Private
Public Access
Make first-run setup race-safe with an atomic SetupLock claim (S4)
The setup view's User.objects.exists() check and the admin account's save() weren't in the same transaction, so two concurrent requests during first deployment could both pass the check and both create an admin account. SetupLock is a singleton row (pk=1); claiming it and creating the admin now happen in one atomic block, so only the first of any racing requests can succeed — the rest hit IntegrityError and are sent to the login page instead. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
56eb2bc498
commit
b52ba2be8a
4 files changed
+74
-7
No files matched your search
@@ -0,0 +1,22 @@
|
||||
# Generated by Django 5.2.18 on 2026-10-31 18:00
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("accounts", "0001_initial"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name="SetupLock",
|
||||
fields=[
|
||||
(
|
||||
"id",
|
||||
models.PositiveSmallIntegerField(default=1, primary_key=True, serialize=False),
|
||||
),
|
||||
],
|
||||
),
|
||||
]
|
||||
Reference in new issue
Block a user