Skip to content

ENG-30396: materialized views over joins, and what lab builds #48 and #49 found (milestone 32) - #31

Closed
jwiebema1 wants to merge 9 commits into
ENG-30396-sqlancer-m31from
ENG-30396-sqlancer-m32
Closed

jwiebema1 wants to merge 9 commits into
ENG-30396-sqlancer-m31from
ENG-30396-sqlancer-m32

Conversation

@jwiebema1

Copy link
Copy Markdown

Milestone 32 of ENG-30396 (tracked in ENG-30581, epic ENG-30580 "SQL Housekeeping"): materialized views over joins, the second coverage gap milestone 30's measurement found; and what lab builds #48 and #49 found through them. Stacked on #30 (milestone 31), which is stacked on #29 to #1; review those first.

Why

Milestone 30's coverage run found that the engine's code for views over joins, MaterializedViewHandler, never ran. VoltDB keeps such a view up to date by running the view's query for each changed row, which is different code from the triggers that keep a view of one table up to date.

What it changes

Views over joins

  • A third of the views (gen/VoltDBViewGenerator) now read an inner join of two or three tables:
    • distinct tables (VoltDB's views have no self-join), with JOIN ... ON (VoltDB rejects outer joins in a view);
    • at most one partitioned table joined to replicated ones, or partitioned tables joined on their partitioning columns only: VoltDB keeps a view of partitioned tables only when every joined row is in one partition;
    • an ON condition that compares two columns of the same kind (=, <, <=, >, >= or <>), is a random predicate, or both;
    • a random WHERE clause a third of the time. Join views do not hit ENG-30583, which is about views of one table.
  • The VIEWS oracle changes one of the view's tables before it compares. The tables any view reads are tracked (getViewedTables()) for the other oracles' rules about views.
  • Workarounds while --avoid-known-bugs is true:
    • ENG-30529: a join view groups by columns with distinct names. The view is right, but its query run as a SELECT merges groups.
    • ENG-30664: an index on a table a view reads is never UNIQUE or ASSUMEUNIQUE.
    • ENG-30665: columns of different types in the join are compared with = or <> only.
    • ENG-12656: a VARBINARY column in the join is compared only with one of the same size.
    • ENG-30255: with a 16.0.0 mirror or an in-service upgrade from it, a join view does not group by a DECIMAL column.

Bug reproductions

Bugs found

Ticket Issue Workaround while --avoid-known-bugs is true
ENG-30664 Server crash. A view joins T with a partitioned table. T, holding a row, gets a UNIQUE index on its primary key's column, and the next INSERT into T kills the server: "Could not find Index with name I among {VOLTDB_AUTOGEN_IDX_PK_T_A}". The engine seems to keep one of the two identical indexes while the view's maintenance plan names the other. Needs 8 sites per host locally. Also on 16.0.0. Found by lab build #48's security run. Blocker for V16.1.0. An index on a table a view reads is not unique.
ENG-30665 Server crash. A view over a join of a partitioned table and a replicated one on T0.tinyint < T1.int, with an index on the TINYINT column created after the view. When a T1 value is below TINYINT's range, the view's maintenance reads T0 through the index with that key, which matches every row (ENG-30511). The next change kills the server: "MaterializedViewHandler ... went looking for a tuple in the view and expected to find it but didn't". Also on 16.0.0. Found by lab build #49's resize run, where an UPDATE of the replicated table killed two nodes at once and the cluster with them. Blocker for V16.1.0. Columns of different types are compared with = or <> only.
ENG-12656 (existing) Through a join view: the view's maintenance scans the other table's VARBINARY(n) index with a longer value, and the change fails with "Type VARCHAR can't be cast as VARBINARY". Found by lab build #49's upgrade run. VARBINARY columns are compared only with one of the same size.
ENG-30255 (existing, fixed after 16.0.0) A join view grouped by a NULL DECIMAL aborts a 16.0.0 server. Master is fixed, and views of one table do not abort. Lab build #48's kill run lost its 16.0.0 mirror to it. No DECIMAL grouping with a 16.0.0 mirror or upgrade.
ENG-30529 (existing) Found again through a join view's query: a multi-partition GROUP BY of two columns of the same name from different tables merges groups. Grouping columns have distinct names.

Coverage

In probe runs on the instrumented engine (master bf8602e3), MaterializedViewHandler.cpp went from 0% to 89.2% of its lines, and materializedviewhandlerinfo.cpp to 71.9%.

Testing

  • Lab build ENG-30396: STREAMSNAP checks streaming snapshots (milestone 51) #50 (matrix-systemtest-apprunner-sqlancer, branch job ENG-30396-sqlancer-nightly) ran this milestone's a86d159, with milestone 31, on 16.1.0-SNAPSHOT beside one node of 16.0.0. Every run was 45 minutes with all twenty-two oracles:

    Run Result
    Reproductions PASS: 75 still broken; ENG-30664 reported FIXED, the runner bug fixed above
    Kill (3 nodes k=1, a kill every 300 s) PASS: 8 kills, 8 rejoins, 53,569 queries
    Security (1 node) PASS
    Export (3 nodes k=2) PASS
    Resize (3 nodes k=1, every 120 s) PASS: 9 grows, 8 shrinks, 41,343 queries
    XDCR PASS: 474 databases compared after convergence, 0 conflicts
    Upgrade from 16.0.0 PASS: 3 of 3 nodes upgraded, 55,031 queries
    Crash (every 600 s) PASS: 4 crashes, 4 recoveries, 0 failed databases
  • Lab builds ENG-30396: XDCR with node failures, --xdcr with --kill-interval (milestone 49) #48 and ENG-30396: the JAVAPROC oracle, Java stored procedures (milestone 50) #49 ran earlier commits of this milestone and found the bugs above.

  • Local trials (macOS, master): VIEWS only, 5 minutes, 172,000 queries; all oracles, 8 minutes; 3 nodes k=1 with 4 kills and 4 rejoins; 1 node with security and the 16.0.0 mirror, 10 minutes, 9,338 queries; VIEWS, NOREC, TLP_WHERE and PQS after the ENG-30665 workaround, 5 minutes, 17,968 queries. All passed.

  • The reproductions ENG-30664, ENG-30665, ENG-30611, ENG-30595, ENG-30588 and ENG-30493 are reported still broken by the runner at the head of this branch.

  • mvn verify (formatter, TestVoltDBExpressionEvaluator) passes.

… (milestone 32)

Milestone 30's coverage run found the engine's handler for views over joins
(MaterializedViewHandler) never ran. A third of the views now read an inner
join: distinct tables, at most one partitioned table unless joined on the
partitioning columns, ON conditions that compare two columns, are random
predicates, or both, and a random WHERE clause a third of the time (join views
do not hit ENG-30583). The VIEWS oracle changes one of the view's tables before
it compares. Tables any view reads are tracked through getViewedTables().
While avoiding known bugs, a join view groups by columns with distinct names
(ENG-30529, found again through the view's query).
… primary key crashes the server) and ENG-30255 through join views on 16.0.0; workarounds and reproduction

Lab build #48 (milestone 32) lost two servers to the new views over joins:
- ENG-30664 (new): with a view over a join of T and a partitioned table, a UNIQUE index on T's primary key column,
  created while T has a row, crashes the server on the next INSERT into T ("Could not find Index with name ...").
  Master and 16.0.0, 8 sites per host. While avoiding known bugs, an index on a table a view reads is not unique.
- ENG-30255 (fixed after 16.0.0): a join view grouped by a NULL DECIMAL aborts a 16.0.0 server, the DIFF mirror.
  With a mirror or an in-service upgrade, join views do not group by DECIMAL.
- voltdb/repros/ENG-30664.sql (8 sites); README rows.
…4's check does more after the crashing INSERT

Lab build #49 reported ENG-30664 FIXED on Linux, where the same statements crash a server (macOS, and Linux in a
container): the INSERT can be answered before the server dies in the fragments after it, and the runner looked for
1 s. A crash reproduction is now watched for 10 s, and ENG-30664's check (now with a second index on the column, as
in the lab) inserts into both tables and reads the view after the INSERT.
… out-of-range key crashes the server); workaround and reproduction

