Commit Graph

369 Commits

Author SHA1 Message Date
Pere Diaz Bou
0f70e7101f core/state_machine: move state_machine to its own file 2025-08-01 12:49:32 +02:00
Pere Diaz Bou
27757ab4eb core/mvcc commit_txn generic state machinery
Unfortunately it seems we are never reaching the point to remove state
machines, so might as well make it easier to make.

There are two points that must be highlighted:
1. There is a `StateTransition` trait implemented like:

```rust
pub trait StateTransition {
    type State;
    type Context;

    fn transition<'a>(&mut self, context: &Self::Context) ->
Result<TransitionResult>;
    fn finalize<'a>(&mut self, context: &Self::Context) -> Result<()>;
    fn is_finalized(&self) -> bool;
}
```

where there exists `transition` which tries to move state forward, and
`finalize` which marks the state machine as "finalized" so that **no
other call to finalize will forward the state and it will panic instead.

2. Before, we would store the state of a state machine inside the
callee's struct, but I'm proposing we do something different where the
callee will return the state machine and the caller will be responsible
of advancing it. This way we don't need to track many reset operations
in case of failures or rollbacks, and instead we could simply drop a
state machine and all other nested state machines will drop in a
cascade.
2025-08-01 12:36:02 +02:00
Pere Diaz Bou
d616a375ee core/mvcc: commit_tx state machine 2025-08-01 12:36:02 +02:00
Pere Diaz Bou
0cefb01395 mvcc_benchmark: clippy 2025-08-01 11:01:29 +02:00
Pere Diaz Bou
c807b035c5 core/mvcc: fix tests again
had to create connections for every different txn
2025-08-01 10:44:19 +02:00
Pere Diaz Bou
5ad7d10790 core/mvcc: fix use of rwlock 2025-08-01 10:38:41 +02:00
Pere Diaz Bou
b518e1f839 core/mvcc: add missing arc import 2025-08-01 10:38:41 +02:00
Pere Diaz Bou
c4318cac36 core/mvcc: fix tests 2025-08-01 10:38:41 +02:00
Pere Diaz Bou
49a00ff338 core/mvcc: load table's rowid on initialization
We need to load rowids into mvcc's store in order before doing any read
in case there are rows.

