]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Add some warm-body tests for rollback journal i/o enhancements. (CVS 4279)
authordanielk1977 <danielk1977@noemail.net>
Thu, 23 Aug 2007 16:27:21 +0000 (16:27 +0000)
committerdanielk1977 <danielk1977@noemail.net>
Thu, 23 Aug 2007 16:27:21 +0000 (16:27 +0000)
FossilOrigin-Name: ff3770f855c1dd75025b1f2496f8c75e9f17ee44

manifest
manifest.uuid
test/io.test
test/quick.test

index a764a905cb4743a2a07e2b70ccae3e9de99730fd..c2b64c433ddf30b35d67dc70f254ff74c01f9438 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Add\scode\sto\sreduce\srollback\sjournal\si/o\sbased\son\sIOCAP\sflags.\sAs\syet\suntested.\s(CVS\s4278)
-D 2007-08-23T14:48:24
+C Add\ssome\swarm-body\stests\sfor\srollback\sjournal\si/o\senhancements.\s(CVS\s4279)
+D 2007-08-23T16:27:21
 F Makefile.in 0c0e53720f658c7a551046442dd7afba0b72bfbe
 F Makefile.linux-gcc 65241babba6faf1152bf86574477baab19190499
 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@@ -319,7 +319,7 @@ F test/insert3.test 72ea6056811fd234f80d923f977c196089947381
 F test/insert4.test 1e27f0a3e5670d5f03c1636f699aa44270945bca
 F test/interrupt.test 81555fb0f8179bb2d0dc7151fd75428223f93cf2
 F test/intpkey.test af4fd826c4784ec5c93b444de07adea0254d0d30
-F test/io.test 4368da68ae82a8496cd3904a886345b75303979f
+F test/io.test 689a16c1a4c9e42e132a02632a48fbe8c7b5cab6
 F test/ioerr.test 491d42c49bbec598966d26b01ed7901f55e5ee2d
 F test/ioerr2.test f938eadb12108048813869b86beee4a2f98e34b8
 F test/join.test af0443185378b64878750aa1cf4b83c216f246b4
@@ -377,7 +377,7 @@ F test/pragma2.test bb5aa7be00dae2c381fcc782358048a33c955793
 F test/printf.test 69d8cb0771a1a5e4d9d5dece12fc2c16179ac5e5
 F test/progress.test 5b075c3c790c7b2a61419bc199db87aaf48b8301 x
 F test/ptrchng.test 1c712dd6516e1377471744fa765e41c79a357da6
-F test/quick.test 1284e8b506596ccaa25e69963e87b58dc09f5a68
+F test/quick.test 88844a19f6d9dc5c990e01c7dd611d33d022a1c1
 F test/quote.test 215897dbe8de1a6f701265836d6601cc6ed103e6
 F test/rdonly.test b34db316525440d3b42c32e83942c02c37d28ef0
 F test/reindex.test 38b138abe36bf9a08c791ed44d9f76cd6b97b78b
@@ -560,7 +560,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130
 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
 F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
 F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
-P cf4e3c158aa71afc91f263a314c2e750d191fb41
-R 48618499cdb378fd88ded4f7882609ca
+P 595568492e63822caed5b6970542dcee4615dc4d
+R 481110817a2ed016cc610c9d83519f44
 U danielk1977
-Z c7849b12c2cdd0aee60800e4b6323c91
+Z bffb4d15c81e758cd2ec1b776561f96d
index e3b70f662e30dc1d01bd2bf2f4196dde2f383b33..ed827a68137df28d2b7f698be89d104c3cbee6e7 100644 (file)
@@ -1 +1 @@
-595568492e63822caed5b6970542dcee4615dc4d
\ No newline at end of file
+ff3770f855c1dd75025b1f2496f8c75e9f17ee44
\ No newline at end of file
index 640b6b0ba7a793933bf048a7d5ce743b633b177f..1ef72c4a0eb375a44b970bffd15715b63a5b05b4 100644 (file)
@@ -13,7 +13,7 @@
 # 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 $
+# $Id: io.test,v 1.5 2007/08/23 16:27:21 danielk1977 Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -21,8 +21,17 @@ 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.
+#
+# 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
@@ -315,8 +324,145 @@ do_test io-2.10.2 {
   }
   file exists test.db-journal
 } {0}
+do_test io-2.10.3 {
+  execsql { ROLLBACK }
+} {}
 
-sqlite3_simulate_device -char {} -sectorsize 0
+#----------------------------------------------------------------------
+# 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
 
index 0ea4daea9a136975a99f507efd5e4608f7b8b6cb..490a5283abfdaa2d9dcc801046e46db285734a58 100644 (file)
@@ -6,7 +6,7 @@
 #***********************************************************************
 # This file runs all tests.
 #
-# $Id: quick.test,v 1.61 2007/08/23 02:47:54 drh Exp $
+# $Id: quick.test,v 1.62 2007/08/23 16:27:21 danielk1977 Exp $
 
 proc lshift {lvar} {
   upvar $lvar l
@@ -47,6 +47,7 @@ set EXCLUDE {
   corrupt.test
   crash.test
   crash2.test
+  crash3.test
   exclusive3.test
   fuzz.test
   fuzz_malloc.test