Commit Graph

141 Commits

Author SHA1 Message Date
Pekka Enberg
9a1bd2112d Merge 'Run simulator under Miri' from Bob Peterson
This adds support for running the simulator under Miri to detect UB.
There are a few things to note about Miri and its limitations
- It has limited `libc` coverage, so it's not really possible to have
Miri help with `UringIO`/`UringFile` or `UnixIO`/`UnixFile`. That's a
big gap ☹️
- It **can** work for `GenericIO`/`GenericFile`, which only uses `std`
- It can't call external C libraries, so even using `sqlite` is out
(hence adding `--disable-integrity-check` to the simulator for Miri use)
- It runs on nightly, consequently there are a few new lints that don't
exist on turso's pinned version of rustc
Some questions I have about this MR
- I made `GenericFile::{lock_file,unlock_file}` noops so I could use
`GenericIO`. This isn't great, but if/when you update from Rust 1.88.0
to 1.89.0, `std::File::{lock,lock_shared,unlock}` will be stabilized and
available. Should I note that as a TODO or something?
- Previously, the sim runner shelled out to `git` to get stuff like the
current git hash and the repo directory. For Miri, that's out, and so is
`git2`. Unfortunately, `gix` is also out since it has a required
dependency that uses inline assembly, which Miri doesn't like. I wrote a
hacky shim that uses only std to look for `.git` and find the hash that
HEAD is pointing to. It doesn't deal with stuff like packed-refs or the
repo being a secondary one made with `git worktree`. I'm happy to
support that, but wanted to hear from maintainers before doing more
work.
Two UB occurrences I already found:
- `TursoRwLock::read` used `AtomicU64::compare_exchange_weak`, which is
(evidently) [allowed to spuriously fail](https://doc.rust-lang.org/std/s
ync/atomic/struct.AtomicU64.html#method.compare_exchange_weak) in
exchange for perf. Miri forces this behavior, which triggers trivial
read deadlocks even with zero readers/writers. I changed it to
`compare_exchange`, but I'm not an atomics expert.
- Uninitialized read in non-Unix
`core::storage::buffer_pool::arena::alloc`. This is a simple one,
resolved by using `std::alloc::alloc_zeroed` instead of
`std::alloc::alloc`
Moving forward, I'd be interested in potentially getting the tests to
run in Miri, too. `tokio` looks like a good example of a project with
partial coverage that runs it where they can. They have some extra test
config to allow as many as possible to run under Miri, with
appropriately scaled-down parameter values since Miri is super slow

Closes #3720
2025-10-14 09:26:55 +03:00
Bob Peterson
4d843804b7 Add --disable-integrity-check option to simulator
Miri can't execute sqlite via the FFI, so this needs to be configurable
2025-10-13 14:54:16 -05:00
pedrocarlo
fafbdbfa9d persist files in sim memory io for integrity check 2025-10-11 15:03:22 -03:00
pedrocarlo
b6f94b2fa1 remove dead code in sim 2025-10-09 17:25:04 -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
pedrocarlo
dc0d4e2dcb print diffs in assert tables 2025-10-03 02:01:14 -03:00
bit-aloo
460b87fdfb Refactor simulator logger initialization
- Changed `init_logger()` to return `anyhow::Result<()>`
- Removed deprecated usage of `with_ansi`
2025-10-02 19:18:33 +05:30
pedrocarlo
44c08c02d1 do not shadow interactions when generating the next plan, only after the interaction is ran 2025-09-23 21:57:06 -03:00
pedrocarlo
69d09bcf8c modify code to use runtime generation 2025-09-23 21:57:06 -03:00
pedrocarlo
c3cdb0e0fd add begin concurrent before each statement with mvcc 2025-09-20 11:52:15 -03:00
pedrocarlo
81cff3e3d7 fix shrinking to use a secondary index that points to the Property that generated the interactions 2025-09-17 10:49:24 -03:00
pedrocarlo
4d9e676f65 simplify run_simualtion signature + remove watch mode file as it shares logic with default run simulation logic 2025-09-17 10:49:24 -03:00
pedrocarlo
b98c22a90e run simulation on the total list of interactions to avoid recomputing whole vec of interactions on each loop + change state management in preparation for multiple connections change 2025-09-17 10:49:24 -03:00
pedrocarlo
961c0cd282 script to save JsonSchema for editor integration 2025-08-30 12:17:50 -03:00
pedrocarlo
61fa7546c1 fold some SimulatorOpts fields to Profile 2025-08-30 11:31:52 -03:00
pedrocarlo
962666831b read Profile file from path or use predefined profiles 2025-08-30 11:31:52 -03:00
pedrocarlo
06b923d0c1 adjust simulator to use correct trait signature 2025-08-30 11:31:52 -03:00
pedrocarlo
19d9003cd7 create profiles folder 2025-08-30 11:31:52 -03:00
pedrocarlo
bcd70488ae add sqlite integrity check back 2025-08-29 12:25:27 -03:00
pedrocarlo
8010b7d0c7 make simulator use sql_generation crate as dependency 2025-08-25 22:59:31 -03:00
PThorpe92
2810b5d8a2 Add --keep-files flag and force Drop of database in simulator to prevent issues with the Registry 2025-08-15 17:54:40 -04:00
pedrocarlo
0c9ecbc768 simulator should delete files after a successful run 2025-08-09 16:25:51 -03:00
alpaylan
0b3fb2ecdd Merge branch 'main' of https://github.com/tursodatabase/limbo 2025-07-13 11:10:52 -04:00
Nils Koch
828d4f5016 fix clippy errors for rust 1.88.0 (auto fix) 2025-07-12 18:58:41 +03:00
Mikaël Francoeur
ed2de42048 only output color on terminal 2025-07-11 10:57:01 -04:00
alpaylan
e28ad97ac7 cargo fmt and cargo clippy fixes 2025-07-11 03:35:32 -04:00
alpaylan
3a967f9127 remove rusqlite integrity check, sync generation with --experimental-indexes, move FaultyQuery to disabled by default 2025-07-11 03:35:02 -04:00
alpaylan
489602b095 updates to the oracle implementations for differential and doublecheck, add integrity check to the end of the simulation, run cargo clippy --fix 2025-07-11 01:22:40 -04:00
alpaylan
a7b5a2c435 Merge branch 'main' of https://github.com/alpaylan/limbo 2025-07-09 00:14:24 -04:00
alpaylan
44a2fa60a3 add union all cardinality preservation, start generating INSERT INTO t SELECT... queries, add integrity checks to the end of run_simulation 2025-07-09 00:14:13 -04:00
echoumcp1
c5d719dafa adding better shrinking and cli opts 2025-07-07 21:21:21 -04:00
alpaylan
ea9c67a950 generate joins and unions 2025-07-07 02:54:48 -04:00
alpaylan
0bce68b38d wip: add joins to the select 2025-07-06 14:46:38 -04:00
pedrocarlo
6dfd4700e9 simulator: disable all ansi encodings for debug print log file 2025-06-14 19:34:40 -03:00
Jussi Saurio
f7fa56ecfd Change integrity check failure to say 'simulation failed:'
our AWS nightly sim looks for a line 'simulation failed:' in the process
output to capture context for the github issues it creates.

if the sim passes otherwise but integrity check fails, then this log line
must also be present there, otherwise the aws sim will panic due to not finding
a suitable line.
2025-06-13 11:26:04 +03:00
pedrocarlo
83d72db901 better error messages + cleaner printing of file stats + tracing
instrumentation in `execute_interaction`
2025-06-11 11:32:45 -03:00
pedrocarlo
82538dbe8e add integrity_check to sim 2025-06-10 12:17:59 -03:00
pedrocarlo
f3ef60e1f1 use anyhow in simulator for lazily evaluated error context instead of eager evaluation with .or 2025-06-10 10:50:39 -03:00
Jussi Saurio
51e3a04668 simulator: add option to disable BugBase 2025-06-02 12:14:35 +03:00
Pere Diaz Bou
8ee7228c43 simulator: log to file too
most of the time debugging the log of a simulator run is spent reading
from a file for convinience. Let's just log to a file too.
2025-05-30 11:10:17 +02:00
Pere Diaz Bou
83db9be818 log seed creating plan 2025-05-30 11:04:19 +02:00
Pere Diaz Bou
d3495238c4 set default level info and log seed at startup 2025-05-30 11:02:05 +02:00
Pere Diaz Bou
8ec7e616b4 simulator: switch to tracing, run io.run_once and add update queries
* Without tracing crate we cannot log anything that happens in
limbo_core
* IO never ran in step loop inside simulator.
* Added update queries (which currently loop forever for some reason I'm
debugging).
2025-05-30 10:57:13 +02:00
alpaylan
e13b5bc698 fix min/max-tests bug 2025-04-11 15:33:32 -04:00
alpaylan
9d08693e8f add simulator subcommands 2025-04-11 14:10:12 -04:00
alpaylan
d4707fe391 add non-zero exit code in case of failures, remove the interactive initalization option in bug base for now, fix bugs in differential mode, add detailed information regarding runs to the bug base 2025-04-11 11:23:03 -04:00
alpaylan
64c2917e81 add bug base, refactor 2025-04-08 17:48:16 -04:00
Pekka Enberg
96175cccf7 cli: Add --experimental-mvcc option to enable MVCC 2025-03-06 10:16:42 +02:00
alpaylan
c133bbdd29 add differential testing against rusqlite 2025-02-11 14:13:14 -05:00
Aarni Koskela
eaea02c567 Fix a handful of typos 2025-02-09 18:08:29 +02:00