Commit Graph

5842 Commits

Author SHA1 Message Date
Pekka Enberg
dbbc3f5190 Merge 'Reachable assertions in Antithesis Python Test for better logging' from Pedro Muniz
I added some `reachable` assertions in the
`parallel_driver_generate_transaction` so that Antithesis can log when
we reach them, so it is easier to debug the `page_cache` panic we are
getting there

Closes #1995
2025-07-08 10:19:14 +03:00
Pekka Enberg
1cd5a49705 Merge 'treat ImmutableRecord as Value::Blob' from Nikita Sivukhin
This PR implement `get_owned_value` method for `Register` which holds
`ImmutableRecord`. This will be helpful for CDC where `turso-db` will
emit binary record in the before/after columns of CDC table.

Closes #1997
2025-07-08 10:17:56 +03:00
Nikita Sivukhin
29422542cd fix clippy 2025-07-08 10:31:40 +04:00
Nikita Sivukhin
d8fb321b16 treat ImmutableRecord as Value::Blob 2025-07-08 10:28:11 +04:00
pedrocarlo
e9361c0eba add more logging to antithesis tests
format python tests
2025-07-07 19:11:55 -03:00
Pekka Enberg
ad7eabeefc Merge 'remove experimental_flag from script + remove -q flag default flag from TestTursoShell' from Pedro Muniz
Should fix CI issues right now and decrease some of the time it takes to
execute the tests.

Closes #1992
2025-07-07 21:35:05 +03:00
pedrocarlo
90878e12b1 remove cargo-c from CI + let makefile decide what is needed to uv sync for testing 2025-07-07 15:34:29 -03:00
pedrocarlo
81f80edd4a remove experimental_flag from script + remove -q flag default flag from TestTursoShell 2025-07-07 15:34:03 -03:00
Pekka Enberg
341f963a8e Merge 'Fix infinite loops, rollback problems, and other bugs found by I/O fault injection' from Pedro Muniz
Was running the sim with I/O faults enabled and fixed some nasty bugs.
Now, there are some more nasty bugs to fix as well. This is the command
that I use to run the simulator `cargo run -p limbo_sim -- --minimum-
tests 10 --maximum-tests 1000`
This PR mainly fixes the following bugs:
- Not decrementing in flight write counter when `pwrite` fails
- not rolling back the transaction on `step` error
- not rolling back the transaction on `run_once` error
- some functions were just being unwrapped when they could suffer io
errors
- Only change max_frame after wal sync's

Reviewed-by: Pere Diaz Bou <pere-altea@homail.com>
Reviewed-by: Pere Diaz Bou <pere-altea@homail.com>

Closes #1946
2025-07-07 21:31:26 +03:00
pedrocarlo
d21a629cd9 rollback simulator table when we encounter a Rollback query 2025-07-07 13:37:51 -03:00
pedrocarlo
79660f268f rust pass arguments to run-sim 2025-07-07 12:23:00 -03:00
pedrocarlo
6b60dd06c6 only rollback on write transaction 2025-07-07 12:10:54 -03:00
Pekka Enberg
0d17d35ef4 Merge 'Change data capture' from Nikita Sivukhin
This PR add basic CDC functionality to the `turso-db`.
### Feature components
1. `unstable_capture_data_changes_conn` pragma which allow user to turn
on/off CDC logging for **specific connection**
    * CDC will have multiple modes, but for now only `off` / `rowid-
only` are supported
    * Default CDC table is `turso_cdc` but user can override this with
`PRAGMA` update syntax and use arbitrary table for the CDC needs
      * This can be helpful in future if turso will need to break table
format compatibility and custom tables can be a way to migrate between
different schemas
    * Update syntax for the pragma accepts one string argument in
