Commit graph

11973 commits

Author SHA1 Message Date
Nikita Sivukhin
e19efb07b2 fix python lint errors 2025-12-22 22:03:09 +04:00
Nikita Sivukhin
8b04ce7235 rename partial_sync_opts to partial_sync_experimental for Python driver 2025-12-22 21:52:11 +04:00
Nikita Sivukhin
1a1d06b708 rename partialSyncOpts to partialSyncOptsExperimental in the JS driver 2025-12-22 21:50:27 +04:00
Nikita Sivukhin
f63ae56ddb rename options in go driver to *Experimental 2025-12-22 21:50:27 +04:00
Nikita Sivukhin
286fc6d42c update devcontainer setup 2025-12-22 19:29:07 +04:00
Preston Thorpe
37e8cf176a
Merge 'slightly adjust fixed unstable test' from Nikita Sivukhin
Follow up after 2257614423
dbef65c907312afe8e437dde763c4b

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

Closes #4325
2025-12-22 09:02:34 -05:00
Jussi Saurio
92e78466c9
Merge 'tcl: run PRAGMA journal_mode=experimental_mvcc with mvcc' from Pere Diaz Bou
## Description
run PRAGMA journal_mode=experimental_mvcc with mvcc
## Motivation and context
After https://github.com/tursodatabase/turso/pull/4294 we need a way run
with mvcc mode.
## Description of AI Usage
it wrote the remove first line

