Commit Graph

9929 Commits

Author SHA1 Message Date
Nikita Sivukhin
8dae601fac make rollback non-failing method 2025-10-06 13:21:45 +04:00
Nikita Sivukhin
38d2630969 remove unnecessary SchemaLocked error
- lock() return error in case when another thread panicked while holding the same lock
- we better to just panic too in any such case
2025-10-06 12:15:15 +04:00
Pekka Enberg
f12e0105e5 Merge 'core/io: Add completion group API for managing multiple I/O operations' from Pekka Enberg
Introduces a CompletionGroup abstraction that allows grouping multiple
I/O completions together for coordinated tracking and error handling.
This enables:
- Tracking completion status of multiple I/O operations as a group
- Detecting when all operations in a group have finished
- Aborting all operations in a group atomically
- Retrieving errors from any completion in the group
The implementation uses intrusive linked lists for efficient membership
tracking and atomic counters for outstanding operation counts. Each
completion can be linked to a group using the new .link() method.
This lays the groundwork for batch I/O operations and coordinated
transaction handling in the storage layer.

Reviewed-by: Pedro Muniz (@pedrocarlo)

Closes #3560
2025-10-06 09:19:50 +03:00
Pekka Enberg
be6f3d09ea core/storage: Switch checkpoint_inner() to completion group 2025-10-06 07:33:31 +03:00
Pekka Enberg
c27b167c6d core/io: Add completion group API for managing multiple I/O operations
Introduces a completion group abstraction that allows grouping multiple
I/O completions together for coordinated tracking and error handling.
This enables:

- Tracking completion status of multiple I/O operations as a group
- Detecting when all operations in a group have finished
- Aborting all operations in a group atomically
- Retrieving errors from any completion in the group

The implementation uses intrusive linked lists for efficient membership
tracking and atomic counters for outstanding operation counts. Each
completion can be linked to a group using the new .link() method.

This lays the groundwork for batch I/O operations and coordinated
transaction handling in the storage layer.
2025-10-06 07:33:31 +03:00
Jussi Saurio
aab7d989df Merge 'Simulator diff print' from Pedro Muniz
I was trying to debug MVCC simulator and database diffs, and this change
makes it much easier to visualize this. This PR is just a small quality
of life upgrade for debugability.

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

Closes #3548
2025-10-05 18:34:26 +03:00
Jussi Saurio
90632ad883 Merge 'Improve simulator cli' from bit-aloo
1. Moving manual CLI validation into Clap for safer argument handling.
2. Remove deprecated `with_ascii` flag from `PrettyFields` in logger
initialization.
3. Remove `log` and `env_logger` dependencies in favor of `tracing` from
simulator.

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

Closes #3533
2025-10-05 18:33:55 +03:00
Pekka Enberg
b52d6ab056 Merge 'core/mvcc: automatic logical log checkpointing on commit' from Pere Diaz Bou
On reaching 8 MiB checkpoint threshold we perform a blocking checkpoint
on the logical log. These changes modified how transaction_state is
tracked so that on a regular transaction we don't update it checkpoint's
state machine.
I wonder if checkpoint should stay inside commit's transaction locks or
like I did, where checkpoint happens right after committing transaction
but this happens on the same query during halt.

Closes #3565
2025-10-04 11:30:04 +03:00
Pekka Enberg
b063d0d41a Merge 'Don't panic if doing INSERT INTO ... SELECT rowid' from Jussi Saurio
Backport: 0.2
Closes #3567

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

Closes #3572
2025-10-04 10:11:09 +03:00
Pekka Enberg
b81d45ae11 Merge 'remove dyn DatabaseStorage replace it with DatabaseFile' from Pedro Muniz
Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com>

Closes #3566
2025-10-04 10:08:33 +03:00
Pekka Enberg
50607607fa Merge 'Actually enforce uniqueness in create unique index' from Jussi Saurio
we just weren't doing it 🤡
Backport: 0.2
Closes #3568

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

Closes #3571
2025-10-04 10:07:44 +03:00
Pere Diaz Bou
e3f2bbf90b core/mvcc: remove unnecessary fields in CommitState::Checkpoint 2025-10-03 22:27:03 +02:00
Pere Diaz Bou
c612a51df7 fmt 2025-10-03 22:24:38 +02:00
Pere Diaz Bou
6c1983aadf core/vdbe: op_checkpoint set update_transaction_state logical log checkpoint to true 2025-10-03 22:24:38 +02:00
Pere Diaz Bou
8e80af7221 core/mvcc: checkpoint if needed after commit 2025-10-03 22:24:38 +02:00
Pere Diaz Bou
a30c95d988 core/mvcc/logical-log: add threshold for checkpoints in logical log 2025-10-03 22:24:33 +02:00
Jussi Saurio
81b437c690 Don't panic if doing INSERT INTO ... SELECT rowid
Closes #3567
2025-10-03 23:12:24 +03:00
Jussi Saurio
8dac1ba21a Fix: actually enforce uniqueness in CREATE UNIQUE INDEX
...we just didn't do it
2025-10-03 22:58:42 +03:00
Jussi Saurio
cb96c3e944 VDBE: implement SorterCompare
this is used for uniqueness enforcement in CREATE INDEX.
2025-10-03 22:58:42 +03:00
pedrocarlo
f3dc0bef5d remove some explicit Arc<dyn File> references 2025-10-03 16:39:57 -03:00
Pekka Enberg
1b42f77300 Merge 'Add short writes to unreliable-libc' from FamHaggs
Add short writes in the faulty_libc
As @PThorpe92 stated in #3209, this should be implemented here instead
of the memory io in the simulator. Running this in the stress test I
caught a logic bug in the try_pwritev_raw I will create a pr for that
small fix. I will close #3209 in favor of this pr.