format, where only mode is set or custom cdc table name is provided as
second part of the string, separated with comma from the mode
```sql
turso> PRAGMA unstable_capture_data_changes_conn('rowid-only');
turso> PRAGMA unstable_capture_data_changes_conn('off');
turso> PRAGMA unstable_capture_data_changes_conn('rowid-only,custom_cdc_table');
turso> PRAGMA unstable_capture_data_changes_conn;
┌────────────┬──────────────────┐
│ mode       │ table            │
├────────────┼──────────────────┤
│ rowid-only │ custom_cdc_table │
└────────────┴──────────────────┘
```
2. CDC table schema right now is simple but it will be evolved soon to
support logging of row values before/after the change:
```sql
CREATE TABLE custom_cdc_table (
  operation_id INTEGER PRIMARY KEY AUTOINCREMENT,
  operation_time INTEGER, -- unixepoch() at the moment of insert, can drift if machine clocks is not monotonic
  operation_type INTEGER, -- -1 = delete, 0 = update, 1 = insert
  table_name TEXT,
  id
)
```
  * Note, that `operation_id` is marked as `AUTOINCREMENT` but `turso-
db` needs to implement
https://github.com/tursodatabase/turso/issues/1976 in order to properly
support that keyword
3. Query planner changes are made in `INSERT`/`UPDATE`/`DELETE` plans in
order to emit updates to the CDC table for changes in the table
  * Note, that row `UPDATE` which change primary key generate `DELETE` +
`INSERT` statement instead of single `UPDATE`
### Implementation details
- `PRAGMA` to enable CDC is **unstable** which means that publicly
visible side-effects/public API can change in future (and it will change
soon in order to support more rich CDC modes)
- CDC table is just a regular table with its benefits and downsides:
  * benefits: user can perform maintenance operations with that table
just with regular SQL like `DELETE FROM turso_cdc WHERE operation_id <
?` to cleanup old not needed CDC entries
  * downsides: user can accidentally make unwanted change to CDC table
- Changes to CDC table is not logged to itself
  * Note, that different connections (e.g. `C1`, `C2`) can have
different CDC tables set (e.g. `A` and `B`) - in which case changes made
to CDC table `B` through connection `C1` will be reflected in CDC table
`A`

Reviewed-by: Pere Diaz Bou <pere-altea@homail.com>

Closes #1926
2025-07-07 18:03:07 +03:00
pedrocarlo
367002fb72 rename change_schema to schema_did_change 2025-07-07 11:58:16 -03:00
pedrocarlo
1f2199ea44 run less tests in simulator in CI 2025-07-07 11:53:45 -03:00
pedrocarlo
d8ad4a27f8 only finish appending frames when we are done in cacheflush 2025-07-07 11:53:45 -03:00
pedrocarlo
b85687658d change instrumentation level to INFO 2025-07-07 11:53:45 -03:00
pedrocarlo
4639a4565f change max_frame count only after wal sync in cacheflush 2025-07-07 11:53:45 -03:00
pedrocarlo
46f59e4f0f add more instrumentation + add faults to shrunk plan 2025-07-07 11:53:45 -03:00
pedrocarlo
7c8737e292 do not shadow + continue the assertion on injected fault error 2025-07-07 11:53:45 -03:00
pedrocarlo
7c10ac01e6 do_allocate_page should return a Result 2025-07-07 11:53:45 -03:00
pedrocarlo
e32cc5e0d1 fix query shadowing in faulty query 2025-07-07 11:53:45 -03:00
pedrocarlo
711b1ef114 make all run_once be run under statement or connection so that rollback is called 2025-07-07 11:51:25 -03:00
pedrocarlo
5559c45011 more instrumentation + write counter should decrement if pwrite fails 2025-07-07 11:50:21 -03:00
pedrocarlo
b69472b5a3 pass correct change schema to step rollback 2025-07-07 11:50:21 -03:00
pedrocarlo
7ec47e90cc turn off tracing by default so that errors are not printed in the cli env is not set 2025-07-07 11:50:21 -03:00
pedrocarlo
89a81f9926 remove logging in test 2025-07-07 11:50:21 -03:00
pedrocarlo
9632ab0a41 rollback transaction when we fail in step 2025-07-07 11:50:21 -03:00
pedrocarlo
897426a662 add error tracing to relevant functions + rollback transaction in step_end_write_txn + make move_to_root return result 2025-07-07 11:50:21 -03:00
pedrocarlo
d82b526a5c fix infinite loop with write counter 2025-07-07 11:50:21 -03:00
pedrocarlo
5f9abb62c4 enable faulty query 2025-07-07 11:50:21 -03:00
Pekka Enberg
4a3b0bcf42 Merge 'Import subset of SQLite TCL tests' from Pekka Enberg
This implements a subset of SQLite TCL tests. Let's start fixing errors
and then import more tests!
The test cases are imported from SQLite 3.50.2.
Refs #62

