1
0
mirror of https://github.com/sqlite/sqlite.git synced 2026-10-23 21:49:02 +03:00

Ensure that a hot journal is rolled back in the case where a process or system crash resulted in a corrupt super-journal record where the magic and length values are correct but the super-journal name and checksum fields are both zeroed. Frorum post [forum:/info/2026-07-20T18:27:00Z | 2026-07-20T18:27:00Z].

FossilOrigin-Name: bf70dadc2d455844cfd3e759cc2f78bd38841f7362dde302af3dce0d20303935
This commit is contained in:
dan
2026-07-20 20:15:08 +00:00
parent e9dd890d9c
commit 80fd9ec141
5 changed files with 83 additions and 12 deletions

View File

@@ -1,5 +1,5 @@
C Add\sthe\sSQLITE_SHELL_EDITION\scompile-time\soption,\swhich\sif\sset\sto\sa\ndate\snumber\sof\sthe\sform\sYYYYMMDD\swill\stry\sto\sconfigure\sthe\sdefaults\nto\sbe\ssimilar\sto\sthe\slatest\srelease\sat\sor\sprior\sto\sthat\sdate.
D 2026-07-17T00:27:13.979
C Ensure\sthat\sa\shot\sjournal\sis\srolled\sback\sin\sthe\scase\swhere\sa\sprocess\sor\ssystem\scrash\sresulted\sin\sa\scorrupt\ssuper-journal\srecord\swhere\sthe\smagic\sand\slength\svalues\sare\scorrect\sbut\sthe\ssuper-journal\sname\sand\schecksum\sfields\sare\sboth\szeroed.\sFrorum\spost\s[forum:/info/2026-07-20T18:27:00Z\s|\s2026-07-20T18:27:00Z].
D 2026-07-20T20:15:08.230
F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
@@ -727,7 +727,7 @@ F src/os_setup.h 8efc64eda6a6c2f221387eefc2e7e45fd5a3d5c8337a7a83519ba4fbd2957ae
F src/os_unix.c 92a1773139e0c6206a927c7e1648b06287583570b6e253210a06ee3886739d39
F src/os_win.c 1ad2a8679104249197a9ea10d287136484fdf70c1a245bdda393bbfca2033980
F src/os_win.h 5e168adf482484327195d10f9c3bce3520f598e04e07ffe62c9c5a8067c1037b
F src/pager.c a9fe20f18adfe7c3371cb68b42c723e9ce2a068a7558949216d9363359b267cf
F src/pager.c 456a9c16269e31cc8301b4f5aec24aab1e3b38d40e209dfbd359ac9d4794baf8
F src/pager.h 6137149346e6c8a3ddc1eeb40aee46381e9bc8b0fcc6dda8a1efde993c2275b8
F src/parse.y d5a3c5b0277a441c38b35071c05e2b61ff5fc918a63309c809f4b6706179c320
F src/pcache.c 588cc3c5ccaaadde689ed35ce5c5c891a1f7b1f4d1f56f6cf0143b74d8ee6484
@@ -1025,6 +1025,7 @@ F test/crash5.test 4aa55e7ac3c4bc511873e457aa65d2827d52da9b51e061511899dadcfe22b
F test/crash6.test 4c56f1e40d0291e1110790a99807aa875b1647ba
F test/crash7.test 1a194c4900a255258cf94b7fcbfd29536db572df
F test/crash8.test 3a0c39c079b441a9b1da22e3edb58817f9dd330c4c3a7f9dd1f9f7c8368ea352
F test/crash9.test 03082a11471c9468bc0b25440f55a13ee6d27b1b5183f5a64eb0eba887782b6f
F test/crashM.test d95f59046fa749b0d0822edf18a717788c8f318d
F test/crashtest1.c 09c1c7d728ccf4feb9e481671e29dda5669bbcc2
F test/createtab.test 85cdfdae5c3de331cd888d6c66e1aba575b47c2e3c3cc4a1d6f54140699f5165
@@ -1511,7 +1512,7 @@ F test/pcache.test c8acbedd3b6fd0f9a7ca887a83b11d24a007972b
F test/pcache2.test 8a801d2b8e4b0ebb99701f026a67a9e84634c8aa24799a842c44003b93250da1
F test/pendingrace.test e99efc5ab3584da3dfc8cd6a0ec4e5a42214820574f5ea24ee93f1d84655f463
F test/percentile.test fd78896fa882fa4fbf693640097859721f3629926c2ccf804af5bcb7001fd35b
F test/permutations.test 1e3f732d91bcb9fa38665488e7584eade025fb1d2948559673e41c95a2f7c8ee
F test/permutations.test fd0a0feffa0632f276b8199773347e34f0e7719e17771ec2c5489888d51d3bc5
F test/pg_common.tcl 3b27542224db1e713ae387459b5d117c836a5f6e328846922993b6d2b7640d9f
F test/pragma.test 7d07b7bb76e273215d6a20c4f83c3062cc28976c737ccb70a686025801e86c8f
F test/pragma2.test e5d5c176360c321344249354c0c16aec46214c9f
@@ -2204,9 +2205,8 @@ F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee
F tool/warnings.sh a554d13f6e5cf3760f041b87939e3d616ec6961859c3245e8ef701d1eafc2ca2
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
F tool/winmain.c 00c8fb88e365c9017db14c73d3c78af62194d9644feaf60e220ab0f411f3604c
P a508bb8f88e79742df314e51e6404c964547f811d9361233157cd7a748ddfadb
Q +6924895d2cbc50971d8da1810423ad15c638dabc31b4f1083dd6076e20492ef4
R 4761f5ab1cb756e05c9ec229bb0d463f
U drh
Z b1a6453ea1d389ff8f7867cc067b87ae
P 1d84dc151bada74952819b5193a3d39706ef54b6a1b2d52aea04666b7904210f
R 8c93044f747e571fd4f497805da83e02
U dan
Z d43d94ea92fa68a1e71775ba03427cda
# Remove this line to create a well-formed Fossil manifest.