Closes #4298
2025-12-22 15:08:28 +02:00
Nikita Sivukhin
9923fdd2f7 fix clippy 2025-12-22 16:36:01 +04:00
Nikita Sivukhin
b6a63be40e slightly adjust fixed unstable test 2025-12-22 16:32:48 +04:00
Jussi Saurio
1085e78124 Merge 'CI test setup fixes + fix GroupCompletion bug' from Pedro Muniz
## CI speed improvements
Let's use Sccache for compiling our code faster, cargo nextest to run
tester faster, run all tests in CI, automatically terminate workflows if
you push a new commit (so we don't waste more money running code that we
don't care anymore).
Also https://github.com/useblacksmith/rust-cache is deprecated, so we
should be using `Swatinem/rust-cache@v2`
## CI test setup fixes
We were ignoring entire suites of tests in CI. Re-enable them and fix
the failures. Most of them were stale test setups, apart from https://gi
thub.com/tursodatabase/turso/pull/4311/commits/a67eb0006d8ac23dd85918309
303701959fdc988 which appears to be a real bug.
Also fix linking sqlite not working on windows for compat tests
## Runtime code fixes
a67eb0006d
dd85918309303701959fdc988 appears to be a real bug in GroupCompletion
code - `succeeded()` requires that the result be set to `Some(None)`
## Motivation and context
Closes https://github.com/tursodatabase/turso/issues/4266
<!--
Please include relevant motivation and context.
Link relevant issues here.
-->
## Description of AI Usage
Ai just edited the files for me, I was the one asked it do the changes
in the workflows
<!--
Please disclose how AI was used to help create this PR. For example, you
can share prompts,
specific tools, or ways of working that you took advantage of. You can
also share whether the
creation of the PR was mainly driven by AI, or whether it was used for
assistance.
This is a good way of sharing knowledge to other contributors about how
we can work more efficiently with
AI tools. Note that the use of AI is encouraged, but the committer is
still fully responsible for understanding
and reviewing the output.
-->

Closes #4311
2025-12-22 14:24:55 +02:00
Jussi Saurio
596d8e4abb Ensure mvcc and non-mvcc test cant share the same directory 2025-12-22 13:49:33 +02:00
Jussi Saurio
75a1dbea58 Enable conn_raw_api feature in core_tester 2025-12-22 13:48:01 +02:00
Jussi Saurio
2257614423 make test_db_concurrent_use() more robust 2025-12-22 12:52:50 +02:00
Jussi Saurio
84fb3d6f55 Dont compare against real sqlite on windows in c compat tests due to complexity 2025-12-22 12:52:50 +02:00
Jussi Saurio
9517c1290f don't test macro comments - theyre just an illustration 2025-12-22 12:24:06 +02:00
Jussi Saurio
29aed49ec2 fix completions: result must be Some for succeeded() be true 2025-12-22 12:24:06 +02:00
Jussi Saurio
08805d6315 fix test_pager_setup: page1 should be initialized properly 2025-12-22 12:24:06 +02:00
Jussi Saurio
206a42ef7e fix timediff test: comparing eq times should return zeros, not null 2025-12-22 12:24:06 +02:00
Jussi Saurio
b52661c28e fix setup_test_env(): initialize page 1 2025-12-22 12:24:06 +02:00
Jussi Saurio
a0ba3691dc fix/sdk-kit: fix whitespace difference in assertion 2025-12-22 12:24:06 +02:00
Jussi Saurio
00d7b5d8db fix page_cache tests not to use page id 1 which is never evictable 2025-12-22 12:24:06 +02:00
Jussi Saurio
e20bec6167 Fix incorrect error expectation in test_wal_stale_snapshot 2025-12-22 12:24:06 +02:00
pedrocarlo
9e08ffc04c use cargo nextest to run all tests and not only integration tests + remove sccache show stats 2025-12-22 12:24:06 +02:00
pedrocarlo
591cf05fbd try claude suggestions 2025-12-22 12:24:06 +02:00
Pekka Enberg
b4a331da38
Merge 'SDK tweaks' from Nikita Sivukhin
Few small tweaks in SDKs:
1. Export `ConnectionSync` type from Python SDK
2. Remove dependency on `conn_raw_api` and corresponding methods from
rust bindings - no one use them so let's drop support for this feature
completely
3. Add Waker dependency in the sdk-kit in order to integrate it later to
rust bindings
4. Add io_uring feature to the sdk-kit

Closes #4284
2025-12-22 11:59:02 +02:00
Pekka Enberg
f598dfa13d
Merge 'core/mvcc: set_null_flag(false) when seek is called' from Pere Diaz Bou
Some checks are pending
Build & publish @tursodatabase/database / db-bindings-x86_64-pc-windows-msvc - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / db-bindings-x86_64-unknown-linux-gnu - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / sync-bindings-aarch64-apple-darwin - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / sync-bindings-aarch64-unknown-linux-gnu - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / sync-bindings-wasm32-wasip1-threads - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / sync-bindings-x86_64-pc-windows-msvc - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / sync-bindings-x86_64-unknown-linux-gnu - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / Test DB bindings on Linux-x64-gnu - node@20 (push) Blocked by required conditions
Build & publish @tursodatabase/database / Test DB bindings on browser@20 (push) Blocked by required conditions
Build & publish @tursodatabase/database / Publish (push) Blocked by required conditions
Python / configure-strategy (push) Waiting to run
Python / test (push) Blocked by required conditions
Python / lint (push) Waiting to run
Python / linux (x86_64) (push) Waiting to run
Python / macos-arm64 (aarch64) (push) Waiting to run
Python / sdist (push) Waiting to run
Python / Release (push) Blocked by required conditions
Rust / cargo-fmt-check (push) Waiting to run
Rust / build-native (blacksmith-4vcpu-ubuntu-2404) (push) Waiting to run
Rust / build-native (macos-latest) (push) Waiting to run
Rust / build-native (windows-latest) (push) Waiting to run
Rust / clippy (push) Waiting to run
Rust / simulator (push) Waiting to run
Rust / test-limbo (push) Waiting to run
Rust / test-sqlite (push) Waiting to run
Rust Benchmarks+Nyrkiö / tpc-h (push) Waiting to run
Rust Benchmarks+Nyrkiö / vfs-bench-compile (push) Waiting to run
Rust Benchmarks+Nyrkiö / bench (push) Waiting to run
Rust Benchmarks+Nyrkiö / clickbench (push) Waiting to run
Rust Benchmarks+Nyrkiö / tpc-h-criterion (push) Waiting to run
## Description
BTreeCursor sets null flag to false once `seek` is called. This PR does
the same for MVCC
## Motivation and context
join.test failed with some cases due to this bug
## Description of AI Usage
I asked AI to find the issue but I ended showing the agent why he did
things wrong and that he should be ashamed

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

Closes #4296
2025-12-22 09:15:24 +02:00
Pekka Enberg
6fcf66be3d
Merge 'pyturso: fix panic' from Nikita Sivukhin
`resume` was not re-entrant and panicked in case when was called after
operation completion.
```
thread '<unnamed>' panicked at sync/sdk-kit/src/turso_async_operation.rs:59:20:
`async fn` resumed after completion
...
```
This PR makes `resume` method for `PyTursoAsyncOperation` re-entrant
(like in the c-api) and also convert exception type in the sync module

Closes #4315
2025-12-22 09:09:37 +02:00
Pekka Enberg
d3714f4120
Merge 'Mark triggers as experimental' from Jussi Saurio
Closes #4022

Closes #4318
2025-12-22 09:08:54 +02:00
Preston Thorpe
d6ceda8dcb
Merge 'fix(core/translate): apply affinity conversion to hash join build and probe keys' from Nuno Gonçalves
## Description
This PR adds missing affinity conversion to hash joins by applying
affinity conversion to build and probe keys before hashing.
```
turso> CREATE TABLE x(a INTEGER);
turso> CREATE TABLE y(b TEXT);
turso> INSERT INTO x VALUES (2),(3);
turso> INSERT INTO y VALUES ('02'),('2'),('2.0'),('3x'),('3.5');
turso> SELECT a, b
  FROM x JOIN y ON a = b
  ORDER BY a, b;
┌───┬─────┐
│ a │ b   │
├───┼─────┤
│ 2 │ 02  │
├───┼─────┤
│ 2 │ 2   │
├───┼─────┤
│ 2 │ 2.0 │
└───┴─────┘
```
## Motivation and context
Fixes #3482.
Currently, Turso returns an empty result set:
```
turso> CREATE TABLE x(a INTEGER);
turso> CREATE TABLE y(b TEXT);
turso> INSERT INTO x VALUES (2),(3);
turso> INSERT INTO y VALUES ('02'),('2'),('2.0'),('3x'),('3.5');
turso> SELECT a, b
  FROM x JOIN y ON a = b
  ORDER BY a, b;
turso>
```
Expected behavior:
```
sqlite> CREATE TABLE x(a INTEGER);
sqlite> CREATE TABLE y(b TEXT);
sqlite> INSERT INTO x VALUES (2),(3);
sqlite> INSERT INTO y VALUES ('02'),('2'),('2.0'),('3x'),('3.5');
sqlite> SELECT a, b
   ...>   FROM x JOIN y ON a = b
   ...>   ORDER BY a, b;
2|02
2|2
2|2.0
```
## Description of AI Usage
This PR was developed with assistance from Claude Sonnet 4.5 through
code completions.

Reviewed-by: Preston Thorpe <preston@turso.tech>

Closes #4317
2025-12-21 21:08:29 -05:00
Preston Thorpe
ca0f86c8d8
Merge 'Set all testing dbs to WAL journal mode' from Preston Thorpe
Set the testing DB's to WAL mode permanently so we don't keep making
changes to these every time we open them with `make test`

Reviewed-by: Pedro Muniz (@pedrocarlo)

Closes #4321
2025-12-21 21:07:37 -05:00
PThorpe92
9954b096cc
Set all testing dbs to WAL journal mode 2025-12-21 21:02:02 -05:00
Jussi Saurio
ad609dd04f
Merge 'fix/core: fix transaction issues' from Jussi Saurio
Some checks are pending
Build & publish @tursodatabase/database / db-bindings-x86_64-pc-windows-msvc - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / db-bindings-x86_64-unknown-linux-gnu - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / sync-bindings-aarch64-apple-darwin - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / sync-bindings-aarch64-unknown-linux-gnu - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / sync-bindings-wasm32-wasip1-threads - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / sync-bindings-x86_64-pc-windows-msvc - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / sync-bindings-x86_64-unknown-linux-gnu - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / Test DB bindings on Linux-x64-gnu - node@20 (push) Blocked by required conditions
Build & publish @tursodatabase/database / Test DB bindings on browser@20 (push) Blocked by required conditions
Build & publish @tursodatabase/database / Publish (push) Blocked by required conditions
Python / sdist (push) Waiting to run
Python / Release (push) Blocked by required conditions
Python / configure-strategy (push) Waiting to run
Python / test (push) Blocked by required conditions
Python / lint (push) Waiting to run
Python / linux (x86_64) (push) Waiting to run
Python / macos-arm64 (aarch64) (push) Waiting to run
Rust / cargo-fmt-check (push) Waiting to run
Rust / build-native (blacksmith-4vcpu-ubuntu-2404) (push) Waiting to run
Rust / build-native (macos-latest) (push) Waiting to run
Rust / build-native (windows-latest) (push) Waiting to run
Rust / clippy (push) Waiting to run
Rust / simulator (push) Waiting to run
Rust / test-limbo (push) Waiting to run
Rust / test-sqlite (push) Waiting to run
Rust Benchmarks+Nyrkiö / vfs-bench-compile (push) Waiting to run
Rust Benchmarks+Nyrkiö / bench (push) Waiting to run
Rust Benchmarks+Nyrkiö / clickbench (push) Waiting to run
Rust Benchmarks+Nyrkiö / tpc-h-criterion (push) Waiting to run
Rust Benchmarks+Nyrkiö / tpc-h (push) Waiting to run
## Transaction fixes
- return BUSY_SNAPSHOT instead of BUSY when transaction tries to
      promote from read to write and its snapshot is stale. this is
      a case where retrying with busy_timeout will never help.
- fix bug in begin_read_tx() where it would not allow to use a
      readmark that is lower than shared_max (causes an enormous amount
of busy errors / contention)
 - fix another bug in begin_read_tx() where it would not decrement
shared lock if it needed to abort due to stale header values
- validate shared state again after deciding to use read0 lock -
otherwise we might miss frames (another TOCTOU issue)
- implement sqlite's exponential backoff algorithm for begin_read_tx()
      to improve multiple threads' ability to acquire write lock
## Fix deadlock
use with_shared() instead of with_shared_mut() for lock ops
using shared_mut() is unnecessary because the locks use atomics, and
in fact using shared_mut() can cause a deadlock, example:
- Thread 1 calls with_shared_mut() at in try_begin_read_tx
   to claim/update a read mark slot. This waits for readers to release
   their shared read locks.
- Thread 2 tries to use with_shared_mut() in end_read_tx() and also
  can't proceed
## Perf/throughput test adjustment
If `BusySnapshot` is returned, explicitly ROLLBACK and restart the
transaction
## Review guide
I've interactive rebased this to 10 commits that are fairly sensible, so
feel free to read one-by-one.

Reviewed-by: Preston Thorpe <preston@turso.tech>

Closes #4289
2025-12-21 22:50:33 +02:00
Jussi Saurio
2bf7ec5136 mark triggers as experimental 2025-12-21 21:18:15 +02:00
Nuno Gonçalves
734ba9a1bf chore(format): cargo fmt 2025-12-21 17:15:11 +00:00
Nuno Gonçalves
1b386147c1 fix(core/translate): apply affinity conversion to hash join build and probe keys 2025-12-21 16:59:46 +00:00
Jussi Saurio
492e4cfcd3 quick script to run thrpt benchmark N times 2025-12-21 18:38:08 +02:00
Jussi Saurio
a69191e365 perf/thrpt: rollback+restart if BusySnapshot error is returned 2025-12-21 18:38:05 +02:00
Jussi Saurio
6e58378471 rename with_shared_mut to with_shared_mut_dangerous 2025-12-21 18:38:01 +02:00
Jussi Saurio
acc1a89872 fix/wal: use with_shared() instead of with_shared_mut() for lock ops
using shared_mut() is unnecessary because the locks use atomics, and
in fact using shared_mut() can cause a deadlock, example:

- Thread 1 calls with_shared_mut() at in try_begin_read_tx
   to claim/update a read mark slot. This waits for readers to release
   their shared read locks.
- Thread 2 tries to use with_shared_mut() in end_read_tx() and also
  can't proceed
2025-12-21 18:37:58 +02:00
Jussi Saurio
18f6e1a350 Update tests for BusySnapshot error
- Handle "snapshot is stale" in fuzz tests as retriable error
- Test that stale snapshot returns BusySnapshot, not Busy
2025-12-21 18:37:47 +02:00
Jussi Saurio
97be13a6be Implement progressive backoff in begin_read_tx
Extract try_begin_read_tx with TryBeginReadResult::Retry for transient
conditions. begin_read_tx now retries with SQLite's quadratic backoff:
immediate retries for first 5 attempts, yield for 6-9, then quadratic
microsecond delays matching SQLite's formula.
2025-12-21 18:37:34 +02:00
Jussi Saurio
aead47f2a8 Return BusySnapshot instead of Busy for stale snapshot in begin_write_tx
BusySnapshot indicates the transaction's snapshot is permanently stale
and must be rolled back. Unlike Busy, retrying with busy_timeout will
never help - the caller must rollback and restart the transaction.
2025-12-21 18:35:03 +02:00
Jussi Saurio
139b398e49 Fix begin_read_tx validation and unlock on retry
- Add lock-0 re-validation after acquiring read_locks[0]
- Remove incorrect best_mark == shared_max requirement (stale mark is fine)
- Add current_slot_mark validation to detect slot modification race
- Unlock read lock before returning Busy on validation failure
- Use shared_max instead of best_mark for max_frame (bug fix)
2025-12-21 18:34:06 +02:00
Jussi Saurio
6938f334ab Add yield_now() and sleep() to IO trait
Used for progressive backoff in contended lock acquisition.
2025-12-21 18:29:52 +02:00
Jussi Saurio
cabea235ce Add BusySnapshot error type
Distinct from Busy: indicates the transaction's snapshot is permanently
stale and must be rolled back. Retrying with busy_timeout will not help.
2025-12-21 18:29:39 +02:00
Nikita Sivukhin
fc21324c61 fix test 2025-12-21 15:47:19 +04:00
Nikita Sivukhin
f94f38623d uvx ruff check --fix 2025-12-21 14:29:10 +04:00
Nikita Sivukhin
0270505210 fix exception type 2025-12-21 14:28:52 +04:00
Nikita Sivukhin
03c95fb1ad fix async operation resume API usage in python bindings 2025-12-21 14:24:42 +04:00
Nikita Sivukhin
7a79adc958 make resume re-entrant 2025-12-21 14:24:05 +04:00