SQLite: fail at once on a locked database again (no 2 s busy wait) #21

Merged
ClaudeAI merged 1 commits from fix/sqlite-no-busy-wait into master 49 minutes ago
Collaborator

Summary

PR #7 set a 2-second SQLite busy timeout on every connection, so a statement on a locked database blocked its caller (while holding the connector mutex) for up to 2 seconds. This restores the original behaviour: a locked database fails at once with SQLITE_BUSY. The fix from PR #7 for the endless row-allocating loop on SQLITE_BUSY stays.

Changes (lib/data/sqlite/sqlite_class.cpp/.h)

  • SQLITE_BUSY_TIMEOUT_MS defaults to 0 (no busy handler). It can still be overridden with -DSQLITE_BUSY_TIMEOUT_MS=....
  • New SQLite_Connector::setBusyTimeout(ms) to opt in to waiting per connection. It applies to an open persistent link and on every ReConnect(). Nothing calls it yet.
  • SilentQuery logs a failed step (code and message), as Query does. A statement that returns rows still returns false without a log.

Testing

  • Two connections on the same file, one holding BEGIN EXCLUSIVE:
    • default: the second write fails in 0 ms;
    • setBusyTimeout(500): it fails after about 502 ms;
    • after COMMIT: it succeeds.
  • sqlite_class, SQLite_dataBinder (la_mojo) and servaSessionManager (la_serva) compile with the Debug86 flags. The full programs were not built or run.

Behaviour change to watch

Code that writes to the same database from several connections will see SQLITE_BUSY failures immediately instead of after a wait.

Generated with Claude Code

https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16

## Summary PR #7 set a 2-second SQLite busy timeout on every connection, so a statement on a locked database blocked its caller (while holding the connector mutex) for up to 2 seconds. This restores the original behaviour: a locked database fails at once with `SQLITE_BUSY`. The fix from PR #7 for the endless row-allocating loop on `SQLITE_BUSY` stays. ### Changes (`lib/data/sqlite/sqlite_class.cpp/.h`) - `SQLITE_BUSY_TIMEOUT_MS` defaults to `0` (no busy handler). It can still be overridden with `-DSQLITE_BUSY_TIMEOUT_MS=...`. - New `SQLite_Connector::setBusyTimeout(ms)` to opt in to waiting per connection. It applies to an open persistent link and on every `ReConnect()`. Nothing calls it yet. - `SilentQuery` logs a failed step (code and message), as `Query` does. A statement that returns rows still returns false without a log. ## Testing - Two connections on the same file, one holding `BEGIN EXCLUSIVE`: - default: the second write fails in 0 ms; - `setBusyTimeout(500)`: it fails after about 502 ms; - after `COMMIT`: it succeeds. - `sqlite_class`, `SQLite_dataBinder` (la_mojo) and `servaSessionManager` (la_serva) compile with the `Debug86` flags. The full programs were not built or run. ## Behaviour change to watch Code that writes to the same database from several connections will see `SQLITE_BUSY` failures immediately instead of after a wait. Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
ClaudeAI added 1 commit 50 minutes ago
4b0ddc3ed0
SQLite: fail at once on a locked database again (no 2 s busy wait)
ClaudeAI merged commit da0adac736 into master 49 minutes ago
The pull request has been merged as da0adac736.
Sign in to join this conversation.
No reviewers
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date

No due date set.

Dependencies

This pull request currently doesn't have any dependencies.

Loading…
There is no content yet.