Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Fix a second race condition in lock4.test. (CVS 4861) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
e62858b9b8a12ecbad8037868d03469d |
User & Date: | danielk1977 2008-03-14 08:57:42.000 |
Context
2008-03-14
| ||
13:02 | Revise Bitvec struct sizing to prevent assertion failure on 64-bit systems (CVS 4862) (check-in: a3c12dbe95 user: mlcreech tags: trunk) | |
08:57 | Fix a second race condition in lock4.test. (CVS 4861) (check-in: e62858b9b8 user: danielk1977 tags: trunk) | |
04:11 | Allow the testfixture to be built even when using the amalgamation (CVS 4860) (check-in: 8a726e3731 user: mlcreech tags: trunk) | |
Changes
Changes to test/lock4.test.
1 2 3 4 5 6 7 8 9 10 11 12 13 | # 2007 April 6 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this script is database locks. # | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # 2007 April 6 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this script is database locks. # # $Id: lock4.test,v 1.8 2008/03/14 08:57:42 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Initialize the test.db database so that it is non-empty # |
︙ | ︙ | |||
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | # # A. Get an exclusive lock on test.db # B. Attempt to read from test2.db but get an SQLITE_BUSY error. # C. Commit the changes to test.db thus alloing the other process # to continue. # do_test lock4-1.2 { set out [open test2-script.tcl w] puts $out "set sqlite_pending_byte [set sqlite_pending_byte]" puts $out { sqlite3 db2 test2.db db2 eval { BEGIN; INSERT INTO t2 VALUES(2); } sqlite3 db test.db db timeout 1000000 db eval { INSERT INTO t1 VALUES(2); } db close db2 eval COMMIT exit } close $out db eval { | > > > > > | > > > > > > > > > > | 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | # # A. Get an exclusive lock on test.db # B. Attempt to read from test2.db but get an SQLITE_BUSY error. # C. Commit the changes to test.db thus alloing the other process # 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 { sqlite3 db2 test2.db db2 eval { BEGIN; INSERT INTO t2 VALUES(2); } sqlite3 db test.db db timeout 1000000 db eval { INSERT INTO t1 VALUES(2); } db close db2 eval COMMIT exit } close $out # Begin a transaction on test.db. db eval { 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) } db2 } {1 {database is locked}} do_test lock4-1.3 { db eval { COMMIT; } 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 } } {2} do_test lock4-999.1 { rename db2 {} } {} finish_test |