1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-29 08:01:23 +03:00

Fix a second race condition in lock4.test. (CVS 4861)

FossilOrigin-Name: e62858b9b8a12ecbad8037868d03469d27418377
This commit is contained in:
danielk1977
2008-03-14 08:57:41 +00:00
parent 969b2cd74a
commit d5fe8d6c43
3 changed files with 25 additions and 10 deletions

View File

@ -11,7 +11,7 @@
# This file implements regression tests for SQLite library. The
# focus of this script is database locks.
#
# $Id: lock4.test,v 1.7 2008/03/13 04:53:53 danielk1977 Exp $
# $Id: lock4.test,v 1.8 2008/03/14 08:57:42 danielk1977 Exp $
set testdir [file dirname $argv0]
@ -49,6 +49,9 @@ do_test lock4-1.1 {
# to continue.
#
do_test lock4-1.2 {
# Create a script for the second process to run.
#
set out [open test2-script.tcl w]
puts $out "set sqlite_pending_byte [set sqlite_pending_byte]"
puts $out {
@ -67,14 +70,22 @@ do_test lock4-1.2 {
exit
}
close $out
# Begin a transaction on test.db.
db eval {
BEGIN;
BEGIN EXCLUSIVE;
INSERT INTO t1 VALUES(1);
}
# Kick off the second process.
exec [info nameofexec] ./test2-script.tcl &
# Wait until the second process has started its transaction on test2.db.
while {![file exists test2.db-journal]} {
after 10
}
# Try to write to test2.db. We are locked out.
sqlite3 db2 test2.db
catchsql {
INSERT INTO t2 VALUES(1)
@ -87,6 +98,10 @@ do_test lock4-1.3 {
while {[file exists test2.db-journal]} {
after 10
}
# The other process has committed its transaction on test2.db by
# deleting the journal file. But it might retain the lock for a
# fraction longer
#
db2 eval {
SELECT * FROM t2
}