Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Add a test to walthread.test for changing between WAL and rollback modes. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | wal |
Files: | files | file ages | folders |
SHA1: |
da229e44bd4a5d512261da05958d5608 |
User & Date: | dan 2010-04-28 18:17:23.000 |
Context
2010-04-29
| ||
08:47 | Add tests to walthread.test. (check-in: 9e891e7543 user: dan tags: wal) | |
2010-04-28
| ||
18:17 | Add a test to walthread.test for changing between WAL and rollback modes. (check-in: da229e44bd user: dan tags: wal) | |
17:49 | Merge two "wal" leaves. (check-in: 13d2d5a66e user: dan tags: wal) | |
Changes
Changes to test/walthread.test.
︙ | ︙ | |||
57 58 59 60 61 62 63 64 65 66 67 68 69 70 | # # -seconds SECONDS How many seconds to run the test for # -init SCRIPT Script to run before test. # -thread NAME COUNT SCRIPT Scripts to run in threads (or processes). # -processes BOOLEAN True to use processes instead of threads. # proc do_thread_test {args} { set A $args set P(testname) [lshift A] set P(seconds) 5 set P(init) "" set P(threads) [list] set P(processes) 0 | > > > | 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | # # -seconds SECONDS How many seconds to run the test for # -init SCRIPT Script to run before test. # -thread NAME COUNT SCRIPT Scripts to run in threads (or processes). # -processes BOOLEAN True to use processes instead of threads. # proc do_thread_test {args} { #if {[string match walthread-2* [lindex $args 0]]==0} return set A $args set P(testname) [lshift A] set P(seconds) 5 set P(init) "" set P(threads) [list] set P(processes) 0 |
︙ | ︙ | |||
127 128 129 130 131 132 133 | sqlite3 db test.db db busy busyhandler db eval { SELECT randomblob($tid*5) } set ::finished 0 after [expr %SECONDS% * 1000] {set ::finished 1} | | | | 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | sqlite3 db test.db db busy busyhandler db eval { SELECT randomblob($tid*5) } set ::finished 0 after [expr %SECONDS% * 1000] {set ::finished 1} proc tt_continue {} { update ; expr ($::finished==0) } set rc [catch { %TEST% } msg] catch { db close } list $rc $msg }] if {$P(processes)==0} { sqlthread spawn ::done($name,$i) $program } else { testfixture_nb ::done($name,$i) $program |
︙ | ︙ | |||
180 181 182 183 184 185 186 | # 1) Modifying the contents of t1 (inserting, updating, deleting rows). # 2) Appending a new row to the table containing the md5sum() of all # rows in the table. # # Each of the N threads runs N read transactions followed by a single write # transaction in a loop as fast as possible. # | | | 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 | # 1) Modifying the contents of t1 (inserting, updating, deleting rows). # 2) Appending a new row to the table containing the md5sum() of all # rows in the table. # # Each of the N threads runs N read transactions followed by a single write # transaction in a loop as fast as possible. # # There is also a single checkpointer thread. It runs the following loop: # # 1) Execute "PRAGMA checkpoint" # 2) Sleep for 500 ms. # foreach {mode name} { 0 walthread-1-threads |
︙ | ︙ | |||
234 235 236 237 238 239 240 | } } set nRun 0 while {[tt_continue]} { read_transaction write_transaction | < > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 | } } set nRun 0 while {[tt_continue]} { read_transaction write_transaction incr nRun } set nRun } -thread ckpt 1 { set nRun 0 while {[tt_continue]} { db eval "PRAGMA checkpoint" usleep 500 incr nRun } set nRun } } #-------------------------------------------------------------------------- # foreach {mode name} { 0 walthread-2-threads 1 walthread-2-processes } { do_thread_test $name -processes $mode -seconds $SECONDS -init { execsql { CREATE TABLE t1(x INTEGER PRIMARY KEY, y UNIQUE) } } -thread RB 2 { db close set nRun 0 set nDel 0 while {[tt_continue]} { sqlite3 db test.db db busy busyhandler db eval { SELECT * FROM sqlite_master } catch { db eval { PRAGMA journal_mode = DELETE } } db eval { BEGIN; INSERT INTO t1 VALUES(NULL, randomblob(100+$tid)); } incr nRun 1 incr nDel [file exists test.db-journal] db eval COMMIT set ic [db eval {PRAGMA integrity_check}] if {$ic != "ok"} { error $ic } db close } list $nRun $nDel } -thread WAL 2 { db close set nRun 0 set nWal 0 while {[tt_continue]} { sqlite3 db test.db db busy busyhandler db eval { SELECT * FROM sqlite_master } catch { db eval { PRAGMA journal_mode = WAL } } db eval { BEGIN; INSERT INTO t1 VALUES(NULL, randomblob(110+$tid)); } incr nRun 1 incr nWal [file exists test.db-wal] db eval COMMIT set ic [db eval {PRAGMA integrity_check}] if {$ic != "ok"} { error $ic } db close } list $nRun $nWal } } finish_test |