Closes #3569
2025-10-03 21:52:47 +03:00
Pekka Enberg
c35896ab0f Merge 'core/io/unix: Fix short writes in try_pwritev_raw()' from FamHaggs
Fixes incorrect buffer length calculation in try_pwritev_raw when
handling the first slice of the I/O vector.
Why:
With the faulty libc tests, a short write was simulated and the code
incorrectly computed the length for the first buffer, leading to more
bytes being written than expected, leading to a panic inside the
completion.
How:
Adjusted the slice calculation to ensure only the intended range of
bytes is written.
Backport: 0.2

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

Closes #3570
2025-10-03 20:50:58 +03:00
pedrocarlo
e93add6c80 remove dyn DatabaseStorage and replace it with DatabaseFile 2025-10-03 14:14:15 -03:00
FHaggs
af35f6534d Fix: Calculate right buff len in the case of the first buffer in
try_pwritev_raw.
2025-10-03 18:46:16 +02:00
FHaggs
dd6e092a5c Add short writes to pwritev in faulty_libc. 2025-10-03 18:35:03 +02:00
Pere Diaz Bou
55f5cd2ad7 core/mvcc/logical-log: test automatic checkpoint 2025-10-03 17:23:59 +02:00
Pere Diaz Bou
7db5a09005 core/mvcc/logical-log: checkpoint support not updating transaction_state if needed 2025-10-03 17:23:35 +02:00
pedrocarlo
25ad94079c print_diff in ReadYourUpdatesBack + TableHasExpectedContent 2025-10-03 11:34:40 -03:00
Pekka Enberg
2efbb2d324 Merge 'add basic examples for database-wasm package' from Nikita Sivukhin
Closes #3558
2025-10-03 17:21:25 +03:00
Pekka Enberg
0dd8307ea2 Merge ' core/wal: introduce transaction_count, same as iChange in sqlite ' from Pere Diaz Bou
Depends on #3502
sqlite has a field in index header called `iChange` that is incremented
after every commit. This commit simply adds support for it.
```c
struct WalIndexHdr {
  u32 iVersion;       /* Wal-index version */
  u32 unused;         /* Unused (padding) field */
  u32 iChange;        /* Counter incremented each transaction */
```

Closes #3559
2025-10-03 16:53:35 +03:00
Pere Diaz Bou
9c9d4d147e core/btree: fuzz tests force page 1 allocation with a transaction 2025-10-03 13:28:28 +02:00
Pere Diaz Bou
8f103f7c35 core/wal: introduce transaction_count, same as iChange in sqlite 2025-10-03 13:02:47 +02:00
Pekka Enberg
c98bf9b593 Merge 'core/wal: check index header on begin_write_tx' from Pere Diaz Bou
Fixes a page cache staleness issue where connections could incorrectly
believe the database hasn't changed after checkpointing. This can happen
when writes following a checkpoint resulted in the same `max_frame
value`, causing connections to miss updates since they only checked
`max_frame` to detect changes.

Closes #3502
2025-10-03 13:51:22 +03:00
Nikita Sivukhin
f582744819 fix package jsons 2025-10-03 14:44:15 +04:00
Nikita Sivukhin
82d53f8d06 add sync-wasm-vite example 2025-10-03 14:43:23 +04:00
Nikita Sivukhin
d4373379cd remove wasm example 2025-10-03 14:20:18 +04:00
Nikita Sivukhin
17c99de34f accept libsql:// urls generated by the platform 2025-10-03 14:19:36 +04:00
Nikita Sivukhin
515ccfea76 small adjustment 2025-10-03 14:19:07 +04:00
Nikita Sivukhin
73049a0205 add sync node example 2025-10-03 14:18:52 +04:00
Pere Diaz Bou
b5a969933c core/wal: remove dbg! 2025-10-03 12:17:35 +02:00
Pekka Enberg
7d45253d03 Merge 'Disallow unexpected interop between WAL mode and MVCC mode' from Jussi Saurio
1. DB cannot be opened with MVCC if non-zero WAL file exists
2. DB cannot be opened without MVCC if non-zero logical log file exists

Closes #3557
2025-10-03 12:55:03 +03:00
Pekka Enberg
5c0b3313f2 Add encryption at rest feature to README 2025-10-03 12:32:01 +03:00
Nikita Sivukhin
b67ef8a7eb add basic examples for database-wasm package 2025-10-03 13:23:59 +04:00
Pekka Enberg
7905841990 Turso 0.2.0 2025-10-03 12:20:42 +03:00
Pekka Enberg
91983abaa5 Update CHANGELOG.md 2025-10-03 12:20:20 +03:00
Jussi Saurio
ec6731de0a Disallow unexpected interop between WAL mode and MVCC mode
1. DB cannot be opened with MVCC if non-zero WAL file exists
2. DB cannot be opened without MVCC if non-zero logical log file exists
2025-10-03 12:00:35 +03:00
Pekka Enberg
3867e5a60e Merge 'CI: run long fuzz tests and stress on every PR, use 2 threads for stress' from Jussi Saurio
Reviewed-by: Pere Diaz Bou <pere-altea@homail.com>

Closes #3556
2025-10-03 11:49:20 +03:00
Pekka Enberg
3b1d2535de Turso 0.2.0-pre.15 2025-10-03 11:29:43 +03:00
Pekka Enberg
d9e607082f Merge 'Disallow INDEXED BY / NOT INDEXED in select' from Jussi Saurio
Closes #3547

Closes #3551
2025-10-03 11:29:13 +03:00
Pekka Enberg
87a6a90fdf Merge 'core/mvcc: Rename "-lg" to "-log"' from Pekka Enberg
The "lg" name is just weird.

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

Closes #3554
2025-10-03 11:28:54 +03:00