/ Check-in [ff3770f8]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add some warm-body tests for rollback journal i/o enhancements. (CVS 4279)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: ff3770f855c1dd75025b1f2496f8c75e9f17ee44
User & Date: danielk1977 2007-08-23 16:27:21
Context
2007-08-23
20:23
Fix fts3 to not have the VACUUM bug from fts2. %_content.docid is an alias to fix the rowid for documents, %_segments.blockid is an alias to fix the rowid for segment blocks. Unit test for the problem. (CVS 4280) check-in: 6eb2d74a user: shess tags: trunk
16:27
Add some warm-body tests for rollback journal i/o enhancements. (CVS 4279) check-in: ff3770f8 user: danielk1977 tags: trunk
14:48
Add code to reduce rollback journal i/o based on IOCAP flags. As yet untested. (CVS 4278) check-in: 59556849 user: danielk1977 tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to test/io.test.

9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24

25









26
27
28
29
30
31
32
...
311
312
313
314
315
316
317



318










































319
320




























































































321
322
#
#***********************************************************************
#
# The focus of this file is testing some specific characteristics of the 
# IO traffic generated by SQLite (making sure SQLite is not writing out
# more database pages than it has to, stuff like that).
#
# $Id: io.test,v 1.4 2007/08/23 11:07:10 danielk1977 Exp $

set testdir [file dirname $argv0]
source $testdir/tester.tcl

# Test summary:
#
# io-1.* -  Test that quick-balance does not journal pages unnecessarily.
# io-2.* -  Test that when the atomic-write optimisation is used no

#           journal file is created.









#           

set ::nWrite 0
proc nWrite {db} {
  set bt [btree_from_db $db]
  db_enter $db
  array set stats [btree_pager_stats $bt]
................................................................................
  sqlite3_simulate_device -char atomic2k
  execsql {
    BEGIN;
    INSERT INTO abc VALUES(11, 12);
  }
  file exists test.db-journal
} {0}














































sqlite3_simulate_device -char {} -sectorsize 0





























































































finish_test








|







<
>
|
>
>
>
>
>
>
>
>
>







 







>
>
>

>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|

>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>


9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
...
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
#
#***********************************************************************
#
# The focus of this file is testing some specific characteristics of the 
# IO traffic generated by SQLite (making sure SQLite is not writing out
# more database pages than it has to, stuff like that).
#
# $Id: io.test,v 1.5 2007/08/23 16:27:21 danielk1977 Exp $

set testdir [file dirname $argv0]
source $testdir/tester.tcl

# Test summary:
#
# io-1.* -  Test that quick-balance does not journal pages unnecessarily.

#
# io-2.* -  Test the "atomic-write optimization".
#
# io-3.* -  Test the IO traffic enhancements triggered when the 
#           IOCAP_SEQUENTIAL device capability flag is set (no 
#           fsync() calls on the journal file).
#
# io-4.* -  Test the IO traffic enhancements triggered when the 
#           IOCAP_SAFE_APPEND device capability flag is set (fewer 
#           fsync() calls on the journal file, no need to set nRec
#           field in the single journal header).
#           

set ::nWrite 0
proc nWrite {db} {
  set bt [btree_from_db $db]
  db_enter $db
  array set stats [btree_pager_stats $bt]
................................................................................
  sqlite3_simulate_device -char atomic2k
  execsql {
    BEGIN;
    INSERT INTO abc VALUES(11, 12);
  }
  file exists test.db-journal
} {0}
do_test io-2.10.3 {
  execsql { ROLLBACK }
} {}

#----------------------------------------------------------------------
# Test cases io-3.* test the IOCAP_SEQUENTIAL optimization.
#
sqlite3_simulate_device -char sequential -sectorsize 0
do_test io-3.1 {
  db close
  file delete -force test.db test.db-journal
  sqlite3 db test.db
  file size test.db
} {0}
do_test io-3.2 {
  execsql { CREATE TABLE abc(a, b) }
  nSync
  execsql {
    PRAGMA cache_size = 10;
    BEGIN;
    INSERT INTO abc VALUES('hello', 'world');
    INSERT INTO abc SELECT * FROM abc;
    INSERT INTO abc SELECT * FROM abc;
    INSERT INTO abc SELECT * FROM abc;
    INSERT INTO abc SELECT * FROM abc;
    INSERT INTO abc SELECT * FROM abc;
    INSERT INTO abc SELECT * FROM abc;
    INSERT INTO abc SELECT * FROM abc;
    INSERT INTO abc SELECT * FROM abc;
    INSERT INTO abc SELECT * FROM abc;
    INSERT INTO abc SELECT * FROM abc;
    INSERT INTO abc SELECT * FROM abc;
  }
  # File has grown - showing there was a cache-spill - but there 
  # have been no calls to fsync():
  list [file size test.db] [nSync]
} {31744 0}
do_test io-3.3 {
  # The COMMIT requires a single fsync() - to the database file.
  execsql { COMMIT }
  list [file size test.db] [nSync]
} {39936 1}

