Opened 11 years ago

Closed 11 years ago

Last modified 10 years ago

#15118 closed (fixed)

MySQL/InnoDB has integrity problems with new deletion code

Reported by: Russell Keith-Magee Owned by: nobody
Component: Database layer (models, ORM) Version: 1.2
Severity: Keywords: blocker
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


It looks like MySQL/InnoDB's inability to defer constraints poses problems

The problem is revealed by the queries.SubclassFKTests regression test. In that test:

TVChef -- is a -- Celebrity -- has many -- fans.

The test deletes a TVChef. In deleting the TVChef, the deletion code deletes the fan objects, then the celebrity... which leaves TVChef as a dangling reference. Under Postgres, the reference check is deferred until the end of the transaction (as it should be); but InnoDB throws a hissy because it reference checks after every statement.

In this case, the problem can be resolved by deleting in a different order. However, I'm not sure if that will yield a general solution.

Change History (4)

comment:1 Changed 11 years ago by Russell Keith-Magee

Triage Stage: UnreviewedAccepted

comment:2 Changed 11 years ago by Carl Meyer

Resolution: fixed
Status: newclosed

(In [15246]) Fixed #15118 - Corrected the deletion-ordering for inherited models.

comment:3 Changed 11 years ago by Carl Meyer

Just to clarify here, there is no general solution. Databases with constraint checking that are incapable of deferring constraint checks (i.e. InnoDB) cannot delete models with a cyclic non-nullable FK dependency (of course, I'm not sure how it could create them either, so it's kind of moot).

There was, however, a bug in this case causing incorrect ordering of deletion of parent and child models, and that's now fixed.

comment:4 Changed 10 years ago by Jacob

milestone: 1.3

Milestone 1.3 deleted

Note: See TracTickets for help on using tickets.
Back to Top