311 Commits

Author SHA1 Message Date
drh
8741d0ddb0 Fix a harmless compiler warning that arose from the ENABLE_CURSOR_HINTS
fix of check-in [0af18674ca5b34e67e]

FossilOrigin-Name: f578e62ae6f6cc78d8281adab9fa93f3f58711879c2860bbe19f291d257dc0af
2018-09-12 00:21:11 +00:00
dan
8d4b7a3fa8 If a call to sqlite3_snapshot_open() fails because the requested snapshot no
longer exists, return SQLITE_ERROR_SNAPSHOT instead of SQLITE_BUSY_SNAPSHOT.

FossilOrigin-Name: e07923128bb164efbafde29d49175b61f2ef44b2dfac5ae4ed61937945dfcf4c
2018-08-31 19:00:16 +00:00
drh
876c7ea3fa Try to identify the places in WAL code where thread-safety depends on the
underlying architecture supporting atomic load and store of aligned 32-bit
values.

FossilOrigin-Name: 47d44be4a68d377d0049a12b2587dbbcc0870b469473e1098f7c0358fe8c7532
2018-08-30 20:28:18 +00:00
dan
f5778751f7 Fix a problem causing spurious SQLITE_CORRUPT errors when using the snapshot
API to read from old database snapshots.

FossilOrigin-Name: 535155be584ad8c1836e6b1c62de836d9872056d39608c995221c928cb5b365d
2018-08-28 11:23:52 +00:00
dan
588032fe33 Allow sqlite3_snapshot_open() to be called to change the snapshot after a read
transaction is already open on database.

FossilOrigin-Name: 41399169954f9bef53c3fa89879f39823b80bd127f76cf60abbe24217878a571
2018-08-15 14:03:26 +00:00
mistachkin
6389a7b0ac Minor style improvements.
FossilOrigin-Name: 60bbca2b9a591800cd8e7b374e62d75b1df0e8fd2d2f71f9b4d5fd044da78be0
2018-08-08 20:46:35 +00:00
dan
fa3d4c19a9 Allow sqlite3_snapshot_open() to be called to change the snapshot after a
read transaction is already open on database.

FossilOrigin-Name: 051ac0152048ef52723196c26ca5f2629dafb782aec1c66fc30531bf54335043
2018-08-06 17:12:36 +00:00
drh
4ece2f2657 Slightly smaller and faster code by encapsulating wal-index hash table
location information in a separate WalHashLoc object rather than passing
around the various elements as separate variables.

FossilOrigin-Name: 538a365b7a32ab7fa84f59d7556242cfb59b76d287b6417eb3a823197a354e8e
2018-06-09 16:49:00 +00:00
drh
49cc2f3b9c Fix walIteratorInit() so that it always leaves the iterator as a NULL pointer
if an OOM occurs.  This fixes an assertion fault introduced by 
check-in [044b0b65e716bff].

FossilOrigin-Name: e5ce256aa1f7a8ae995b79c9da895827bee5d8d0724fc15413ff203dc9e2602d
2018-03-05 23:23:28 +00:00
dan
f0cb61d6c2 In a checkpoint, figure out if it is possible to checkpoint any frames at all
before creating the wal-iterator.

FossilOrigin-Name: 044b0b65e716bffeddedbd1b0360c4c332f6d2359167c1d327a5ff96539474cb
2018-03-02 16:52:47 +00:00
dan
302ce47519 Optimize the obscure case of running a checkpoint against a very large wal
file for which a large percentage of the frames have already been checkpointed.

FossilOrigin-Name: 0f5057dffa9be1bccab04894709d25bf1f066c4b1aef50d67ee635d46d300a4d
2018-03-02 15:42:20 +00:00
drh
c0ec2f7762 Remove an unreachable branch in the walIndexPage() logic.
FossilOrigin-Name: 4e61a9731f5949dcf05c541106b56be16add04a7730613481fc8519d3e4f493b
2018-02-21 01:48:22 +00:00
drh
8d3e15eec4 Small performance improvement in sqltie3WalFindFrame().
FossilOrigin-Name: 52013cad0e6ce2d694f25e2984a76d438cef724f0e07c8bb9d3dce8a3caf4350
2018-02-21 01:05:37 +00:00
drh
2e178d7321 Make the walIndexPage() routine about 3x faster by factoring out the seldom
used reallocation logic into a separate subroutine.

FossilOrigin-Name: e2b107141cd97bd4ab240748a9ce43fc2ec950ea74610697a4a7a3d7a6441e6b
2018-02-20 22:20:57 +00:00
dan
05573e41a8 Lock the wal file for all snapshot transactions, even if they would not
otherwise require this, preventing checkpointers and writers from wrapping the
wal file. This means that if one connection has an open snapshot transaction
it is guaranteed that a second connection can open a transaction on the same
snapshot.

FossilOrigin-Name: b81a31495bd27c1d96f7df653da3502054240cb5acf66b860da7f0f9b422a524
2017-11-28 13:39:41 +00:00
drh
8b17ac1919 Improvement to a comment. No changes to code.
FossilOrigin-Name: 486949fc03706e0056439b52ce60931ea4ce0a65e391da7f6287fe13862de251
2017-11-14 03:42:52 +00:00
drh
2e9b0923ac Remove some branches in walTryBeginRead() that were
added by check-in [ce5d13c2de] but became unreachable with the addition
of logic in check-in [18b26843] that enabled read-only clients to parse
the WAL file into a heap-memory WAL-index, thus guaranteeing that the 
WAL-index header is always available.

FossilOrigin-Name: 9c6b38b9a96c11bdf9db4ea025720a4f49dcb723fa2e2776edc8453bce85c7e3
2017-11-13 05:51:37 +00:00
drh
c05a063c68 In wal.c: improved comments, new assert() and testcase() macros, and
replace some magic numbers with appropriate symbolic constants.

FossilOrigin-Name: 13ec8a77a47aa471af587459f4094da0d06674c5960f0d34777bcb3d38bc413b
2017-11-11 20:11:01 +00:00
drh
870655bb9e Further comment improvements in wal.c. No code changes.
FossilOrigin-Name: 346388007de585083dc67ad865b91db7c7d7b78c10a06f8bb7c48767c326c47e
2017-11-11 13:30:44 +00:00
drh
85bc6df2f1 Improved comments and variable names in the read-only WAL logic.
FossilOrigin-Name: d3c25740eec9a2a41c29e6e488fcf6587c1fb821147a442c29439b25a92154a5
2017-11-10 20:00:50 +00:00
drh
9214c1efe8 Extra comments on the sqlite3OsShmMap() call in walBeginUnlocked(). No
changes to code.

FossilOrigin-Name: 033ee92bf4d5dc57f5cb8fd02d1154ae06f2d3261d214e7191a82c70c8ffebf7
2017-11-08 19:26:27 +00:00
drh
7e45e3a5d7 Change the name of SQLITE_READONLY_CANTLOCK to SQLITE_READONLY_CANTINIT.
FossilOrigin-Name: 6d7f94faa7e6de62f82bc6cac019508a9c1ffd6fa1d14f52fa93e9c06afdd32f
2017-11-08 17:32:12 +00:00
dan
6c9d8f640b Update an assert in wal.c.
FossilOrigin-Name: 94527b897bac66d100ca92161f18b6f0e0768dd77ebcb06e3fb106f0e0e380ee
2017-11-07 21:25:15 +00:00
dan
08ecefc5b1 Handle the race condition that may occur if another process connects and then
checkpoints and truncates the wal file while a readonly-shm client is building
its heap-memory wal-index.

FossilOrigin-Name: 5a6703fc3f2174b3e9a624c7272ae013b73c42d6c97ffa62b58553efdb54e3bc
2017-11-07 21:15:07 +00:00
dan
ab54838452 Add further test cases for the new code on this branch. And a couple of fixes.
FossilOrigin-Name: 71af9acb227a91d9ad8798c9d0b12d6967e863d050f5cb1fddb45f25ee1f47db
2017-11-06 19:49:34 +00:00
dan
cbd3321978 Add further tests for the code added on this branch.
FossilOrigin-Name: a6716fcde38b28b8a03b40f9d16f78a57ec20f60cf391ff553692641cb7f0d3f
2017-11-04 21:06:35 +00:00
dan
11caf4f4b7 In cases where a readonly_shm client cannot take the DMS lock on the *-shm
file, have it parse the wal file and create a wal-index to access it in heap
memory.

FossilOrigin-Name: 18b268433d739486eac1b04947bd418655e4bc56e8dc63ffa558aa4552a32e30
2017-11-04 18:10:03 +00:00
dan
dea5ce36f5 Avoid locking shm-lock WAL_READ_LOCK(0) during recovery. Doing this allows
recovery to proceed while a readonly_shm connection in unlocked mode has an
ongoing read transaction.

FossilOrigin-Name: 5190d84a296b7cf716ef43bf7b6d4d351ef1a4d650de37dc01a5ab333da7c05d
2017-11-02 11:12:03 +00:00
dan
92c02da33e If a readonly_shm connection cannot map the *-shm file because no other
process is holding the DMS lock, have it read from the database file only,
ignoring any content in the wal file.

FossilOrigin-Name: ce5d13c2de69b73378637d4f7e109714f7cd17bf1d1ad995e0be442d517ed1b3
2017-11-01 20:59:28 +00:00
drh
183f0aa6c4 Fix a minor comment typo. No changes to code.
FossilOrigin-Name: 5f79e6d9c3d44b0cc7cf805429006f7b29a69e8d863b58472172a56b29a7bb4e
2017-10-31 12:06:29 +00:00
drh
07dae088b9 Clarify some comments describing the WAL index file. No changes to code.
FossilOrigin-Name: 3be3aad9ecbe33060cfa9c6059b9206ed221d1fd72a69c355a9387f9f4e075e7
2017-10-30 20:44:36 +00:00
dan
21f2bafd9b Experimental change so that snapshot transactions always lock the wal file -
preventing writers or truncate-checkpointers from wrapping it.

FossilOrigin-Name: d71eeaab9ecdeed772047498b781be1f0be0655af284b94cf676bb408ceea8b1
2017-09-23 07:46:54 +00:00
drh
daaae7b9d1 Update the mechanism used to keep track of what kind of syncing to do for
WAL transaction commits and checkpoint operations.  Use the checkpoint-style
of syncing to sync the header of a new or restarted WAL file.

FossilOrigin-Name: bf65dae8d4297c57ac63228ccf0100f9fabf2fb600438c9f2e10a29c4b118168
2017-08-25 01:14:43 +00:00
drh
9c6e07d2fa Fix an incorrect hyperlink in a comment.
FossilOrigin-Name: 25292b9a4eb5efc7db551da0b3c9cfd7e79da1594ee14729de44090e188c2b2a
2017-08-24 20:54:42 +00:00
drh
bc88711d08 Enclose the sqlite3WalSnapshotRecover() routine within
FossilOrigin-Name: e7be3183eb25e0f9f04b9e251ff37fa5e50cc1a7
2016-11-22 21:11:59 +00:00
dan
93f5113290 Remove the requirement to open the wal file before sqlite3_snapshot_recover()
is called. Also add some comments to new functions.

FossilOrigin-Name: 28393c413cc4505b94411730e728583c5d4baaae
2016-11-19 18:31:37 +00:00
dan
6a9e7f16eb Fix a problem causing sqlite3_snapshot_recover() to return
SQLITE_IOERR_SHORT_READ.

FossilOrigin-Name: 525f75fa9fd4a95acc3fb3b0a01dabe2be39b383
2016-11-19 16:35:53 +00:00
dan
5b4009f637 Fix a bug in sqlite3_snapshot_recover() that could cause subsequent read
transactions to use out-of-data cache entries.

FossilOrigin-Name: 9abeb7980a34cec11a3420e14ad98a4ec0d9c599
2016-11-19 14:53:22 +00:00
dan
1158498dce Add experimental sqlite3_snapshot_recover() API.
FossilOrigin-Name: 174a6076a8d7bebe5efebf55f3fdc5d87c589cc7
2016-11-18 20:49:43 +00:00
drh
ba6eb8769f Experimental changes toward making snapshots serializable.
FossilOrigin-Name: b6a81fa1fc1fb78a65894129851a4ec3986640de
2016-11-15 17:37:56 +00:00
dan
4a5bad572a Fix a problem with switching from wal to rollback mode when
SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE is configured.

FossilOrigin-Name: 46e0016207b8e7df2ae6c7491fd0f3c2926eed21
2016-11-11 17:08:51 +00:00
dan
298af02308 Add the SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE sqlite3_dbconfig() option - for
disabling SQLite's default checkpoint-on-close behaviour.

FossilOrigin-Name: 093d2fc2288b75c15ccf877bfa0e622d3918a562
2016-10-31 16:16:49 +00:00
dan
7fb8990688 Have wal file checkpoints exit early if the sqlite3_interrupt() API function is called.
FossilOrigin-Name: 8a5f41c7b1718507524adef1a2730e99cf53270a
2016-08-12 16:21:15 +00:00
dan
fe912510ea Fix an obscure problem with transactions written in "PRAGMA synchronous=full" mode on systems that do not support POWERSAFE_OVERWRITE causing an xSync() call to be omitted if the last frame written by a transaction is aligned to a sector boundary. This means that if a power failure or OS crash occurs very soon after such a transaction is committed, it may be lost following system recovery.
FossilOrigin-Name: 37de3eab67f12ae1ce5bc8d5e541c64fc6b1fd80
2016-05-24 16:20:51 +00:00
dan
ad2d5baf1f Add the sqlite3_snapshot_cmp() API.
FossilOrigin-Name: c698a21af740ca1019c3a771fb83e569cd6bf23e
2016-04-11 19:59:52 +00:00
drh
32c49904a6 Add the SQLITE_NOMEM_BKPT macro to enhance the ability to debug OOM errors.
Only effective with compiling with SQLITE_DEBUG.

FossilOrigin-Name: 9b3454762d142113f5923d754ca6bd2edefbd362
2016-02-15 18:15:15 +00:00
drh
8e0cea1a5d Make sure the codec is invoked when overwriting existing frames of the
WAL file.  Yikes!

FossilOrigin-Name: f694e60a79024967a3f4574e3928f0b28589d381
2016-02-15 15:06:47 +00:00
mistachkin
fad3039c51 Enhance ability to debug out-of-memory errors.
FossilOrigin-Name: 6a9c4a3ebfb7cc0738ef6634440ccab44a21ff28
2016-02-13 23:43:46 +00:00
drh
31a2313fa8 Add the SQLITE_FCNTL_JOURNAL_POINTER file control.
FossilOrigin-Name: ad3daa5427672d2d236939ad3285b765f4601801
2016-01-13 18:12:44 +00:00
drh
869aaf0941 Make sure all bytes of the WAL file are initialized even if the checksums are
not being computed until commit due to WAL overwrite.

FossilOrigin-Name: 1f44a9bdc1577aed088d9b91882527228015dcd3
2016-01-12 02:28:19 +00:00