Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 74 additions & 1 deletion src/sqlancer/voltdb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ A SQLancer provider for [VoltDB](https://www.voltactivedata.com/), developed for
VoltDB schemas, both replicated and partitioned tables, fills them with single-row inserts, upserts, updates and deletes, and runs SQLancer's oracles
against them through the VoltDB JDBC driver.

**Status: milestone 49.** The provider creates schemas and data and runs these logic-bug oracles: NoREC (the default,
**Status: milestone 50.** The provider creates schemas and data and runs these logic-bug oracles: NoREC (the default,
milestone 2), TLP WHERE (milestone 3), TLP DISTINCT, TLP HAVING and TLP AGGREGATE (milestone 5), PQS (milestone 6), and
PARAMS, literals against JDBC parameters (milestone 8). Since milestone 9 each database's rows are also updated,
upserted and deleted before the oracles run. Since milestone 10 each database also has materialized views, which the
Expand Down Expand Up @@ -65,6 +65,8 @@ Since milestone 47 the HTTP target sends form pairs by POST, PUT or GET, signed
Since milestone 48 every other node failure is a graceful `voltadmin stop`, and every other crash a `voltadmin shutdown
--save`; see [Graceful stops and shutdowns](#graceful-stops-and-shutdowns-milestone-48).
Since milestone 49 `--xdcr` runs can kill nodes too; see [XDCR with node failures](#xdcr-with-node-failures-milestone-49).
Since milestone 50 the JAVAPROC oracle compiles Java stored procedures, compound ones included, loads them with
`@UpdateClasses` and checks what they return and leave; see [The JAVAPROC oracle](#the-javaproc-oracle).
`SMOKE`, from
milestone 1, only reads every table and checks that the queries succeed. `voltdb/run-sqlancer.sh` (milestone 4) starts a
cluster, runs SQLancer against it and saves the results. A nightly lab job (milestone 7) runs it against master's kit;
Expand Down Expand Up @@ -1346,6 +1348,74 @@ and 32 user changes refused. In run-coverage.sh's 10-minute security run, agains
(from 19), `SetYamlConfiguration` 294 of 396 (from 173), `YamlUtils.PropertyParser` 56 of 68 (from 34); security as a
whole 26.3% of its lines (from 23.4%). The rest is mostly LDAP and Kerberos, which need servers of their own.

## The JAVAPROC oracle

Milestone 50. Every procedure the other oracles create is one SQL statement in DDL, so milestone 49's coverage found
the rest of VoltDB's procedure support never run: compound procedures (`CompoundProcedureRunner`, 0 of 180 lines),
`@UpdateClasses` and its checks (`UpdateClassesAcceptancePolicy`, 2 of 23), the procedure compiler's class paths
(`ProcedureCompiler`, 103 of 467), and the multi-batch, abort and expectation paths of `ProcedureRunnerImpl`.

Each JAVAPROC check writes the Java source of four classes over its own table, `XJ_<db>` (partitioned on k, no
database's), compiles them in SQLancer's JVM (`javax.tools`) against the kit's jars, which run-sqlancer.sh passes as
`--procedure-classpath` (`lib/volt-procedure-api-*.jar`, `voltdb/voltdb-*.jar`, `voltdb/voltdbclient-*.jar`), loads them
with `@UpdateClasses`, and creates the procedures `FROM CLASS`:

- `JPS_<db>_<n>`, single-partition on k: inserts its rows for k in batches of 1 to 5 (`voltExecuteSQL()` per batch,
`EXPECT_SCALAR_MATCH(1)` on each insert, a column from `getSeededRandomNumberGenerator()`, which k-safe replicas must
agree on), reads them back (`EXPECT_ONE_ROW`), and returns its class's version, the count, the sum and
`getUniqueId()`, with an app status; or, by its mode, then aborts (`VoltAbortException`, USER_ABORT), throws
(UNEXPECTED_FAILURE), fails an expectation (`EXPECT_EMPTY`, USER_ABORT), or inserts a duplicate key
(GRACEFUL_FAILURE);
- `JPM_<db>_<n>`, multi-partition: the same over 2 to 7 keys, so on several partitions in one transaction;
- `JPC_<db>_<n>`, compound (`CREATE COMPOUND PROCEDURE`): its first stage calls JPS for 1 to 4 keys, the last one
failing in a third of the calls, and its second stage, by its mode, completes with the sum of the counts (or aborts
if a call failed), completes with a table, throws `CompoundProcAbortException` (COMPOUND_PROC_USER_ABORT) or another
exception (UNEXPECTED_FAILURE), returns without completing ("end of stage list reached"), queues one more call and
completes, so that the call is never sent, or sets the app status and completes; or the procedure sets up no stages,
calls itself (refused: "nested call"), or queues more calls than a stage may (10);
- `JPN_<db>_<n>`, a non-transactional procedure class (`VoltNonTransactionalProcedure`), which VoltDB creates procedures
from only in its own tests.

Each call writes keys no other call wrote, so the rows it must leave are known: all of them when it succeeds, none when
it fails, its transaction rolled back whole. A compound procedure is not one transaction: the rows of each JPS call it
made that succeeded stay, whatever the compound procedure returns, and a call queued in the stage that completed must
leave no row. When a node failure interrupts a call (in a kill, crash, resize or upgrade run), it may or may not have
committed, but it must have committed whole: all its rows, on every partition, or none; JAVAPROC checks that, then
skips the rest of the check.

Then one of:

1. the classes replaced by a new version (`@UpdateClasses` again), which the next call must run;
2. the class of a procedure in use removed, which must be refused ("cannot be removed, it is being used by procedure");
3. a class whose static initializer throws loaded, which must be refused, and not listed by `@SystemCatalog CLASSES`;
4. a procedure created from a class of the wrong kind, which must be refused: `CREATE PROCEDURE` from JPN or JPC, or
`CREATE COMPOUND PROCEDURE` from JPS;
5. a procedure partitioned on a parameter its class does not have, which must be refused;
6. nothing.

In the end the procedures are dropped and the classes removed, and `@SystemCatalog CLASSES` must no longer list them.
`@UpdateClasses` also loads and removes the classes on the mirror and the XDCR peer, where the provider repeats the
DDL; the calls and their rows are on this cluster only. At exit JAVAPROC prints its checks, the calls checked by kind,
the failures checked, the calls a node failure interrupted, the classes replaced and the class changes refused; the
summary has the line. Without `--procedure-classpath`, or on a JRE without a compiler, it skips every check.

A user change by `@SetYamlConfiguration` that races an `@UpdateClasses` reaches the deployment but not the catalog, so
a removed user still logs in (ENG-30710). While avoiding known bugs, JAVAPROC's `@UpdateClasses` calls hold the lock
that LOGIN's and CONFIG's checks hold, so classes change only between them. A classes change also restarts a task that
`ON ERROR STOP` stopped (ENG-30711), so they wait for TASK's checks too.

In local 90- to 300-second trials (JAVAPROC alone on 1 node; with TASK and STATS on 3 nodes with a kill every 60 s;
beside XDCR; beside DIFF with a 16.0.0 mirror) every check passed: 48 to 78 checks and 191 to 309 calls per trial, the
mirror and the XDCR peer creating the same procedures. In lab build #64's 30-minute kill run: 213 checks, 833 calls
(362 single-partition, 240 multi-partition, 231 compound), 346 failures checked, 38 classes replaced, 137 class changes
refused; in its upgrade run, from 16.0.0 in service: 243 checks, 970 calls. Its security run found ENG-30710 (LOGIN's
removed users logging in), which JAVAPROC now avoids; the security run of build #65 then found ENG-30711 (TASK's stopped
tasks restarted), which it avoids as well. In run-coverage.sh's 10-minute kill run, against the best of milestones 44 to 49: `CompoundProcedureRunner`
143 of 183 lines (from 0), `VoltCompoundProcedure` 31 of 35 (from 0), `ProcedureCompiler` 296 of 477 (from 108),
`UpdateApplicationBase` 249 of 378 (from 193), `NTProcedureService` 187 of 236 (from 137), `ClassMatcher` 32 of 84
(from 7), `CreateProcedureFromClass` 27 of 39 (from 5), `UpdateClassesAcceptancePolicy` 16 of 23 (from 2),
`InMemoryJarfile` 173 of 269 (from 146); 813 lines more in 38 classes.

## The STREAMS oracle

A stream cannot be read, so STREAMS puts each row into a stream and into a shadow table with the same columns, and
Expand Down Expand Up @@ -1964,6 +2034,9 @@ The bugs below were found in milestones 43, 46, 47 and 48.
| ENG-30696 | DDL fails with "Unable to find reference for catalog item" while `voltadmin stop` takes a node out: the stopping node verifies catalog updates it no longer applies. Lab build #56's upgrade run, on 16.0.0; not reproduced locally. Major. | The error counts as a node failure (VoltDBErrors). |
| ENG-30704 | A node stopped with `voltadmin stop` sometimes logs FATAL partition detection ("fewer than half of the previous servers") after it has shut down, as the survivors hang up on it before its JVM exits. Milestone 48's graceful stops, under load only; no reliable reproduction. Minor. | FATAL lines a stopped node logs after its shutdown are not counted (`chaos.excluded`). |
| ENG-30705 | A task that `ON ERROR STOP` has stopped runs again after the node that ran it fails: the node that takes over starts its scheduler again (RUNNING) and runs the procedure once more. Found by TASK in lab build #61's kill run; `repros/ENG-30705.sh`; 16.0.0 too. Major. | While `--avoid-known-bugs` is true and nodes fail, TASK does not check the state of a task stopped by an error (the row counts still are). |
| ENG-30708 | During an elastic join, the join's own index snapshot failed on some partitions ("Elastic streaming was invoked without proper activation", "Table streamer has no streams to serialize more"), and the join stayed at "Building index for data migration"; the next command-log truncation snapshot was refused by the engine ("COW context activation is not allowed while elastic indexing is in progress") and every original node crashed ("Failed to activate snapshot stream"), losing the cluster. Found by run-coverage.sh's resize run (milestone 50), once in two runs of the same seed; not reduced: snapshot saves, truncation snapshots and table swaps during a join did not reproduce it alone. Blocker. | None: a resize run can fail with FATAL lines. |
| ENG-30710 | A user removed by `@SetYamlConfiguration` (`.users[name]=null`) still logs in when an `@UpdateClasses` runs at the same time: `@GetYamlConfiguration` no longer lists the user, but the update applies with the catalog unchanged (`securityChange=false`), so authentication keeps the user until the next catalog change. 16.0.0 too. Found by LOGIN beside JAVAPROC (milestone 50) in lab build #64's security run; `repros/ENG-30710.sh` (with `repros/users/RemovedUserRepro.java`) reproduces it at the first user. Critical. | While `--avoid-known-bugs` is true, JAVAPROC's `@UpdateClasses` calls hold the lock LOGIN and CONFIG share. |
| ENG-30711 | `@UpdateClasses` restarts a task that `ON ERROR STOP` stopped: with classes changed, `TaskManager` recreates every task's handler, the stopped one included, which shows RUNNING and runs its procedure again. An ordinary DDL change does not. 16.0.0 too. Found by TASK beside JAVAPROC (milestone 50) in lab build #65's security run; `repros/ENG-30711.sh`. Major. | While `--avoid-known-bugs` is true, TASK's checks and JAVAPROC's `@UpdateClasses` calls exclude each other (a read-write lock). |

The bugs below were found in lab build #53 and in milestone 41.

Expand Down
3 changes: 3 additions & 0 deletions src/sqlancer/voltdb/VoltDBOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ public class VoltDBOptions implements DBMSSpecificOptions<VoltDBOracleFactory> {
@Parameter(names = "--mirror", description = "Comma-separated host:port client addresses of a second cluster, normally running another VoltDB version: every statement that changes the database is repeated on it, and the DIFF oracle compares the two clusters' rows for the same query")
public String mirror;

@Parameter(names = "--procedure-classpath", description = "The VoltDB jars (colon-separated) that Java stored procedures compile against (run-sqlancer.sh passes the kit's): the JAVAPROC oracle compiles its procedure classes with them; without it, JAVAPROC does nothing")
public String procedureClasspath;

@Parameter(names = "--servers", description = "Comma-separated host:port client addresses of every node; SQLancer connects to all of them, so it keeps working while any one node is down (used instead of --host and --port)")
public String servers;

Expand Down
12 changes: 12 additions & 0 deletions src/sqlancer/voltdb/VoltDBOracleFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import sqlancer.voltdb.oracle.VoltDBDurabilityOracle;
import sqlancer.voltdb.oracle.VoltDBGeographyOracle;
import sqlancer.voltdb.oracle.VoltDBImportOracle;
import sqlancer.voltdb.oracle.VoltDBJavaProcedureOracle;
import sqlancer.voltdb.oracle.VoltDBLimitOracle;
import sqlancer.voltdb.oracle.VoltDBLoginOracle;
import sqlancer.voltdb.oracle.VoltDBParameterOracle;
Expand Down Expand Up @@ -263,6 +264,17 @@ public TestOracle<VoltDBGlobalState> create(VoltDBGlobalState globalState) {
return new VoltDBLoginOracle(globalState);
}
},
/**
* Java stored procedures (milestone 50): single-partition, multi-partition and compound procedure classes compiled
* and loaded with @UpdateClasses return what they wrote, roll back whole when they fail, run the new version once
* replaced, and are refused what VoltDB must refuse.
*/
JAVAPROC {
@Override
public TestOracle<VoltDBGlobalState> create(VoltDBGlobalState globalState) {
return new VoltDBJavaProcedureOracle(globalState);
}
},

/**
* Permissions, with --security: the users reader (SQLREAD) and writer (SQL) may run what their roles allow and
Expand Down
Loading