This has a performance penalty for now as expected because we should,
ideally, scan for row ids lazily instead.
2025-08-01 10:38:41 +02:00
Pere Diaz Bou
b399ddea1b core/mvcc: begin pager read txn on mvcc begin_txn 2025-08-01 10:38:41 +02:00
Pere Diaz Bou
b4ac38cd25 core/mvcc: persist writes on mvcc commit
On Mvcc `commit_txn` we need to persist changes to database, for this case we re-use pager's semantics of transactions:
1. If there are no conflicts, we start `pager.begin_write_txn`
2. `pager.end_txn`: We flush changes to WAL
3. We finish Mvcc transaction by marking rows with new timestamp.
2025-08-01 10:38:41 +02:00
Pekka Enberg
b7cb4a3ed4 core/mvcc: Switch to parking_lot RwLock 2025-07-30 20:25:45 +03:00
Pere Diaz Bou
caa5fe3ef4 core/mvcc: simplify mvcc cursor types
We have so many cursor types that it will be unbearable to properly make
all of them work. Let's simplify this and only focus on lazy cursor
which in the future will load from database in case we need it.
2025-07-29 20:13:52 +02:00
Pekka Enberg
ddc0144dcf core/mvcc: Adjust cursor tests 2025-07-17 21:43:07 +03:00
Pekka Enberg
962987e9a1 core/mvcc: Fix MVCC cursor traversal
Add an explicit rewind() to move to the beginning. Change forward()
semantics so that *after* first forward() call, you are pointing to the
first row, which matches the get_next_record() semantics in B-tree
cursor.
2025-07-17 16:12:40 +03:00
Pekka Enberg
2b1ee907a9 core/vdbe: Fix op_new_rowid() with MVCC 2025-07-17 14:13:22 +03:00
Nils Koch
828d4f5016 fix clippy errors for rust 1.88.0 (auto fix) 2025-07-12 18:58:41 +03:00
Nils Koch
2827b86917 chore: fix clippy warnings 2025-06-23 19:52:13 +01:00
Pere Diaz Bou
da4190a23e Convert u64 rowid to i64
Rowids can be negative, therefore let's swap to i64
2025-05-30 13:07:31 +02:00
Ihor Andrianov
7c1d827d33 clippy 2025-03-25 17:13:31 +02:00
Ihor Andrianov
8bfacf3955 add lazy and bucket cursor 2025-03-25 16:55:29 +02:00
Pekka Enberg
ef180fa1cb core/mvcc: Improve tracing format
Suggested by Pere
2025-03-06 12:58:41 +02:00
Pekka Enberg
461be0dc87 core: Add multi-version store to Database 2025-03-06 10:16:42 +02:00
Pekka Enberg
5d0982f5db core/mvcc: Add RowID::new() and Row::new() helpers 2025-03-06 09:59:40 +02:00
Pekka Enberg
4247974f95 core/mvcc: Add insert() helper to Cursor 2025-03-06 09:32:48 +02:00
Pekka Enberg
b7382ffab1 core/mvcc: Switch Cursor to use Rc instead of lifetimes 2025-03-06 09:31:34 +02:00
Pekka Enberg
ff6d9465eb core/mvcc: Improve trace logging 2025-03-06 09:31:04 +02:00
Pekka Enberg
81b79bc833 core/mvcc: Eliminate row generic types
The logging code that writes out transactions to disk needs to write out
the byte array that we actually use. The code is less hairly without the
generics so drop them.
2025-03-05 19:17:16 +02:00
Jussi Saurio
aea8b416bc Merge 'mvcc: comments and small cleanup' from Jussi Saurio
Closes #930
2025-02-15 18:18:01 +02:00
Doug Anderson444
39c3b135e3 make all serde optional
to reduce dep size
2025-02-11 09:05:34 -04:00
Jussi Saurio
3826c540ae thank you clippy, actually a nice suggestion 2025-02-08 14:47:41 +02:00
Jussi Saurio
c23d97f33c refactor: is_version_visible() -> RowVersion::is_visible_to() 2025-02-08 14:33:06 +02:00
Jussi Saurio
a0460ae2d5 Comment about tx visibility when deleting a row 2025-02-08 14:31:27 +02:00
Jussi Saurio
40f59f124f Fix comment: new -> old 2025-02-08 11:12:16 +02:00
Pekka Enberg
b17610ab77 core/mvcc: Minor code cleanups
Make the source file readable from top to bottom by moving private
functions at the end of the struct implementation.
2025-02-08 10:55:13 +02:00
Jussi Saurio
791255fd8c MVCC: Add a few comments 2025-02-08 10:20:48 +02:00
Jussi Saurio
fab105c10c MVCC: fix write conflict handling 2025-02-08 10:10:09 +02:00
Pekka Enberg
7809df913a core/mvcc: Rename Database to MvStore 2025-02-07 07:40:33 +02:00
Pekka Enberg
f772fc83e1 core/mvcc: Disable test_overlapping_concurrent_inserts_read_your_writes test
...it fails sporadically
2025-02-05 14:18:56 +02:00
Pekka Enberg
acb98f56d5 core/mvcc: Thanks Clippy... 2025-02-05 13:44:55 +02:00
Pekka Enberg
36b487d281 core/mvcc: Make Clippy happy 2025-02-05 13:41:20 +02:00
Pekka Enberg
fad479ac59 core/mvcc: Move source code to module 2025-02-05 13:25:16 +02:00
Pekka Enberg
a585b81148 mvcc/core: Kill S3 persistent storage 2025-02-05 12:51:58 +02:00
Pekka Enberg
e923a2352e core/mvcc: Kill mvcc-rs crate
We'll just integrate everything in the core.
2025-02-05 12:50:46 +02:00
Pekka Enberg
9f0b33a8ef core/mvcc: Remove README.md 2025-02-05 12:50:46 +02:00
Pekka Enberg
5c9bb4bddd core/mvcc: Remove duplicate Cargo workspace config 2025-02-05 12:42:39 +02:00
Pekka Enberg
5e282c00bc Remove duplicate MIT license 2025-02-05 12:42:15 +02:00
Pekka Enberg
7d99894269 Move MVCC docs to top-level docs directory 2025-02-05 12:41:55 +02:00
Pekka Enberg
df20213a4b core/mvcc: Remove C bindings
We won't need them because we just use the Rust APIs in the core.
2025-02-05 12:40:28 +02:00
Pekka Enberg
fcb4c7e46a core/mvcc: Remove Git metadata files 2025-02-05 12:40:06 +02:00