Commit Graph

9946 Commits

Author SHA1 Message Date
pedrocarlo
bb9c8dea4f rework interaction generation to only generate possible queries + do less allocations 2025-10-07 02:36:13 -03:00
pedrocarlo
1d1b09dc17 modify query generation to always sample from valid queries 2025-10-07 02:36:13 -03:00
Preston Thorpe
497808a40c Merge 'eliminate the need for another Once in Completion' from Pedro Muniz
I added the `Once` before so fix a bug, but it was a bit hackery. We can
`get_or_init` to achieve the same purpose, and the code becomes much
cleaner. `get_or_init` guarantees the init will happen only once as
well.

Reviewed-by: Preston Thorpe <preston@turso.tech>
Reviewed-by: bit-aloo (@Shourya742)

Closes #3578
2025-10-06 19:52:41 -04:00
Pekka Enberg
f8bdc02986 Merge 'Rename Completion methods' from Pedro Muniz
Reviewed-by: bit-aloo (@Shourya742)
Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com>

Closes #3579
2025-10-06 20:12:21 +03:00
Pekka Enberg
0134192cae Merge 'Top level examples' from Nikita Sivukhin
Closes #3599
2025-10-06 18:26:18 +03:00
Pere Diaz Bou
59c08c1062 Merge 'core/mvcc: implement PartialOrd for RowId' from Pere Diaz Bou
Closes #3597
2025-10-06 16:42:04 +02:00
Nikita Sivukhin
d2dab3d18c fix main workspace dir 2025-10-06 18:30:29 +04:00
Nikita Sivukhin
f0c7cff18c add README 2025-10-06 18:19:22 +04:00
pedrocarlo
2ce0e9db57 eliminate the need for another Once in Completion 2025-10-06 11:10:41 -03:00
pedrocarlo
5a7390735d rename Completion functions 2025-10-06 11:07:06 -03:00
Nikita Sivukhin
926fd25cdd move examples to the top-level directory 2025-10-06 18:01:54 +04:00
Pekka Enberg
0b9a5f331c Merge 'docs: Explain BEGIN CONCURRENT' from Pekka Enberg
Reviewed-by: bit-aloo (@Shourya742)

Closes #3555
2025-10-06 16:30:46 +03:00
Pekka Enberg
41d909e1fb Merge 'MVCC: do checkpoint writes in ascending order of rowid' from Jussi Saurio
For insert-heavy checkpoints this gives a much higher chance of using
the balance-quick subalgorithm instead of the more complex and slower
balance-nonroot.

Closes #3589
2025-10-06 16:30:19 +03:00
Pekka Enberg
3ac923b892 Merge ' core/mvcc: filter out seek results where is not same table_id ' from Pere Diaz Bou
Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com>

Closes #3596
2025-10-06 16:20:35 +03:00
Pere Diaz Bou
aed255d2e6 core/mvcc: implement PartialOrd for RowId 2025-10-06 13:43:42 +02:00
Pere Diaz Bou
fc7e1639a0 core/mvcc: filter out seek results where is not same table_id 2025-10-06 13:29:10 +02:00
Pere Diaz Bou
b9b9831d17 core/mvcc: test seek with empty table 2025-10-06 13:28:51 +02:00
Jussi Saurio
fd9008f123 MVCC: do checkpoint writes in ascending order of rowid
For insert-heavy checkpoints this gives a much higher chance of using
the balance-quick subalgorithm instead of the more complex and slower
balance-nonroot.
2025-10-06 10:11:19 +03: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