On 10/4/17, Hegde, Deepakakumar (D.) <deep...@allgosystems.com> wrote: > > > 1) Open the Database in the two process > > 2) Both the link are added the busy handler and busy handler function is > retries for 10000 times with 10ms second of delay. > > 3) In one thread there is a continuous record insertion with begin and > commit operation. This begin and commit will be done with for every 200 > record insertion. time for a single begin to the commit is about 1 second.
Because SQLite does not have a separate server process to coordinate access, only a single process at a time can be writing to the database. It sounds like your "continuous insertion" process is monopolizing write access. That process seems to always be in between BEGIN and COMMIT. Probably you are running BEGIN almost immediately after each COMMIT, no? That means that other processes are unable to write unless they get looking and try to write in that very brief interval in between COMMIT and the next BEGIN. Probably your solution is to accumulate data in memory for about 1 second. Then, once per second, run a BEGIN, lots of INSERTs, and a COMMIT. The idea is for there to be a short amount of time in between BEGIN and COMMIT (a few milliseconds) and a much larger amount of time between COMMIT and the next BEGIN (nearly one second). That way, when the process below tries to write, it is likely to hit in between the COMMIT and the BEGIN and be successful. Or, if it is unlucky and hits in between BEGIN and COMMIT, it will get a busy callback until the next COMMIT occurs. I think you will do well to always run "BEGIN IMMEDIATE". That way, any busy timeout will occur on your BEGIN statement, and not on the INSERT or UPDATE or COMMIT that follows, and you never have to worry about retrying the transaction. > > 4) If we try to write INSERT or UPDATE in the other thread using > sqlite3_exec () then it is giving the error. > > Following is the failure cases: > 1) Busy handler is invoked, but it will not get success for 10000 retry and > then give error. > 2) Some time direct error is given without invoking the the busy handler. > > Please can anyone help us to understand the use of the multi-thread handling > of the sqlite? > > Thanks and Regards > Deepak > > _______________________________________________ > sqlite-users mailing list > sqlite-users@mailinglists.sqlite.org > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users > -- D. Richard Hipp d...@sqlite.org _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users