Commit Graph

4887 Commits

Author SHA1 Message Date
Diego Reis
3a17bf7186 bind/java: Throw in case of yet unsupported Linux on arm64 2025-06-04 10:41:19 -03:00
Diego Reis
b50dcd493a bind/java: Improve TODO comment 2025-06-03 10:37:46 -03:00
Diego Reis
4589cd6916 bind/java: Add support for building on Linux 2025-06-02 16:18:11 -03:00
Jussi Saurio
ea301de726 Merge 'Pass input string to translate function' from Pedro Muniz
In preparation for `CREATE VIEW`, we need to have the original sql query
that was used to create the view. I'm using the scanner's offset to
slice into the original input, trimming the newlines, and passing it to
the translate function.

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

Closes #1621
2025-06-02 17:43:11 +03:00
Jussi Saurio
5f586b7b24 Merge 'Small tracing enhancement' from Pedro Muniz
Instrument trace_insn to debug print its the stack pc and instruction.
Also, disable rustyline logs for the CLI as it is too noisy to work
with.

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

Closes #1635
2025-06-02 17:41:52 +03:00
Jussi Saurio
20555bce0a Merge 'Adjust write cursors for delete to avoid opening more than once. ' from Pedro Muniz
We were opening Write cursors inside of the rewind loop, which meant
that we were opening the same cursor multiple times per iteration. Also,
in this case, we need to open all indexes before the loop starts, and
avoid opening the same cursor again. While I was trying to debug this, I
also added instrumentation to some functions, so that I could track
where the instructions were being emitted. This helped me a lot. The
`#[instrument]` macro creates a span for the particular function, which
enables us to examine the path our functions are taking when any log is
emitted. Lastly, I fixed an explain bug, where it was unwrapping a None
`CursorKey` when opening the `sqlite_schema` table.

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

Closes #1640
2025-06-02 17:41:19 +03:00
Pekka Enberg
e6cfeb9552 Merge 'simulator: add option to disable BugBase' from Jussi Saurio
we will soon run the sim on AWS where we don't need bugbase

Closes #1644
2025-06-02 12:45:15 +03:00
Jussi Saurio
51e3a04668 simulator: add option to disable BugBase 2025-06-02 12:14:35 +03:00
pedrocarlo
9dc6638313 cleaner approach for opening indexes 2025-06-02 01:13:14 -03:00
pedrocarlo
c9c73f2497 fix explain panicking on None CursorKey 2025-05-31 01:19:26 -03:00
pedrocarlo
bc563266b3 add instrumentation to more functions for debugging + adjust how cursors are opened 2025-05-30 20:35:50 -03:00
pedrocarlo
0757109676 instrument trace_insn 2025-05-30 11:33:22 -03:00
pedrocarlo
08f415370c remove rustyline traces from cli 2025-05-30 11:33:22 -03:00
pedrocarlo
b73200de86 pass input string to translate function 2025-05-30 11:20:36 -03:00
Pere Diaz Bou
09e6bb5438 Merge 'Convert u64 rowid to i64' from Pere Diaz Bou
Rowids can be negative, therefore let's swap to i64
Fixes: #1631

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

Closes #1632
2025-05-30 14:46:07 +02:00
Pere Diaz Bou
d4f1b8e068 update i64::MAX comment 2025-05-30 14:02:05 +02:00
Pere Diaz Bou
da4190a23e Convert u64 rowid to i64
Rowids can be negative, therefore let's swap to i64
2025-05-30 13:07:31 +02:00
Pekka Enberg
0fbff54b90 Merge 'simulator: switch to tracing, run io.run_once and add update queries' from Pere Diaz Bou
* 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).

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

Closes #1627
2025-05-30 12:52:34 +03:00
Pekka Enberg
aa637d5ae1 antithesis: Build workload image with antithesis profile
...need for stuff like instrumentation to work.
2025-05-30 12:19:12 +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
1ca67d0092 remove dumb log 2025-05-30 11:03:09 +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
Pekka Enberg
48e0441fae Update README.md 2025-05-30 09:45:41 +03:00
Jussi Saurio
819a6138d0 Merge 'Fix: aggregate regs must be initialized as NULL at the start' from Jussi Saurio
Again found when fuzzing nested where clause subqueries:
Aggregate registers need to be NULLed at the start because the same
registers might be reused on another invocation of a subquery, and if
they are not NULLed, the 2nd invocation of the same subquery will have
values left over from the first invocation.

Reviewed-by: Preston Thorpe (@PThorpe92)

Closes #1614
2025-05-30 09:39:37 +03:00
Jussi Saurio
5632a6046e Merge 'Fix: allow DeferredSeek on more than one cursor per program' from Jussi Saurio
Found while fuzzing nested subqueries. Since subqueries result in nested
plans, it quickly revealed that there can be multiple `DeferredSeek`
instructions issued for different cursors, but our `ProgramState` only
supported one at a time.

Closes #1610
2025-05-30 09:39:23 +03:00
Jussi Saurio
0d91971639 Merge 'Use tempfile in constraint test' from Jussi Saurio
Closes #1618
2025-05-30 09:38:29 +03:00
Jussi Saurio
d52a9a635c fix: use tempfile as db path in constraint.py 2025-05-29 21:03:10 +03:00
Jussi Saurio
d18ab34193 Fix: dont pollute testing.db in insert tests 2025-05-29 20:51:29 +03:00
Jussi Saurio
482eb4aa9a Merge 'Refactor: make clear distinction between 'joined tables' and 'tables referenced from outer query scopes'' from Jussi Saurio
**Beef:** we need to distinguish between references to tables in the
current query scope (CTEs, FROM clause) and references to tables from
outer query scopes (inside subqueries, or inside CTEs that refer to
previous CTEs). We don't want to consider 'tables from outside' in the
join order of a subquery, but we want the subquery to be able to
_reference_ those tables in e.g. its WHERE clause.
This PR -- or at least some sort of equivalent of it -- is a requirement
for #1595.
---
This PR replaces the `Vec<TableReference>` we use with new data
structures:
- TableReferences struct, which holds both:
     - joined_tables, and
     - outer_query_refs
