I work with sqlite 3.5.3.
I experimented with threads and I get a strange behavior. it looks
like one thread takes over sqlite and does not leave it until it is
finished even though I tell it to wait (using random after). This is
the script I use:
package require sqlite3
package require Thread
sqlite3 conn test
catch {conn eval "drop table a"}
conn eval "create table a (b varchar(10))"
set t1 [thread::create]
set t2 [thread::create]
set b {
package require sqlite3
sqlite3 conn test
conn timeout 100000
for {set i 0} {$i<10} {incr i} {
puts $i-[thread::id]
conn eval "insert into a values ($i-[thread::id])"
£ wait for randomal time so other thread might take over sqlite
after [expr {int(rand()*100)}]
}
thread::exit
}
thread:::send -async $t1 $b
thread:::send -async $t2 $b
thread::wait
the result is:
0-65539
0-81924
1-65539
2-65539
3-65539
4-65539
5-65539
6-65539
7-65539
8-65539
9-65539
1-81924
2-81924
3-81924
4-81924
5-81924
6-81924
7-81924
8-81924
9-81924
why in the start both threads get access?
why after it only thread 1 access it and thread 2 starts only when
thread 1 finishes. the behavior changes if I increate the after but it
looks like sqlite does not retry for a long time after it meets a
lock.
Yahalom Emet
XPO Team
Xor Financial Solutions
Email: <blocked::mailto:[EMAIL PROTECTED]> [EMAIL PROTECTED]
www.XorTechnologies.com <blocked::http://www.xortechnologies.com/>