Closes #1980
2025-07-07 17:20:32 +03:00
Pekka Enberg
989fdca6e3 testing/sqlite3: Import function TCL tests 2025-07-07 15:41:38 +03:00
Pekka Enberg
53070d74a4 testing/sqlite3: Import JOIN TCL tests 2025-07-07 15:41:38 +03:00
Pekka Enberg
790b0da97c testing/sqlite3: Import INSERT statement TCL tests 2025-07-07 15:41:38 +03:00
Pekka Enberg
c26adcdeb4 testing/sqlite3: Disable SELECT test that takes forever 2025-07-07 15:41:38 +03:00
Pekka Enberg
3c968df0b2 testing/sqlite3: Disable SELECT tests that require views 2025-07-07 15:41:38 +03:00
Pekka Enberg
38f3d213db testing/sqlite3: Import SELECT statement TCL tests 2025-07-07 15:41:38 +03:00
Pekka Enberg
4206fc2e23 testing/sqlite3: Add TCL tester harness 2025-07-07 15:41:38 +03:00
Pekka Enberg
931a33642e Merge 'add interactive transaction to property insert-values-select' from Pere Diaz Bou
Closes #1958
2025-07-07 14:29:02 +03:00
Pekka Enberg
f640298a6e Merge 'add pere to antithesis' from Pere Diaz Bou
Closes #1984
2025-07-07 14:28:24 +03:00
Pekka Enberg
bcfb9df6f5 Merge 'cli: Add support for .headers command' from Pekka Enberg
The `.headers` command takes `on` and `off` as parameter, supported by
SQLite, which controls whether result set header is printed in list
mode.

Closes #1983
2025-07-07 14:28:17 +03:00
Pekka Enberg
3acd0b5097 antithesis: Install procps in Docker image
Having "ps" around is pretty helpful...
2025-07-07 13:58:11 +03:00
Pere Diaz Bou
cae3a9b54e add pere to antithesis 2025-07-07 12:38:21 +02:00
Pekka Enberg
42c08b5bea cli: Add support for .headers command
The `.headers` command takes `on` and `off` as parameter, supported by
SQLite, which controls whether result set header is printed in list mode.
2025-07-07 13:24:45 +03:00
Pekka Enberg
8d844c13da Merge 'stress: add a way to run stress with indexes enabled' from Jussi Saurio
Previously all constraints were disabled with an `if false {}` hack.
In this PR:
- enable PRIMARY KEYs and UNIQUE constraints if `experimental_indexes`
compile-time feature is enabled.
- Also enable PRIMARY KEY for exactly INTEGER columns, as INTEGER
PRIMARY KEY does not require an index
- NOT NULL constraint is also now enabled in both cases, as it doesn't
require an index

Closes #1981
2025-07-07 13:18:10 +03:00
Pekka Enberg
4aa987d65c Merge 'core/translate: Unify no such table error messages' from Pekka Enberg
We're now mixing different error messages, which makes compatibility
testing pretty hard. Unify on a single, SQLite compatible error message
"no such table".

Closes #1978
2025-07-07 13:17:59 +03:00
Jussi Saurio
0762c8f780 stress: add a way to run stress with indexes enabled 2025-07-07 13:04:52 +03:00
Nikita Sivukhin
1655c0b84f small fixes 2025-07-07 12:50:10 +04:00
Nikita Sivukhin
3e7e66c0e7 add basic cdc tests 2025-07-07 12:44:50 +04:00