Opened 5 years ago

Closed 5 years ago

Last modified 4 years ago

#15118 closed (fixed)

MySQL/InnoDB has integrity problems with new deletion code

Reported by: russellm 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: UI/UX:

Description

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 5 years ago by russellm

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 5 years ago by carljm

  • Resolution set to fixed
  • Status changed from new to closed

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

comment:3 Changed 5 years ago by carljm

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 4 years ago by jacob

  • milestone 1.3 deleted

Milestone 1.3 deleted

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