Commit Graph

276 Commits

Author SHA1 Message Date
pedrocarlo
a1c5a6efae begin_sync should return a Completion 2025-07-29 13:40:58 -03:00
pedrocarlo
58b51e036d read_page should return a Completion 2025-07-29 12:42:36 -03:00
pedrocarlo
6edf65f752 append_frame should return a Completion 2025-07-29 11:49:10 -03:00
pedrocarlo
5861145fb4 read_frame should return a Completion 2025-07-29 11:40:53 -03:00
Pekka Enberg
8adc807cd7 Merge 'Change function signatures to return IO Completions' from Pedro Muniz
Changes a couple of function signatures to return `Completion`. Also, I
changed `Completion` to be internally `Arc` to abstract the `Arc`
implementation detail, and to be able to attach a `#[must_use]` to the
`Completion` struct, so that cargo check can show us where we are not
tracking completions in the code. I also attached a `#[must_use]` to
`IOResult` so that we can see the places that we are not propagating or
waiting for I/O, demonstrating locations where functions should be
reentrant and are not.
Also, while we are with this refactor in progress I want to relax the
Clippy CI lint on unused_variables.

Closes #2309
2025-07-29 12:41:14 +03:00
pedrocarlo
d30c7d54c8 change all Arc<Completion> to Completion 2025-07-28 15:32:45 -03:00
pedrocarlo
617254116d begin_read_page should return completions 2025-07-28 15:31:42 -03:00
pedrocarlo
28d6245440 begin_write_btree_page should return completion 2025-07-28 15:31:42 -03:00
Diego Reis
0346c65a72 Fix clippy 2025-07-28 14:48:52 -03:00
Nikita Sivukhin
09b18f6b6e add WAL API methods to the rust bindings and extend result of wal_insert_frame method 2025-07-28 17:20:10 +04:00
Jussi Saurio
36e0ca5a9f pager: remove unnecessary LoadFreelistTrunkPage state 2025-07-28 10:11:57 +03:00
Jussi Saurio
e7b07c1357 pager: reset allocate_page_state in reset_internal_states() 2025-07-28 10:11:57 +03:00
Jussi Saurio
927aca7857 Fix incorrect autovacuum test 2025-07-28 09:00:59 +03:00
Jussi Saurio
e2e25a48f6 Pager: document origins of BtreePageAllocMode 2025-07-28 09:00:59 +03:00
Jussi Saurio
5ce65bf8e7 btree/pager: reuse freelist pages in allocate_page() to fix UPDATE perf 2025-07-28 09:00:59 +03:00
meteorgan
c48a5ef538 we don't need read_tx return IOResult anymore 2025-07-24 23:19:33 +08:00
meteorgan
7ef50e0690 fix page_count pragma 2025-07-24 23:18:26 +08:00
Pere Diaz Bou
46f5609fce Merge 'Append WAL frames one by one' from Pere Diaz Bou
Let's make sure we don't end up in a weird situation by appending frames
one by one and we can later think of optimizations.

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

Closes #2034
2025-07-24 16:44:51 +02:00
Pere Diaz Bou
b07e57d9d1 review fixes 2025-07-24 15:29:21 +02:00
Pere Diaz Bou
674d88e140 do not clear dirty pages on cacheflush::start 2025-07-24 15:29:21 +02:00
Pere Diaz Bou
d77c899fa6 clippy 2025-07-24 15:29:21 +02:00
Pere Diaz Bou
5a1773edf1 clippy 2025-07-24 15:29:21 +02:00
Pere Diaz Bou
14de7c55af set connection state to None in vdbe rollback 2025-07-24 15:29:21 +02:00
Pere Diaz Bou
5f8e386b48 reset internal states on rollback 2025-07-24 15:29:06 +02:00
Jussi Saurio
37955e9a04 Pager/WAL: fix not clearing stale page cache
SQLite behavior is: if another connection has modified the DB when a
read tx starts, it must clear its page cache due to the potentiality
of there being stale versions of pages in it.

In the future, we may want to do either:
1. a more granular invalidation logic for per-conn cache, or
2. a shared versioned page cache