#----------------------------------------------------------------------
# Test cases io-4.* test the IOCAP_SAFE_APPEND optimization.
#
sqlite3_simulate_device -char safe_append

# With the SAFE_APPEND flag set, simple transactions require 3, rather
# than 4, calls to fsync(). The fsync() calls are on:
#
#   1) The directory in which the journal file is created,
#   2) The journal file (to sync the page data),
#   3) The database file.
#
# Normally, when the SAFE_APPEND flag is not set, there is another fsync()
# on the journal file between steps (2) and (3) above.
#
do_test io-4.1 {
  execsql { DELETE FROM abc }
  nSync
  execsql { INSERT INTO abc VALUES('a', 'b') }
  nSync
} {3}

# With SAFE_APPEND set, the nRec field of the journal file header should
# be set to 0xFFFFFFFF before the first journal sync. The nRec field
# occupies bytes 8-11 of the journal file.
#
do_test io-4.2.1 {
  execsql { BEGIN }
  execsql { INSERT INTO abc VALUES('c', 'd') }
  file exists test.db-journal
} {1}
do_test io-4.2.2 {
  set fd [open test.db-journal]
  fconfigure $fd -translation binary -encoding binary
  seek $fd 8
  set blob [read $fd 4]
  close $fd
  binary scan $blob i res
  format 0x%X $res
} {0xFFFFFFFF}
do_test io-4.2.3 {
  execsql { COMMIT }
  nSync
} {3}

sqlite3_simulate_device -char safe_append

# With SAFE_APPEND set, there should only ever be one journal-header
# written to the database, even though the sync-mode is "full".
#
do_test io-4.3.1 {
  execsql {
    INSERT INTO abc SELECT * FROM abc;
    INSERT INTO abc SELECT * FROM abc;
    INSERT INTO abc SELECT * FROM abc;
    INSERT INTO abc SELECT * FROM abc;
    INSERT INTO abc SELECT * FROM abc;
    INSERT INTO abc SELECT * FROM abc;
    INSERT INTO abc SELECT * FROM abc;
    INSERT INTO abc SELECT * FROM abc;
    INSERT INTO abc SELECT * FROM abc;
    INSERT INTO abc SELECT * FROM abc;
    INSERT INTO abc SELECT * FROM abc;
  }
  expr {[file size test.db]/1024}
} {43}
do_test io-4.3.2 {
  execsql {
    PRAGMA synchronous = full;
    PRAGMA cache_size = 10;
    PRAGMA synchronous;
  }
} {2}
do_test io-4.3.3 {
  execsql {
    BEGIN;
    UPDATE abc SET a = 'x';
  }
  file exists test.db-journal
} {1}
do_test io-4.3.4 {
  # The UPDATE statement in the statement above modifies 41 pages 
  # (all pages in the database except page 1 and the root page of 
  # abc). Because the cache_size is set to 10, this must have required
  # at least 4 cache-spills. If there were no journal headers written
  # to the journal file after the cache-spill, then the size of the
  # journal file is give by:
  #
  #    <jrnl file size> = <jrnl header size> + nPage * (<page-size> + 8)
  #
  # If the journal file contains additional headers, this formula
  # will not predict the size of the journal file.
  #
  file size test.db-journal
} [expr 1024 + (1024+8)*41]

sqlite3_simulate_device -char {} -sectorsize 0
finish_test

Changes to test/quick.test.

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
..
43
44
45
46
47
48
49

50
51
52
53
54
55
56
#    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 runs all tests.
#
# $Id: quick.test,v 1.61 2007/08/23 02:47:54 drh Exp $

proc lshift {lvar} {
  upvar $lvar l
  set ret [lindex $l 0]
  set l [lrange $l 1 end]
  return $ret
}
................................................................................
  btree3.test
  btree4.test
  btree5.test
  btree6.test
  corrupt.test
  crash.test
  crash2.test

  exclusive3.test
  fuzz.test
  fuzz_malloc.test
  in2.test
  loadext.test
  malloc.test
  malloc2.test







|







 







>







2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
..
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#    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 runs all tests.
#
# $Id: quick.test,v 1.62 2007/08/23 16:27:21 danielk1977 Exp $

proc lshift {lvar} {
  upvar $lvar l
  set ret [lindex $l 0]
  set l [lrange $l 1 end]
  return $ret
}
................................................................................
  btree3.test
  btree4.test
  btree5.test
  btree6.test
  corrupt.test
  crash.test
  crash2.test
  crash3.test
  exclusive3.test
  fuzz.test
  fuzz_malloc.test
  in2.test
  loadext.test
  malloc.test
  malloc2.test