On 26 Jul 2012, at 6:29am, "Navaneeth.K.N" <[email protected]> wrote:

> Recently, I implemented a web version of my program which internally uses
> the shared library. There will be REST URLs exposed for the "learn" API
> call, something like "http://websitename.com/learn"; with the word to learn
> in the request parameters.

Make sure you have encoded the word somehow.  There may be problems with 
'words' which include punctuation or accented characters since they can't be 
passed as URLs.

> Since the web-server allows concurrent requests,
> there could be a possibility that two requests for learn getting executed
> in parallel. In this case, SQLite fails with error message "Database is
> locked" as there would be one writer already in progress.

Have you set a timeout ?  If you haven't the SQLite functions never back off 
and retry when they find the database locked, they just immediately return an 
error.

<http://www.sqlite.org/c3ref/busy_timeout.html>

> Currently, I have implemented a queue at the server side which will queue
> all the requests for learn. Another worker process reads this queue and
> call my library routine for each word sequentially. This works well. But I
> am wondering is this the right way to workaround this problem?

That may be a good way to do it, especially since you've already written it.

Simon.
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to