Skip to content

ENG-30396: SQLancer milestone 6: PQS oracle with an expression evaluator - #6

Closed
jwiebema1 wants to merge 7 commits into
ENG-30396-sqlancer-m5from
ENG-30396-sqlancer-m6
Closed

jwiebema1 wants to merge 7 commits into
ENG-30396-sqlancer-m5from
ENG-30396-sqlancer-m6

Conversation

@jwiebema1

@jwiebema1 jwiebema1 commented Nov 5, 2026 •

Copy link
Copy Markdown

Milestone 6 of ENG-30396: the PQS (Pivoted Query Synthesis) oracle, fourth and last in the plan's list of oracles ("later, as it requires an expression evaluator in the provider"). Stacked on #5 (milestone 5), which is stacked on #4 to #1; review those first.

What it adds

The other oracles compare VoltDB with itself: a query against an equivalent rewrite of it. A comparison or function that VoltDB gets wrong the same way everywhere passes them. PQS checks VoltDB against values computed outside it, so it finds a different class of bugs: eight new ones during this milestone, including a node crash.

PQS (oracle/VoltDBPivotedQuerySynthesisOracle):

  1. Pivot row. It reads every row of the query's tables and picks one row of each. Partitioned tables are joined on their partitioning columns, so their rows share a partitioning value.
  2. Rectified predicates. It generates a WHERE predicate, and an ON condition for each joined replicated table. It evaluates each on the pivot row in Java and rewrites it to be TRUE there: p, NOT p or p IS NULL.
  3. Expressions. It adds up to three random expressions to the SELECT list, with their values on the pivot row.
  4. Check. The query fetches every column, so the pivot row must be among its rows, and the expressions must have the computed values on it.

The join types are TLP WHERE's: INNER, LEFT and FULL all return the pivot row. Rows are read and checked in Java, since SQLancer's tables are small. A query whose tables could produce more than 50,000 rows is skipped.

The evaluator (oracle/VoltDBExpressionEvaluator) follows VoltDB's execution engine, as probed against a server:

  • Integer arithmetic is BIGINT and truncates division toward zero.
  • DECIMAL keeps scale 12 and truncates multiplication and division toward zero.
  • FLOAT is IEEE double arithmetic.
  • Three-valued logic, exact VARCHAR comparison, and LIKE without escapes.
  • A string literal goes through UTF-8 as the driver sends it, so a lone surrogate becomes ?.

What it can't predict, it doesn't check:

  • Errors. VoltDB evaluates every operand, so an error anywhere fails the query.
  • NULL sentinel results.
  • DECIMAL mixed with FLOAT.
  • Ordered BOOLEAN comparisons (ENG-30493).

An unpredictable expression is left out of the SELECT list. An unpredictable predicate skips the check.

A failure reports the query, the pivot row, and the expected and actual values. --use-reducer works: the reproducer first checks that every table still holds its row of the pivot row. Checked on a known bug (ENG-30502), where it reduced the case to one CREATE TABLE and one INSERT.

Other changes

  • Generator:
    • A temporal comparison takes its operands from DATE alone or from TIMESTAMP alone (ENG-30545).
    • A concatenation's right operand is a one-character constant (ENG-30546).
    • There is no multiplication or division inside ABS (ENG-30550).
    • The constant generator never writes a subnormal FLOAT (ENG-30551) or the string '\N' (ENG-30552).
    • generateExpressionInDomain gives the SELECT list expressions whose operands come from one numeric or temporal domain, as a comparison's do.
  • README:
    • Status line: milestone 6.
    • A PQS section.
    • The milestone 6 bug table.
    • The unit test.
  • run-sqlancer.sh: the help lists every oracle. It had been stale since milestone 5.
  • Tests:
    • TestVoltDBExpressionEvaluator: 11 unit tests of the evaluator's semantics, with no server needed.
    • TestVoltDB: gains a PQS test.

Bugs found

Each has a minimal reproduction and is linked to ENG-30396. Each is avoided while --avoid-known-bugs is on (the default).

