limbo/core
Pekka Enberg 380b27f58a
Merge 'Busy handler' from Pedro Muniz
I searched using deepwiki how SQLite implements their busy handler. They
use a callback system with exponential backoff, where it stores the
callback in the pager and in the database. I confess I found this
slightly confusing, so I just implemented a simple exponential backoff
directly in the `Statement` struct. I imagine SQLite does this in a more
convoluted manner, as they do not have a concept of yielding as we do.
https://deepwiki.com/search/where-is-the-code-for-the-
busy_4a5ed006-4eed-479f-80c3-dd038832831b
I also fixed the rust bindings so that it yields when we return
`StepResult::IO`, instead of just blocking the async function. To
achieve this I implemented the `Stream` trait for `Rows` struct, which
unfortunately came with a slight change to the function signature of
`rows.next()` to `rows.try_next()`.
EDIT:
~test `test_multiple_connections_fuzz` timeouts because now it has the
busy handler "slowing" things down (this test generates a lot of busy
transactions), so it takes a lot longer for the test to run. Not sure if
it is acceptable for us to reduce the number of operations so the test
is shorter.~
EDIT:
Adjusted the API to be more in line with
https://www.sqlite.org/c3ref/busy_timeout.html.
Sets maximum total accumulated timeout. If the duration is None or Zero,
we unset the busy handler for this Connection.
This api defers slightly from SQLite as instead of sleeping for linear
amount of time specified by the user, we will sleep in phases until the
the total amount of time requested is reached. This means we first sleep
of 1ms, then if we still return busy, we sleep for 2 ms, and repeat
until a maximum of 100 ms per phase or we reached the total timeout.
Example:
1. Set duration to 5ms
2. Step through query -> returns Busy -> sleep/yield for 1 ms
3. Step through query -> returns Busy -> sleep/yield for 2 ms
4. Step through query -> returns Busy -> sleep/yield for 2 ms (totaling
5 ms of sleep)
5. Step through query -> returns Busy -> return Busy to user
This slight api change demonstrated a better throughtput in
`perf/throughput/turso` benchmark
```sh
cargo run -p write-throughput --release -- -t 2

Running write throughput benchmark with 2 threads, 100 batch size, 10 iterations, mode: Legacy
Database created at: write_throughput_test.db
Thread 1: 1000 inserts in 0.04s (23438.42 inserts/sec)
Thread 0: 1000 inserts in 0.08s (12385.64 inserts/sec)

=== BENCHMARK RESULTS ===
Total inserts: 2000
Total time: 0.08s
Overall throughput: 24762.60 inserts/sec
Threads: 2
Batch size: 100
Iterations per thread: 10
Database file exists: true
Database file size: 4096 bytes
```
Depends on #3102
Closes #3067

Closes #3074
2025-09-15 13:52:49 +03:00
..
benches fix mvcc rollback 2025-09-15 09:29:08 +03:00
ext use new internal virtual table type 2025-09-05 14:56:05 -04:00
functions Merge 'core: Support ceiling modifier in datetime' from Ceferino Patino 2025-09-10 14:46:07 +03:00
incremental Fix tests for views 2025-09-12 08:20:40 -04:00
io modify semantics of busy_timeout to be more on par with sqlite 2025-09-15 02:20:32 -03:00
json Merge 'Fix jsonb functions check valid json string binary' from 2025-09-10 14:44:54 +03:00
mvcc mvcc: fix hang when CONCURRENT tx tries to commit and non-CONCURRENT tx is active 2025-09-15 11:09:19 +03:00
numeric fix: math function parameter conversion 2025-09-10 20:49:30 -03:00
storage remove unused pager parameter 2025-09-14 23:44:24 +03:00
time
translate store tx_mode in conn.mv_tx 2025-09-14 21:59:08 +03:00
vdbe fix mvcc rollback 2025-09-15 09:29:08 +03:00
vector rename functions 2025-08-15 17:08:53 -04:00
assert.rs
build.rs
Cargo.toml Add checksums behind a feature flag 2025-09-13 11:00:39 +05:30
error.rs Add checksum module 2025-09-13 11:00:37 +05:30
fast_lock.rs
function.rs fix: reintroduce rename 2025-08-30 03:10:39 -03:00
info.rs
lib.rs modify semantics of busy_timeout to be more on par with sqlite 2025-09-15 02:20:32 -03:00
parameters.rs
pragma.rs core: Panic on fsync() error by default 2025-09-13 10:21:12 +03:00
pseudo.rs
result.rs Fix transaction read0 shortcut in WAL and track whether we have snapshot 2025-07-30 14:08:33 +03:00
schema.rs Merge 'Fixes views' from Glauber Costa 2025-09-12 07:43:32 -04:00
series.rs Replace ConstraintInfo::plan_info with ConstraintInfo::index 2025-08-05 05:48:29 +02:00
state_machine.rs core/mvcc: make commit_txn return on I/O 2025-09-02 17:07:38 +02:00
types.rs on reprepare create new state with updated number of cursors and 2025-09-11 12:50:22 -03:00
util.rs store tx_mode in conn.mv_tx 2025-09-14 21:59:08 +03:00
uuid.rs
vtab.rs put json_each behind feature 2025-09-05 14:56:09 -04:00