On 15 Aug 2019, at 10:43pm, test user <example.com.use...@gmail.com> wrote:

> Currently the API lets you set a timeout. Does this just retry again after a 
> set amount of time?

SQLite's built-in busy handler (which it uses unless you tell it to use yours 
instead) repeatedly backs off and retries until the timeout you set is 
complete.  The amount of time it backs off for is decided internally and you 
cannot depend on it being the same amount of time every time.  The entire time 
the busy handler takes should never much exceed the amount of time you set as 
your timeout.

> But I was thinking more along the lines of keeping BUSY and the current 
> locking system as is, but using the notification as a hint, that is possibly 
> unreliable.
> 
> E.g. if BUSY (try again (after x seconds OR when hint arrives))

The assumption behind SQLite is that you will do one of three things.  The 
first of them is what most users do:

1) Set a long timeout, but not set your own busy handler.  Then let SQLite 
handle the wait-and-retry loop until it finally gives up and returns 
SQLITE_BUSY.  Then your program announces that the database is inaccessible and 
quits (or gives up that function).

2) Set no timeout and no busy handler.  Receive and handle SQLITE_BUSY by doing 
whatever the program finds suitable.  Perhaps implement your own wait-and-retry 
loop, perhaps do something a lot more sophisticated, appropriate to whatever 
the user expects.

3) Set no timeout and implement your own busy handler.

You can use any other combination that suits you.  Perhaps set a short timeout, 
after which SQLite calls your busy handler, which can do whatever it wants then 
return SQLITE_BUSY to your program.  When the short timeout gets exhausted, 
SQLite calls your own busy handler, and /that's/ your notification.

None of these would use the hint system or try to monitor files directly.  As 
you see, there's an existing way to monitor locks.  You don't need to abuse a 
different notification which isn't really suited to this purpose.
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to