Lab build #49's resize run lost two nodes at once: a view over a join of a partitioned and a replicated table on
TINYINT < INTEGER, with an index on the TINYINT column created after the view, and a key below TINYINT's range in
the maintenance's index scan (ENG-30511) left the view without a tuple it expected. Not the resize: one node crashes
the same way. While avoiding known bugs, columns of different types in a join view's condition are compared with = or
<> only. voltdb/repros/ENG-30665.sql; README.
… (ENG-12656)

Lab build #49's upgrade run: an INSERT into a join view's source table failed with "Type VARCHAR can't be cast as
VARBINARY": the view's maintenance scans the other table's index on its VARBINARY(1) column with a 2-byte value, the
existing ENG-12656 (a plain join query fails the same way). While avoiding known bugs, a join view's condition compares
VARBINARY columns only with one of the same size, as its partitioning-column joins already did.
…even when sqlcmd got its answers

Lab builds #49 and #50 reported ENG-30664 FIXED, yet the lab's own kit (16.1.0-SNAPSHOT-ENG-30396-sqlancer-nightly/2,
aarch64, in a container) crashes on the same statements: the server answers the INSERT, logs FATAL and takes long to
exit while it dumps core, and the runner only read the logs after a lost connection. For a "-- bug: crash"
reproduction, a crash line in the server's output now counts whether or not the connection was lost.
@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
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