Changes between Version 2 and Version 3 of Ticket #29721, comment 12


Ignore:
Timestamp:
Oct 7, 2026, 2:05:37 AM (8 hours ago)
Author:
Gavin Wahl(vendor)

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #29721, comment 12

    v2 v3  
    11After #32374, the bug still happens for migrations that use deferred sql (which is a lot, like CreateModel, AlterField...). Maybe BaseDatabaseSchemaEditor needs to take a record_migration callback so it can always be recorded in the atomic block? The deferred_sql check was kind of deeply coupled.
    22
    3 I believe the most realistic and reliable reproducible reproducer is to add `import os; os.kill(os.getpid(), 9)  # simulate an hard crash during migration recording.` to the first line of record_migration. A unrecoverable hard crash can happen at any time, that's why we have transactions.
     3I believe the most realistic and reliable reproducible reproducer is to simulate a hard crash during migration recording by adding `import os; os.kill(os.getpid(), 9)` or `import sys; sys.exit()` to the first line of BaseDatabaseSchemaEditor.record_migration. A unrecoverable hard crash can happen at any time, that's why we have transactions.
    44
    55I've reproduced the issue with a deferred_sql migration and tested this fix
    … …  
    7171}}}
    7272
     73Minimal model to get deferred_sql:
     74
     75{{{#!python
     76from django.db import models
     77
     78class Foo(models.Model):
     79    a = models.ForeignKey('self', on_delete=models.CASCADE)
     80}}}
     81
Back to Top