But right now we must follow SQLite to make our current behavior not
corrupt data
2025-07-24 16:23:12 +03:00
Pere Diaz Bou
066ffcc940 append frame one by one
Let's make sure we don't end up in a weird situation by appending frames
one by one and we can later think of optimizations.
2025-07-24 15:12:13 +02:00
Nikita Sivukhin
6daa6d07f1 re-parse schema if necessary after WAL sync end 2025-07-24 11:52:07 +04:00
Nikita Sivukhin
edd6ef2d21 fix after rebase 2025-07-24 11:51:33 +04:00
Nikita Sivukhin
3d2a38eb88 add simple helper 2025-07-24 11:49:39 +04:00
Nikita Sivukhin
4a80306705 fix wal insert frame raw API
- we need to properly mark pages as dirty after insertion
2025-07-24 11:49:39 +04:00
Nikita Sivukhin
d618463906 simplify add_dirty API 2025-07-24 11:29:01 +04:00
Nikita Sivukhin
f4a40c43cd fix clippy 2025-07-23 20:19:00 +04:00
Nikita Sivukhin
30c7bef27b make add dirty to change flag and also add page to the dirty list 2025-07-23 20:06:49 +04:00
Jussi Saurio
1e38202084 Merge 'WAL insert API' from Nikita Sivukhin
This PR implements missing raw WAL API from LibSQL for future use for
offline-sync feature:
1. `wal_insert_begin` - begin WAL session by opening WAL read/write
transaction
2. `wal_insert_end` - finish WAL session by closing WAL transaction
opened by `wal_insert_begin` call
3. `wal_insert_frame` - insert frame `frame_no` with raw content `frame`
(WAL frame included)
For now any schema changes will not be reflected after
`wal_insert_frame` because `turso-db` do not re-parse schema without
need. I will fix this in follow up PR.

Reviewed-by: Pekka Enberg <penberg@iki.fi>

Closes #2231
2025-07-23 14:08:15 +03:00
Jussi Saurio
f98a9e8939 Pager: don't assume page is necessarily in memory anymore 2025-07-23 11:08:34 +03:00
Jussi Saurio
ecb5fce1bd Pager: clear overflow cells when freeing page 2025-07-23 10:58:10 +03:00
Nikita Sivukhin
16763e1500 implement raw WAL write api 2025-07-23 11:30:59 +04:00
Nikita Sivukhin
bc09ea6e98 make end_write_txn/end_read_txn function non-failing 2025-07-23 11:30:29 +04:00
Levy A.
e6ad88cc18 refactor: constified enum -> regular enum 2025-07-22 17:20:30 -03:00
Levy A.
203239ff30 refactor: safer db_state 2025-07-22 17:20:29 -03:00
Jussi Saurio
72b4318fa1 Merge 'fix raw read frame WAL API' from Nikita Sivukhin
This PR fixes `wal_read_frame_raw` API
Before, implementation of raw read API read only page content - which is
not enough as we also need page_no and size_after fields from the
header. This PR fixes that and also make few adjustments in the
signatures.

Reviewed-by: Preston Thorpe (@PThorpe92)

Closes #2229
2025-07-22 16:10:55 +03:00
Nikita Sivukhin
d617d1d21e fix raw read frame WAL API 2025-07-22 16:21:04 +04:00
Nikita Sivukhin
a730136564 use default hasher for the sake of determinism 2025-07-22 16:18:42 +04:00
Jussi Saurio
2967fafe73 Merge 'Usable space unwrap' from Pedro Muniz
Using `unwrap_or_default` can make `page_size` become 0 in this case,
which can lead to subtracting with overflow in `payload_threshold_max`
in case we have some sort of error. Better to unwrap the error here, as
in release mode we may not have overflow checks enabled to catch this.

Closes #2145
2025-07-21 00:23:06 +03:00
Jussi Saurio
010fb1c12a fix/pager/cacheflush: cacheflush shouldn't commit 2025-07-20 21:18:45 +03:00
Levy A.
0ea7849dca feat: IOExt utility trait 2025-07-19 01:40:42 -03:00
pedrocarlo
97d2306e26 unwrap on failed usable_space 2025-07-18 11:36:50 -03:00
Pekka Enberg
02f4bc39b3 Merge 'Reanimate MVCC' from Pekka Enberg
Bit-rot happened. Bring MVCC back from the dead.

Closes #2136
2025-07-18 11:22:49 +03:00
Jussi Saurio
483dc27539 Merge 'make most instrumentation levels to be Debug or Trace instead' from Pedro Muniz
Span creation in debug mode is very slow and impacts our ability to run
the Simulator faster.

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

Closes #2146
2025-07-17 23:45:07 +03:00
pedrocarlo
c15f1e02d3 make most instrumentation levels to be Debug or Trace instead. Span creation in debug mode is very slow and impacts our ability to run the Simulator fast enough 2025-07-17 16:48:24 -03:00