View File

@@ -1 +1 @@
1d84dc151bada74952819b5193a3d39706ef54b6a1b2d52aea04666b7904210f
bf70dadc2d455844cfd3e759cc2f78bd38841f7362dde302af3dce0d20303935

View File

@@ -1334,7 +1334,7 @@ static int readSuperJournal(sqlite3_file *pJrnl, u64 nSuper, char **pzSuper){
cksum -= zOut[u];
}
}
if( rc!=SQLITE_OK || cksum ){
if( rc!=SQLITE_OK || cksum || zOut[0]==0 ){
/* If the checksum doesn't add up, then one or more of the disk sectors
** containing the super-journal filename is corrupted. This means
** definitely roll back, so just return SQLITE_OK and report a (nul)

71
test/crash9.test Normal file
View File

@@ -0,0 +1,71 @@
# 2026 July 21
#
# 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.
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
set testprefix crash9
forcedelete test.db2
#-------------------------------------------------------------------------
# The following test is to hit the bug reported here:
#
# https://sqlite.org/forum/info/2026-07-20T18:27:00Z
#
# Essentially, when a super-journal record is appended to a journal file,
# if the write() calls that set the super-journal magic values and length
# succeed, but the calls that write the super-journal name and checksum
# fail and end up writing zeroes into the file, then the super-journal
# checksum appears to match (because 0 is the checksum for a zero length
# string). This was confusing SQLite, preventing it from rolling the
# journal back later on.
#
do_execsql_test 1.0 {
CREATE TABLE t1(x INTEGER PRIMARY KEY, y);
CREATE INDEX i1 ON t1(y);
WITH s(i) AS (
SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<10
)
INSERT INTO t1 SELECT i, randomblob(900) FROM s;
ATTACH 'test.db2' AS aux;
CREATE TABLE aux.t2(x, y);
}
db_save_and_close
for {set ii 0} {$ii < 200} {incr ii} {
set iDelay 1
while 1 {
db_restore
set c [crashsql -delay $iDelay -file test.db-journal -seed $ii "
ATTACH 'test.db2' AS aux;
PRAGMA cache_size = 5;
BEGIN;
INSERT INTO aux.t2 VALUES(1, 2);
UPDATE t1 SET y=randomblob(901);
COMMIT;
"]
if {$c!="1 {child process exited abnormally}"} break
sqlite3 db test.db
do_execsql_test 1.1.$ii.$iDelay { PRAGMA integrity_check } ok
incr iDelay
db close
}
}
finish_test

View File

@@ -117,7 +117,7 @@ set alltests [test_set $alltests -exclude {
set allquicktests [test_set $alltests -exclude {
backup_ioerr.test corrupt.test
corruptC.test crash.test crash2.test crash3.test crash4.test crash5.test
crash6.test crash7.test delete3.test e_fts3.test fts3rnd.test
crash6.test crash7.test crash9.test delete3.test e_fts3.test fts3rnd.test
fkey_malloc.test fuzz.test fuzz3.test fuzz_malloc.test in2.test loadext.test
misc7.test mutex2.test onefile.test pagerfault2.test
savepoint4.test savepoint6.test select9.test