What is the default value of sqlite3_busy_timeout?
Asked Answered
V

2

11

This seems like it should be really easy to find out, but I don't see it documented anywhere. If I open a sqlite connection and begin a transaction without specifying a timeout by calling sqlite3_busy_timeout, what default value is used? Or will this somehow cause undefined behavior? The documentation of this method doesn't say.

My specific use case is the version bundled with iOS, but I'm guessing the answer is pretty much the same across platforms.

Verdieverdigris answered 14/8, 2014 at 23:14 Comment(0)
I
11

If neither sqlite3_busy_timeout() nor sqlite3_busy_handler() are set and a writer is active then step() returns SQLITE_BUSY immediately.

Note: In some cases SQLITE_IOERR_BLOCKED is returned See also: Register A Callback To Handle SQLITE_BUSY Errors in the second paragraph where it states

If the busy callback is NULL, then SQLITE_BUSY or SQLITE_IOERR_BLOCKED is returned immediately upon encountering the lock. If the busy callback is not NULL, then the callback might be invoked with two arguments.

Ingesta answered 14/8, 2014 at 23:31 Comment(1)
Now only SQLITE_BUSY is left in the cited paragraph if you open that link.Berny
J
0

You can try doing this:

sqlite> PRAGMA busy_timeout = 30000;

It sets the busy_timeout pragma to 30 seconds.

https://www.sqlite.org/pragma.html#pragma_busy_timeout

From what I've read (the default is 0) which I assume is either immediate busy response or unlimited waiting. Docs don't say. However I am seeing when multiple processes write to db, they will sometimes throw a BUSY error.

Joyless answered 9/7, 2022 at 10:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.