Ticket What Workaround
ENG-30545 (Major, wrong rows) Comparing a DATE with a TIMESTAMP converts the right operand to the left one's type. With the DATE on the left, the TIMESTAMP is truncated to its date. dt = ts is TRUE but ts = dt is FALSE for 2020-01-02 and 2020-01-02 12:00; BETWEEN is affected too. Found while checking the evaluator's semantics. Temporal comparisons use DATE operands alone or TIMESTAMP operands alone.
ENG-30546 (Major, wrong result) A concatenation whose result is empty is NULL at run time: v || v and CONCAT(v, v) with v = ''. Found by PQS in its first trial, on 3 of 4 threads. The right operand of || is never empty.
ENG-30547 (Major, wrong result) The planner folds + and - of integer constants in 32 bits: 2147483647 + 1 is NULL, and 2135068309 + 1293734779 is -866164208. A folded multiplication with a BIGINT operand is typed DECIMAL, so 7 / (2 * 3000000000) keeps a fraction (comment on the ticket). Found by PQS. PQS skips values that depend on such folded arithmetic.
ENG-30548 (Minor, wrong result) DECIMAL constant folding differs from run-time DECIMAL arithmetic: 1 / 3.0 folds to 0.3333, and folded multiplication rounds where the EE truncates. Found while checking the evaluator's semantics. None needed: no DECIMAL literals are generated while ENG-30521 is avoided.
ENG-30549 (Minor, wrong result) The planner folds string constant comparisons ignoring trailing spaces ('a' = 'a ' is TRUE), while the EE compares exactly. Found by PQS. PQS skips folded string comparisons that trailing spaces decide.
ENG-30551 (Critical, node crash) A subnormal FLOAT constant (such as 1.0E-309, written or folded from 0.28E0 / 1.79E308) in a statement that is not parameterized makes its plan fail to load ("JSON parse failure"). Running it again after any DDL crashes the node with SIGSEGV in ExecutorContext::cleanupAllExecutors. Found by PQS in the first 3-node acceptance run, where node 0 died 19 minutes in. Reproduced on one node in three statements. No subnormal FLOAT literals, and PQS never sends an expression of constants that folds to one.
ENG-30552 (Major, wrong result, lost data) The string literal '\N' in ad hoc SQL becomes NULL: INSERT stores NULL, and SELECT '\N' and the folded '\' || 'N' return NULL. Found by PQS in the second 3-node acceptance run. The constant generator never writes '\N', and PQS never sends an expression of constants equal to it.
ENG-30550 (Major, wrong result) ABS pushes its argument's type into the operands. ABS((b * 1) / 2) is 3.5 for BIGINT b = 7, and ABS((7 / i) - d) divides 7 by 2 as 3.5 when d is DECIMAL (comment on the ticket). Found by PQS in 5- and 10-minute trials. No multiplication or division inside ABS.

Testing

  • mvn verify -DskipTests passes: formatter, checkstyle, PMD and SpotBugs.

  • TestVoltDBExpressionEvaluator: 13 tests pass.

  • Trials, 1 node, 8 sites per host: each failure was one of the bugs above, worked around in the next commit before the next trial. Clean trials: 3 minutes (11,902 checks) and 10 minutes (37,609 checks).

  • With --avoid-known-bugs false: PQS fails within seconds on known bugs (ENG-30500, ENG-30502, ENG-30503), as expected.

  • Acceptance, 30 minutes each: 8 sites per host, PQS, --use-reducer, both on 4a74fb8 (the head, fbc25cf, changes only README text):

    Cluster Seed Checks Result
    3 nodes, k=1 20261216 79,113 PASS, no FATAL lines, no node down
    1 node 20261217 126,447 PASS, no FATAL lines
  • Earlier acceptance runs found bugs. Two earlier pairs each failed on 3 nodes:

    • The first, on 2dcf163 (seed 20261212), crashed node 0 (ENG-30551). Its 1-node run passed with 126,118 checks.
    • The second, on e766dbb (seed 20261214), found ENG-30552. Its 1-node run passed with 128,741 checks.
  • TestVoltDB's new PQS test runs only with VOLTDB_AVAILABLE=true against localhost:21212, like the others, so it was not run here.

Pivoted Query Synthesis: pick a row of each table, evaluate random predicates
on it in Java, rewrite them to be TRUE for it, and check that the query returns
the row, with the evaluated values of random expressions in its SELECT list.

The evaluator models VoltDB's EE semantics as probed (BIGINT integer
arithmetic, DECIMAL truncation at scale 12, IEEE FLOAT, three-valued logic,
LIKE without escapes) and skips what it cannot predict: errors, NULL
sentinels, DECIMAL/FLOAT mixing.

Known bugs avoided while --avoid-known-bugs is on:
- ENG-30545: temporal comparisons draw operands from DATE or TIMESTAMP only
- ENG-30546: a concatenation's right operand is a non-empty constant
- ENG-30547: folded integer sums outside INTEGER's range are unpredictable
- ENG-30549: folded string comparisons decided by trailing spaces are
  unpredictable
README: the PQS oracle, its evaluator, and the bugs found while building it
(ENG-30545 to ENG-30550). run-sqlancer.sh lists every oracle in its help.
TestVoltDB gains a PQS test.
A subnormal FLOAT constant in a statement that is not parameterized makes its
plan fail to load, and re-running it after DDL crashes the node. The constant
generator never writes one, and PQS never sends an expression of constants
that folds to one.
The literal '\N' reaches VoltDB's EE as NULL. The constant generator never
writes it, and PQS never sends an expression of constants equal to it.
@jwiebema1

Copy link
Copy Markdown
Author

Superseded by #51, which combines every ENG-30396 PR of this repo into one. This PR's branch is kept, and its description still has this milestone's details and lab results.

@jwiebema1 jwiebema1 closed this Nov 18, 2026
@jwiebema1
jwiebema1 deleted the ENG-30396-sqlancer-m6 branch November 25, 2026 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant