Commit Graph

196 Commits

Author SHA1 Message Date
Pekka Enberg
c3fb867173 core: Switch RwLock<Arc<Pager>> to ArcSwap<Pager>
We don't actually need the RwLock locking capabilities, just the ability
to swap the instance.
2025-10-24 14:10:08 +03:00
PThorpe92
a8b257c664 Replace several RwLock<Enum> values with new AtomicEnums 2025-10-22 09:35:26 -04:00
Pere Diaz Bou
ea04e9033a core/mvcc: add btree_cursor under MVCC cursor 2025-10-21 18:22:37 +02:00
Pere Diaz Bou
57eb63cee0 core/bree: remove duplicated code in BTreeCursor 2025-10-16 14:50:08 +02:00
Pere Diaz Bou
bc05497d99 core/mvcc: implement CursorTrait on MVCC cursor 2025-10-13 19:26:18 +02:00
Pekka Enberg
4af61d8049 Merge 'core/btree: try to introduce trait for cursors' from Pere Diaz Bou
I've added a trait called `CursorTrait`. I know it's not a good name for
now, but I didn't know what tto change then enum `Cursor` to. This trait
wraps all common functionality, and some functionality that is yet too
specific that needs to be fixed.
This is needed in order to have layered cursors where for example,
MvccCursor will need a fallback BTreeCursor.

Closes #3660
2025-10-10 19:25:39 +03:00
Pere Diaz Bou
160a84250e core: add CursorTrait imports where needed 2025-10-10 15:04:15 +02:00
Pere Diaz Bou
f06ee571be Merge 'MVCC: Don't modify the row version chain on rollback' from Duy Dang
Rollback shouldn't modify the row version chain. This is crucial for
implementing a Non-blocking row version chain in #3499

Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com>

Closes #3583
2025-10-08 18:00:02 +02:00
Duy Dang
4fe3282d8e Fix missing let from merge 2025-10-08 21:06:13 +07:00
Duy Dang
f7b3033a09 Merge branch 'main' into rollback-fix 2025-10-08 20:56:54 +07:00
Pekka Enberg
94c343770d mvcc: Disable automatic checkpointing by default
MVCC checkpointing currently prevents concurrent writes so disable it by
default while we work on it.
2025-10-08 09:14:55 +03:00
Levy A.
cf53ecb7e3 refactor: remove TextRef and RawSlice and fix tests 2025-10-07 10:43:45 -03:00
Levy A.
77a412f6af refactor: remove unsafe reference semantics from RefValue
also renames `RefValue` to `ValueRef`, to align with rusqlite and other
crates
2025-10-07 10:43:44 -03:00
Duy Dang
1c4a54a73c Add comment explaining the 0 for infinity timestamp 2025-10-07 19:46:26 +07:00
Pekka Enberg
b98c4ece0d Merge 'core/mvcc/logical-log: switch RwLock to parking_lot' from Pere Diaz Bou
Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com>

Closes #3615
2025-10-07 13:43:39 +03:00
Pere Diaz Bou
3e508a4b42 core/io: remove new_dummy in place of new_yield
Yield is a completion that does not allocate any inner state. By design
it is completed from the start and has no errors. This allows lightly
yield without allocating any locks nor heap allocate inner state.
2025-10-07 12:00:33 +02:00
Pere Diaz Bou
44152f11d0 core/mvcc/logical-log: switch RwLock to parking_lot 2025-10-07 11:15:48 +02:00
Pekka Enberg
a72b07e949 Merge 'Fix VDBE program abort' from Nikita Sivukhin
This PR add proper program abort in case of unfinished statement reset
and interruption.
Also, this PR makes rollback methods non-failing because otherwise of
their callers usually unclear (if rollback failed - what is the state of
statement/connection/transaction?)

Reviewed-by: Preston Thorpe <preston@turso.tech>

Closes #3591
2025-10-07 09:07:07 +03:00
bit-aloo
66c69461fb Add getter/setter for checkpoint threshold in LogicalLog
Wire threshold access through Storage

Add checkpoint threshold accessors to MvStore
2025-10-07 10:17:04 +05:30
Duy Dang
26a3e069fb Fix missing row versions to checkpoint 2025-10-07 01:11:46 +07:00
Pekka Enberg
f8bdc02986 Merge 'Rename Completion methods' from Pedro Muniz
Reviewed-by: bit-aloo (@Shourya742)
Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com>

Closes #3579
2025-10-06 20:12:21 +03:00
Pere Diaz Bou
59c08c1062 Merge 'core/mvcc: implement PartialOrd for RowId' from Pere Diaz Bou
Closes #3597
2025-10-06 16:42:04 +02:00
pedrocarlo
5a7390735d rename Completion functions 2025-10-06 11:07:06 -03:00
Nikita Sivukhin
e2f7310617 add explicit tracker for Txn cleanup necessary for statement 2025-10-06 17:51:43 +04:00
Pekka Enberg
41d909e1fb Merge 'MVCC: do checkpoint writes in ascending order of rowid' from Jussi Saurio
For insert-heavy checkpoints this gives a much higher chance of using
the balance-quick subalgorithm instead of the more complex and slower
balance-nonroot.

Closes #3589
2025-10-06 16:30:19 +03:00
Pere Diaz Bou
aed255d2e6 core/mvcc: implement PartialOrd for RowId 2025-10-06 13:43:42 +02:00
Pere Diaz Bou
fc7e1639a0 core/mvcc: filter out seek results where is not same table_id 2025-10-06 13:29:10 +02:00
Pere Diaz Bou
b9b9831d17 core/mvcc: test seek with empty table 2025-10-06 13:28:51 +02:00
Nikita Sivukhin
8dae601fac make rollback non-failing method 2025-10-06 13:21:45 +04:00
Nikita Sivukhin
38d2630969 remove unnecessary SchemaLocked error
- lock() return error in case when another thread panicked while holding the same lock
- we better to just panic too in any such case
2025-10-06 12:15:15 +04:00
Jussi Saurio
fd9008f123 MVCC: do checkpoint writes in ascending order of rowid
For insert-heavy checkpoints this gives a much higher chance of using
the balance-quick subalgorithm instead of the more complex and slower
balance-nonroot.
2025-10-06 10:11:19 +03:00
Duy Dang
c57567d776 Adopt Hekaton solution for rollback tx 2025-10-05 23:51:50 +07:00
Pere Diaz Bou
e3f2bbf90b core/mvcc: remove unnecessary fields in CommitState::Checkpoint 2025-10-03 22:27:03 +02:00
Pere Diaz Bou
c612a51df7 fmt 2025-10-03 22:24:38 +02:00
Pere Diaz Bou
8e80af7221 core/mvcc: checkpoint if needed after commit 2025-10-03 22:24:38 +02:00
Pere Diaz Bou
55f5cd2ad7 core/mvcc/logical-log: test automatic checkpoint 2025-10-03 17:23:59 +02:00
Pere Diaz Bou
7db5a09005 core/mvcc/logical-log: checkpoint support not updating transaction_state if needed 2025-10-03 17:23:35 +02:00
Pekka Enberg
297aaf4887 core/mvcc: Rename "-lg" to "-log"
The "lg" name is just weird.
2025-10-03 10:08:02 +03:00
pedrocarlo
131a5b8048 adjust logical log IO functions to return Completions and not IOResult 2025-10-03 01:44:41 -03:00
Jussi Saurio
e9f0c59bcc fix/mvcc: set log offset to end of file after recovery finishes
otherwise we start overwriting existing log entries
2025-10-01 12:46:24 +03:00
Jussi Saurio
d4d50b564a fix even more tests 2025-09-30 23:22:07 +03:00
Jussi Saurio
adc5b7b27f remove monkey print 2025-09-30 22:57:21 +03:00
Jussi Saurio
fe871188bf fix tests again 2025-09-30 22:54:48 +03:00
Jussi Saurio
fb2878973f fix sort order of write set 2025-09-30 22:54:36 +03:00
Jussi Saurio
fd84fd0683 fix test compilation errors 2025-09-30 22:27:28 +03:00
Jussi Saurio
e68c652f8f Add some table ID integrity checks to logical log recovery 2025-09-30 22:27:28 +03:00
Jussi Saurio
64ce33bd5c Move resolution of tableid/rootpage inside MvCursor constructor 2025-09-30 17:04:37 +03:00
Jussi Saurio
7c897d382f Implement MvTableId newtype for better type safety of table ids 2025-09-30 16:54:22 +03:00
Jussi Saurio
0ba4c6c00e use negative table id in mvcc tests 2025-09-30 16:53:12 +03:00
Jussi Saurio
a52dbb7842 Handle table ID / rootpages properly for both checkpointed and non-checkpointed tables
Table ID is an opaque identifier that is only meaningful to the MV store.
Each checkpointed MVCC table corresponds to a single B-tree on the pager,
which naturally has a root page.

We cannot use root page as the MVCC table ID directly because:
- We assign table IDs during MVCC commit, but
- we commit pages to the pager only during checkpoint
which means the root page is not easily knowable ahead of time.

Hence, we:

- store the mapping between table id and btree rootpage
- sqlite_schema rows will have a negative rootpage column if the
  table has not been checkpointed yet.
2025-09-30 16:53:12 +03:00