Commit Graph

10673 Commits

Author SHA1 Message Date
Pekka Enberg
ae709f04fe Make some opcodes wait for completion 2023-09-02 13:26:44 +03:00
Pekka Enberg
60376ed3dd Fix EXPLAIN when querying 2023-09-02 11:42:17 +03:00
Pekka Enberg
3ec9c0be7c Implement ResultRow opcode 2023-09-02 11:40:11 +03:00
Pekka Enberg
6e748a066e Register allocation 2023-09-02 08:52:30 +03:00
Pekka Enberg
fa51955b43 VDBE improvements 2023-09-02 08:46:01 +03:00
Pekka Enberg
4c64590a5c Decouple Program and ProgramState 2023-09-02 08:18:05 +03:00
Pekka Enberg
14fb12ecdf Translate SQL SELECT column values 2023-09-01 21:26:12 +03:00
Pekka Enberg
f954729fd9 Tune prompt some more 2023-09-01 21:02:52 +03:00
Pekka Enberg
ab96f27c56 Change prompt 2023-09-01 19:50:29 +03:00
Pekka Enberg
591e8df377 Disable tracing by default 2023-09-01 19:49:54 +03:00
Pekka Enberg
4b714311b5 Improve Column instruction 2023-08-31 22:05:05 +03:00
Pekka Enberg
b25f8c4daf Implement Cursor::next() 2023-08-31 21:45:04 +03:00
Pekka Enberg
05621e3286 Cursors 2023-08-30 20:26:15 +03:00
Pekka Enberg
b572d60dc5 B-Tree interface 2023-08-29 20:33:16 +03:00
Pekka Enberg
7c100ea217 Query sqlite_schema table 2023-08-29 19:46:07 +03:00
Pekka Enberg
61b1071d8d Update README.md 2023-08-27 21:22:21 +03:00
Pekka Enberg
b40438f778 Make EXPLAIN output more similar to SQLite 2023-08-27 21:21:42 +03:00
Pekka Enberg
9d7286bde0 Remove unused import 2023-08-27 21:19:43 +03:00
Pekka Enberg
6f1d03d64d Look up columns from table schema 2023-08-27 21:18:17 +03:00
Pekka Enberg
3b53f48400 Look up table root page from schema 2023-08-27 21:11:49 +03:00
Pekka Enberg
2615cdce2c Schema in-memory data structures 2023-08-27 20:40:35 +03:00
Pekka Enberg
6a2d36f4c1 Buffer pool 2023-08-27 12:17:20 +03:00
Pekka Enberg
fb72f9688b Initial commit 2023-08-27 09:59:12 +03: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
0a251b3b76 Merge pull request #61 from penberg/fix59
database: fix an unwrap() in tx_commit
2023-07-09 17:42:08 +02: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
31ee26d037 Merge pull request #58 from penberg/rename-project
Rename project to Tihku
2023-06-18 11:45:24 +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
Pekka Enberg
a8af11a553 Merge pull request #55 from penberg/upsert_tests
database: change insert to upsert in concurrency tests
2023-06-13 16:55:44 +03: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
Pekka Enberg
46e3f7e3c4 Merge pull request #54 from penberg/concurrency_no_shuttle
concurrency test: port to OS threads
2023-06-13 14:49:48 +03: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
3841adf482 Merge pull request #53 from penberg/atomicstate
database: make transaction state atomic
2023-06-12 14:00:44 +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
Pekka Enberg
3d804ece2a Merge pull request #52 from penberg/lockfree
database: drop the mutex
2023-06-12 13:09:12 +03: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
Piotr Sarna
ddbcd9be79 database: bring back dropping unused row versions 2023-06-06 12:47:40 +02:00
Piotr Sarna
625394000e unignore test_dirty_read_deleted 2023-06-06 11:34:34 +02:00
Piotr Sarna
47eb149214 database: drop the mutex
Without a critical section, we naturally hit a few unimplemented
paths when handling concurrent transactions, which is great news!
Visiting previously impossible paths already proves that lock-free
is able to handle concurrency > 1.
Now, the easy part - fixing all the unimplemented paths and making
the Hekaton implementation 100% foolproof.
2023-06-06 11:28:27 +02:00