- JoinedTable:
     - this is just a rename of the previous TableReference struct
- OuterQueryReference
     - this is to distinguish from JoinedTable those cases where
       e.g. a subquery refers to an outer query's table, or a CTE
       refers to a previous CTE.
Both JoinedTable and OuterQueryReference can be referred to by
expressions,
but only JoinedTables are considered for join ordering optimization and
so
forth.
These data structures are then used everywhere, which resulted in a lot
of changes.

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

Closes #1580
2025-05-29 20:45:33 +03:00
Jussi Saurio
f8257df77b Fix: aggregate regs must be initialized as NULL at the start 2025-05-29 18:44:53 +03:00
Pekka Enberg
5af837d50a Merge 'antithesis-tests: Don't fail tests on unique constraint violation' from Pekka Enberg
Unique constraint violation is not an error.

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

Closes #1612
2025-05-29 17:27:47 +03:00
Pere Diaz Bou
d8e636ec45 Merge 'Remove frame id from key' from Pere Diaz Bou
After reading sqlite a bit, it isn't needed because we have RWlock for
each table in the database file.

Closes #1569
2025-05-29 16:18:45 +02:00
Pekka Enberg
1962990506 antithesis-tests: Don't fail tests on unique constraint violation
Unique constraint violation is not an error.
2025-05-29 16:10:14 +03:00
Jussi Saurio
69133b3b2e Fix: allow DeferredSeek on more than one cursor per program 2025-05-29 16:05:47 +03:00
Pere Diaz Bou
968eeea75d Merge 'add stress test with 1 thread 10k iterations to ci' from Pere Diaz Bou
Add simple stress test run with 10k iteration to test `Delete`, `Update`
and `Insert` together.

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

Closes #1585
2025-05-29 14:16:56 +02:00
Pere Diaz Bou
dd15b7df7f remove dumb comment from pagecachekey 2025-05-29 14:12:16 +02:00
Pere Diaz Bou
93161e9fce remove lru size > 0 check on page cache fuzz 2025-05-29 14:12:16 +02:00
Pere Diaz Bou
37e834b092 remove unnecessary test 2025-05-29 14:12:16 +02:00
Pere Diaz Bou
44007075d9 remove frame_id from PageCacheKey
After reading sqlite a bit, it isn't needed because we have RWlock for
each table in the database file.
2025-05-29 14:12:16 +02:00
Pekka Enberg
1653bfb2b3 Merge 'Fix stress test to ignore unique constraint violation' from krishna sindhur
This should ignore unique constraint violation errors during the stress
test.

Closes #1606
2025-05-29 14:59:34 +03:00
krishna sindhur
4b66bcb2a7 fix: stress test will ignore unique constraint violation 2025-05-29 15:11:43 +05:30
Jussi Saurio
211b511189 Fix join optimizer tests 2025-05-29 11:44:56 +03:00
Jussi Saurio
cc405dea7e Use new TableReferences struct everywhere 2025-05-29 11:44:56 +03:00
Jussi Saurio
3d42f85c98 tests/python/writes: use tempfile instead of permanent file 2025-05-29 11:23:50 +03:00
Jussi Saurio
124b38a262 plan.rs: add new datastructures
- TableReferences struct, which holds both:
     - joined_tables, and
     - outer_query_refs

- JoinedTable:
     - this is just a rename of the previous TableReference struct

- OuterQueryReference
     - this is to distinguish from JoinedTable those cases where
       e.g. a subquery refers to an outer query's table, or a CTE
       refers to a previous CTE.

Both JoinedTable and OuterQueryReference can be referred to by expressions,
but only JoinedTables are considered for join ordering optimization and so
forth.

This commit does not compile.
2025-05-29 11:03:09 +03:00
Jussi Saurio
e59c1ac985 tests/compat: use tempfiles for all empty dbs the tests open 2025-05-29 11:01:37 +03:00
Jussi Saurio
7ededb8b97 Merge 'Fix ProgramBuilder::cursor_ref not having unique keys' from Jussi Saurio
Currently we have this:
`program.alloc_cursor_id(Option<String>, CursorType)`
where the `String` is the table's name or alias ('users' or 'u' in the
query).
This is problematic because this can happen:
`SELECT * FROM t WHERE EXISTS (SELECT * FROM t)`
There are two cursors, both with identifier 't'. This causes a bug where
the program will use the same cursor for both the main query and the
subquery, since they are keyed by 't'.
Instead introduce `CursorKey`, which is a combination of:
1. `TableInternalId`, and
2. index name (`Option<Arc<Index>>` -- in case of index cursors.)
This should provide key uniqueness for cursors:
`SELECT * FROM t WHERE EXISTS (SELECT * FROM t)`
here the first 't' will have a different `TableInternalId` than the
second `t`, so there is no clash.
---
These `CursorKey`s are only required when the program needs to retrieve
the cursor ID later:
`program.resolve_cursor_id(key)`
So, there are now two methods for allocating cursors:
`program.alloc_cursor_id_keyed(key, cursor_type); // needs to be
retrieved later with same key`
`program.alloc_cursor_id(cursor_type); // does not need to be retrieved
later`

Reviewed-by: Preston Thorpe (@PThorpe92)

Closes #1604
2025-05-29 10:53:24 +03:00
Jussi Saurio
592ba41137 Add assertion forbidding duplicate cursor keys 2025-05-29 01:04:45 +03:00