Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more options for opening SQLite databases - busy_timeout and journal_mode - and set busy time-out by default #83

Merged
merged 5 commits into from
Feb 12, 2024

Conversation

Mytherin
Copy link
Contributor

@Mytherin Mytherin commented Feb 5, 2024

Fixes #82

This PR adds two new settings when attaching SQLite databases - busy_timeout and journal_mode.

  • busy_timeout specifies a busy timeout in milliseconds, see here. This refers to the amount of time the process will wait if there is another process operating on the SQLite file. The default is now set to 5 seconds (i.e. BUSY_TIMEOUT = 5000), which is the same default used by rusqlite.
  • journal_mode specifies a journaling mode, e.g. journal_mode can be WAL. See here for more info.

Usage:

ATTACH 'file.db' AS f (TYPE SQLITE, BUSY_TIMEOUT 0);
ATTACH  'file.db' AS f (TYPE SQLITE, JOURNAL_MODE 'WAL');

This fixes the linked issue by specifying a busy time-out by default which prevents database is locked errors from appearing until after the timeout has passed. To restore previous behavior where the system would immediately return database is locked a busy_timeout of 0 can be specified.

@Mytherin Mytherin merged commit c134346 into duckdb:main Feb 12, 2024
17 checks passed
breckcs pushed a commit to breckcs/duckdb_sqlite_scanner_concurrency_tests that referenced this pull request Mar 22, 2024
- Updated duckdb-rs to v0.10.1 to include the fix for duckdb/duckdb-sqlite#82
- Added JOURNAL_MODE 'WAL' when DuckDB attaches the SQLite database as documented in duckdb/duckdb-sqlite#83
- These two changes, however, did not seem to fix the concurrency errors documented in duckdb/duckdb-sqlite#82
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SQLite/DuckDB Concurrency Errors Within a Single Process
1 participant