>
> In a message dated 6/4/2004 11:53:05 AM Eastern Daylight Time,
> [EMAIL PROTECTED] writes:
>
> I'm  using SQLite on a Windows XP system with 1GB of RAM. I'm writing a
> server  which spawns multiple threads for it's connections. It is
> querying and  writing to an SQLite database within each thread. Whenever
> a query or  insert/update statement is issued, the SQLite database is
> opened,  queried/written to, and closed again. When a bunch of queries
> come in  (about 10 in a second, for instance), SQLite reports that the
> database is  locked despite my setting the sqlite_busy_timeout to 150 or
> so. Certain  database writes thus do not take place, which is a major
> problem. If I  detect when my call returns SQLITE_BUSY and sleep for a
> while (about 100  ms) and re-try the call, it continuously says that the
> database is  locked.

I have many similar apps that do this, and the best method I discovered that
did the job was to have a database thread that serializes all the requests
and puts them into a transaction.  Then after a certain period of time
commits all changes to the database.  Your other worker threads sends the
SQL statements to the single database thread, where it queues/puts them into
a transaction, executes each statement, then returns back whatever values
you need back to the calling thread.  Depending on the type of database,
(memory or file) I can get extremely fast speeds using this method without
the worry of blocking.

Jay Macaulay


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to