On 19 Oct 2009, at 5:44pm, P Kishor wrote:

> But, if I enter something in the field, and, instead of tabbing out of
> it, if I click on the submit button, two events fire simultaneously.
> There is the onblur() from the field (this is a SELECT query), and the
> submit from the form (this is an UPDATE/INSERT query). The events
> reach sqlite simultaneously, and it croaks.

That was my conclusion when I made my response.  It's why I suggested  
putting a delay into the routine that reacts to the 'submit' button.

> Now, here is the question -- in real life, the web server would
> receive many concurrent requests, not just the one described above.
> What happens in that case? If there is an UPDATE/INSERT request while
> a SELECT is happens to be happening, there is going to be a block, no?
> Putting logic in my code to keep retrying till a query (SELECT or
> UPDATE/INSERT) succeeds is going to be very messy. Does this make
> sqlite unsuitable for a web application?

In any web-facing application, there's always the chance that two  
users will do things at more or less the same time.  SQLite, like any  
version of SQL which can react to more than one thread, has timeouts,  
backoffs, etc. to cope with this.  But at some level or other you will  
have to code your software to deal with the timeout, and implement  
your own backoff procedure.

Systems like MySQL, intended from the start as for multi-process,  
multi-user use, have better and more persistent methods of dealing  
with contention.  But yes, if you thrash them hard enough they too  
will eventually return some sort of 'busy' or 'locked' status, and you  
have to write your own code to deal with that.  The difference is  
which model you want to adopt:

Clients talk to your software using TCP/IP:

many users -->    one copy of my software -->  one SQL engine --> one  
file

Software talks to MySQL over TCP/IP:

many users --> many copies of my software -->  one SQL engine --> one  
file

Software includes SQLite library, which accesses files over filesharing:

many users --> many copies of my software --> many SQL engines --> one  
file

The most commonly used Apache models are types 2 and 3, because Apache  
starts one instance of PHP for request for a web page.

Simon.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to