Commit graph

151 commits

Author SHA1 Message Date
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
Piotr Sarna
1392734609 Merge pull request #62 from tpisto/main
Row<T>
2023-07-12 10:11:08 +02:00
Tommi Pisto
5d240e731f Fixed bench build 2023-07-11 18:03:05 +03:00
Piotr Sarna
6d2a4150aa database: fix an unwrap() in tx_commit
It was a legit error -> the transaction doesn't have to be active
when commit() is called on it, and the right behavior in that case
is to return a TxTerminated error.

Fixes https://github.com/penberg/tihku/issues/59
2023-07-09 11:15:48 +02:00
Tommi Pisto
b42cbe52d0 Added 'static bounds to T 2023-07-08 12:28:27 +03:00
Tommi Pisto
ce6a6ceba2 Row<T> 2023-07-07 18:14:31 +03:00
Pekka Enberg
4888a0639c Mention libsql with MVCC 2023-06-19 11:15:20 +03:00
Pekka Enberg
9bb09d005f Rename project to Tihku
The "mvcc-rs" name is not great for a lot of reasons. Let's rename the project to (Iku-)Tihku to give t a proper name
2023-06-18 11:17:01 +03:00
Piotr Sarna
6daaa79f63 database: actually implement upserts
Fixes #55 - it was the code that should have been there
in the first place, but I forgot to `git add`...
2023-06-13 19:33:22 +02:00
Piotr Sarna
0338e14814 database: change insert to upsert in concurrency tests
Using insert() was a violation of our API, kind of, because
inserts are not expected to be called twice on the same id.
Instead, update or upsert should delete the version first,
and that's what's done in this patch.

At the same time, write-write conflict detection needed to be
implemented, because we started hitting it with rollback().

Finally, garbage collection is modified to actually work
and garbage-collect row versions. Without it, the number of tracked
row versions very quickly goes out of hand.
2023-06-13 15:52:28 +02:00
Piotr Sarna
36d989babb database: properly compare row versions
Previous commit was incorrect in two manners:
 1. It *only* worked if the version was either pushed as the most
    recent or 1 behind the most recent - that's fixed.
 2. Comparing row versions incorrectly compared either timestamps
    or transaction ids, while we *need* to only compare timestamps.
    That's done by looking up the transaction and extracting its
    timestamp - potentially expensive, and maybe we need to rework
    the algorithm and/or consult the Hekaton paper.
2023-06-13 12:51:46 +02:00
Piotr Sarna
1a50e12102 tests: make concurrency test run 4 threads 2023-06-13 11:33:23 +02:00
Piotr Sarna
7a6ca27986 database: make sure row versions are inserted in a sorted order
For the time being, we still assume that the row versions vector
is *nearly* sorted, so we just perform a linear reverse search
and insert the version at an appropriate place.

During concurrency tests, the error was at most 1 offset,
and as long as we empirically prove it to be below a reasonable
constant, we're fine. Otherwise we should consider switching
to either a data structure that keeps elements ordered,
or at least a list that gives us constant insertion.
2023-06-13 11:24:19 +02:00
Piotr Sarna
95ed29e6cb database: fix the locking order in transactions
Before this commit, deadlocks were possible (and detected),
because some functions took row_versions lock first, and then
individual transaction locks, while other functions took the locks
in opposite order.
2023-06-12 16:22:45 +02:00
Piotr Sarna
57249f2c94 concurrency test: port to OS threads
Without mutexes, it makes no sense anymore to use shuttle.
Instead, the test cases just spawn OS threads.
Also, a case with overlapping ids is added, to test whether
transactions read their own writes within the same transaction.
2023-06-12 14:27:40 +02:00
Piotr Sarna
a93fcdcbcf database: make transaction state atomic
Without atomic access, we're subject to races when inspecting
whether a transaction just changed its state, e.g. from Preparing
to Committed.
2023-06-12 13:14:46 +02:00
Piotr Sarna
983544dbfd database: implement missing cases for is_version_visible + tests
Following the Hekaton paper tables, but also taking into account
that in iteration 0 we're only interested in snapshot isolation,
not serializability.
2023-06-07 13:58:34 +02:00
Piotr Sarna
b4932340f4 database: add a juicy comment about serializability
And specifically, the amount of things we don't have implemented
to even think of that. It's mostly about tracking commit dependencies
which allow speculative reads/ignores of certain versions,
as well as making sure that in the commit phase, we validate
visibility of all versions read, as well as that our scans
took into account all data. If some version appeared after the transaction
began, and it was not taken into account during its scans, it is considered
a "phantom", and it invalidates the transaction if we strive for
serializability.
2023-06-07 11:20:00 +02:00
Piotr Sarna
6d82973359 database: restore a CRUCIAL comment about dropping a tx
... which stops being correct after lock-free!
2023-06-06 16:04:28 +02:00