#36551: Race condition in savepoint ID generation causes duplicate identifiers
-------------------------------------+-------------------------------------
Reporter: Mijo Kristo | Owner: (none)
Type: Bug | Status: closed
Component: Database layer | Version:
(models, ORM) |
Severity: Normal | Resolution: invalid
Keywords: threading savepoint | Triage Stage:
race condition thread safety | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Natalia Bidart):
* resolution: => invalid
* status: new => closed
Comment:
I've looked into this some more, and my conclusion is that, in practice,
the race condition described here can't happen under normal Django usage.
Each database connection is tied to a single thread, and the call to
`self.validate_thread_sharing()` enforces this. All `savepoint()` calls
happen inside `transaction.atomic()` blocks on the same thread, so
`savepoint_state` is safely incremented sequentially. Therefore, for
documented ORM usage, duplicate savepoint IDs should not occur.
If you are seeing this issue in a real django project, please share a
minimal reproducer or a django test case for us to evaluate further. Until
then, I'll close this issue as `invalid` following the
[https://docs.djangoproject.com/en/dev/internals/contributing/triaging-
tickets/#closing-tickets ticket triaging process].
--
Ticket URL: <https://code.djangoproject.com/ticket/36551#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/django-updates/01070198a91c6370-8b374c48-7b89-4603-a757-c35705ee0a11-000000%40eu-central-1.amazonses.com.