Yes.  This is a bug, but I have not filed it yet.  The problem is that the the 
Tcl errorcode command does not return a 5 (SQLITE_BUSY) when the DB is in use.  
Instead, Tcl crashes with a "database locked" message.  
  For example,
   sqlite dbCmd $dataBase
 dbCmd timeout 3000
 set qryResult [dbCmd eval $query]
 set errorCode [dbCmd errorcode]
 dbCmd close
   
  So this means that instead of checking the errorcode to try again on a locked 
DB you need to enclose everything in a "catch" statement, and check the "catch" 
for an error.
  
All said though, I love this DB and the Tcl interface.  I really want to thank 
the author for providing these Tcl APIs since Tcl is the most powerful 
scripting language ever developed.
  
Ulrich Schöbel <[EMAIL PROTECTED]> wrote:
  Hi all,

I'm using sqlite3 inside a Tcl module (mod_websh) of
apache. Everything works fine, except when it comes
to concurrent write accesses.

There's a small transaction where I update two rows.
When I stress the web server it generates a
"database locked" error. I invoke a "db timeout 2000"
just before the transaction, but it doesn't seem to
have any effect.

When I stumbled over this problem I increased the
timeout to 500000, which is much longer than the
stress test takes, but the error persists. What's
going wrong here?

Here's a short code snippet:

db timeout 500000
db transaction {
set last_acc [lindex [db eval {
select acc_time from last_hit where site = $site and from_ip = $ip
}] 0]
if {![string length $last_acc]} {
db eval {
insert into last_hit values ($site , $ip , $now)
}
set last_acc 0
} else {
db eval {
update last_hit set acc_time = $now where site = $site and from_ip = 
$ip }
}
......
} ;# end of transaction

There's another update inside this transaction, but
it's always the one above that fails.

Maybe the "busy" method is better suited here, but
the docs say nothing about its usage.

Thanks for any help

Ulrich

-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------


Reply via email to