SQLite transactions started deferred. When two ran at once and both read before writing, SQLite refused the second write at once with "database is locked" instead of making it wait. TestCreateUserRaceCondition failed this way now and then (#253); any two concurrent writers in upaas could hit it.
internal/database/database.go now opens the database with _txlock=immediate, so each transaction takes the write lock when it begins and a second one waits for it, and with _busy_timeout=5000, so that wait lasts up to 5 seconds.
Deviation from the issue: the driver already defaults the busy timeout to 5 seconds. _txlock=immediate is the fix; _busy_timeout=5000 only states the wait in the code.
Every transaction now holds the write lock from its start, read-only ones included. All three transactions in upaas write.
Judgement call: the migrations tests open their own in-memory database with no concurrent writers, so they are unchanged.
Model: opus-5-5
SQLite transactions started deferred. When two ran at once and both read before writing, SQLite refused the second write at once with "database is locked" instead of making it wait. `TestCreateUserRaceCondition` failed this way now and then (https://git.eeqj.de/sneak/upaas/issues/253); any two concurrent writers in upaas could hit it.
`internal/database/database.go` now opens the database with `_txlock=immediate`, so each transaction takes the write lock when it begins and a second one waits for it, and with `_busy_timeout=5000`, so that wait lasts up to 5 seconds.
- Deviation from the issue: the driver already defaults the busy timeout to 5 seconds. `_txlock=immediate` is the fix; `_busy_timeout=5000` only states the wait in the code.
- Every transaction now holds the write lock from its start, read-only ones included. All three transactions in upaas write.
- Judgement call: the migrations tests open their own in-memory database with no concurrent writers, so they are unchanged.
Model: opus-5-5
Conflicts with the current next in TODO.md:23: next now has the #248 entry at the top of Completed Steps, where this PR adds its #253 entry. Acceptable: rebase onto the current next, keep both entries with this one on top, and push the branch again.
Model: opus-5-5
- Conflicts with the current `next` in `TODO.md:23`: `next` now has the https://git.eeqj.de/sneak/upaas/issues/248 entry at the top of Completed Steps, where this PR adds its https://git.eeqj.de/sneak/upaas/issues/253 entry. Acceptable: rebase onto the current `next`, keep both entries with this one on top, and push the branch again.
Model: opus-5-5
SQLite transactions started deferred, so two that both read and then
wrote could not both proceed, and SQLite refused the second at once with
"database is locked" without waiting. TestCreateUserRaceCondition hit
this now and then.
The database is now opened with _txlock=immediate, so each transaction
takes the write lock when it begins and a second one waits for it, and
with _busy_timeout=5000, so that wait lasts up to 5 seconds. The driver
already defaults to 5000; it is now stated in the code.
Model: opus-5-5
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
SQLite transactions started deferred. When two ran at once and both read before writing, SQLite refused the second write at once with "database is locked" instead of making it wait.
TestCreateUserRaceConditionfailed this way now and then (#253); any two concurrent writers in upaas could hit it.internal/database/database.gonow opens the database with_txlock=immediate, so each transaction takes the write lock when it begins and a second one waits for it, and with_busy_timeout=5000, so that wait lasts up to 5 seconds._txlock=immediateis the fix;_busy_timeout=5000only states the wait in the code.Model: opus-5-5
nextinTODO.md:23:nextnow has the #248 entry at the top of Completed Steps, where this PR adds its #253 entry. Acceptable: rebase onto the currentnext, keep both entries with this one on top, and push the branch again.Model: opus-5-5
e10d4313bctodd4e9ad4f0Review passed.
Model: opus-5-5