Skip to content
Merged
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
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@ tokio-util = { version = "0.7", features = ["compat"] }
# transactions through the async driver directly — same crate the lib uses.
mongodb = "3.9.1"
futures-util = "0.3"
mysql_common = { version = "0.37", default-features = false, features = ["binlog"] }

[patch.crates-io]
mysql_common = { git = "https://github.com/rivet-lab/rust_mysql_common", rev = "a660b506c230efe91a31d0421e11c7f373533df9" }

[[bench]]
name = "hot_paths"
Expand Down
1 change: 1 addition & 0 deletions changelog.d/fix-mysql-binlog-time-fraction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- **A MySQL CDC row with a negative `TIME(1)` or `TIME(2)` value that has a fraction was decoded wrongly or crashed the run (TF-1).** The binlog decoder in `mysql_common` 0.37.3 subtracted from an unsigned fraction byte: a debug build panicked with `attempt to subtract with overflow`, and a release build wrapped to a duration of about 625 hours. The row of ANY table in the binlog could trigger it, captured or not, because rivet decodes every row event it reads. **Now** the build uses a patched `mysql_common` (the fix is submitted upstream as blackbeam/rust_mysql_common#200 and the patch is dropped once it is released), and `-00:00:00.50` is read as `-00:00:00.500000`. The fix ships in the release binaries and the Docker image; `cargo install rivet-cli` from crates.io builds against the unpatched `mysql_common` 0.37.3 (cargo drops `[patch]` when it packages a crate) and gets the fix only once upstream releases it. **What to do:** a stream or snapshot-plus-stream table with a `TIME(1)` or `TIME(2)` column that held negative values with a fraction before the upgrade may hold wrong text in a `string` column delivered by an earlier release; re-run its `initial: snapshot` leg (or a one-off `mode: full` export of the table) to replace those rows. Other TIME precisions and positive values were never affected.
3 changes: 2 additions & 1 deletion deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,5 @@ skip = [
unknown-registry = "deny"
unknown-git = "deny"
allow-registry = ["https://github.com/rust-lang/crates.io-index"]
allow-git = []
# 2026-11-04: the mysql_common fork pins a one-line fix for a negative TIME(1)/(2) binlog fraction (upstream blackbeam/rust_mysql_common#200); drop this entry and the [patch] with the upstream release.
allow-git = ["https://github.com/rivet-lab/rust_mysql_common"]
3 changes: 0 additions & 3 deletions dev/release_oracle/known_red.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,6 @@ def _open(cell: str, symptom: str, reason: str) -> KnownRed:
_open("live_stop_class::open_defect_an_mssql_read_blocked_past_its_lock_timeout_exits_retryable",
"assertion `left == right` failed: a lock wait that timed out clears when the lock does: retryable",
"MT-F-F (seam stop-class, 2026-11-04): MSSQL error 1222 (lock request time out) reaches the stop as a stringified SOURCE_QUERY_FAILED whose text the retry classifier does not know, so a read that timed out on a held lock exits 1 where the same wait on MySQL (1205) exits 2. Opened 2026-11-04; closes with fix/stop-class-by-code"),
_open("live_cdc_mbt::open_defect_mysql_cdc_negative_time_fraction_matches_the_snapshot",
"assertion `left == right` failed: stream differs from the source on negative TIME(1)/TIME(2) with a fraction",
"TF-1 (consolidated-2026-11-03 section 2): mysql_common 0.37.3 binlog/misc.rs:35-39 subtracts 0x100 from a u32 fraction for a negative TIME(1)/TIME(2) with a fraction, so a debug rivet panics and a release rivet writes 625:04:19.277216 for -00:00:00.50 in a string column; a row of any table in the binlog panics every MySQL CDC run that reads it. Opened 2026-11-04; closes with fix/mysql-binlog-time-fraction"),
KnownRed("upgrade[oracle/cdc-load]: cycle1/load: prev exit 1 [RIVET_LOAD_BLOCK_MISSING]: Error: [RIVET_LOAD_BLOCK_MISSING] config has no top-level `load:` block — add `load: { target, ... }` to load into a warehouse",
_ORACLE_CDC_LOAD,
_EXPIRES),
Expand Down
24 changes: 24 additions & 0 deletions dev/seeded/mysql-binlog-negative-time-fraction/shared.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -200,9 +200,6 @@
futures-util = "0.3"
mysql_common = { version = "0.37", default-features = false, features = ["binlog"] }

-[patch.crates-io]
-mysql_common = { git = "https://github.com/rivet-lab/rust_mysql_common", rev = "a660b506c230efe91a31d0421e11c7f373533df9" }
-
[[bench]]
name = "hot_paths"
harness = false
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2755,7 +2755,8 @@
[[package]]
name = "mysql_common"
version = "0.37.3"
-source = "git+https://github.com/rivet-lab/rust_mysql_common?rev=a660b506c230efe91a31d0421e11c7f373533df9#a660b506c230efe91a31d0421e11c7f373533df9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0f27695f286b461da077b8c2f72f47feaa04ce3c3f9c0976257410e90e21208a"
dependencies = [
"base64 0.22.1",
"bitflags 2.13.2",
16 changes: 16 additions & 0 deletions dev/seeded/seeds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3258,6 +3258,22 @@ seeds:
na: "a MongoDB change row is two text cells, and the MySQL cell fix does not run"
oracle:
na: "Oracle has no TIME type, and the MySQL cell fix does not run"
- name: mysql-binlog-negative-time-fraction
class: "a dependency's decoder of a binary wire value mis-reads a sign-and-fraction encoding at the edge of its range, so the stream leg of one engine delivers or crashes on a value the snapshot leg of the same engine reads as stored"
history: "2026-11-04 - TF-1: mysql_common 0.37.3 subtracted 0x100 from a u32 fraction byte for a negative MySQL TIME(1)/TIME(2) with a fraction, so a debug rivet panicked and a release rivet read about 625 hours; closed by the rivet-lab/rust_mysql_common pin, the seed removes the pin"
scope: source
patch: mysql-binlog-negative-time-fraction/shared.patch
engines:
postgres:
na: "a PostgreSQL `time` is a time of day and is never negative; the MySQL binlog decoder does not run"
mysql:
cells: [mysql_cdc_negative_time_fraction_matches_the_snapshot]
mssql:
na: "a SQL Server `time` is a time of day and is never negative; the MySQL binlog decoder does not run"
mongo:
na: "a MongoDB change row is two text cells; the MySQL binlog decoder does not run"
oracle:
na: "Oracle has no TIME type; the MySQL binlog decoder does not run"
- name: cursor-past-manifest-continued
class: a stored incremental cursor past the `cursor_high` of the destination's success manifest is continued from, so the rows between are never delivered
history: "2026-10-15 - `last_cursor_value` edited to N+2 after a run that delivered 1..=N: exit 0 with `COUNT(*): source 43, delivered 41` on PostgreSQL, MySQL and SQL Server, through 0.31.0 (open_defect_a_cursor_moved_forward_delivers_or_refuses_*); fixed by refuse_a_cursor_past_the_manifest at the one claim seam every batch run passes"
Expand Down
2 changes: 1 addition & 1 deletion docs/cdc-type-fidelity-matrix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ scenarios:
- id: type_time_negative_fraction
what: "a negative TIME(1)/TIME(2) with a fraction is the stored duration on the stream leg: MySQL's own text in a string column, the snapshot's refusal in a default one"
postgres: { na: "PostgreSQL time of day is never negative" }
mysql: { test: open_defect_mysql_cdc_negative_time_fraction_matches_the_snapshot, oracle: independent }
mysql: { test: mysql_cdc_negative_time_fraction_matches_the_snapshot, oracle: independent }
mssql: { na: "SQL Server time has no negative value" }
mongo: { na: "no TIME type; a value rides the document blob" }
oracle: { na: "Oracle has no TIME type" }
Expand Down
2 changes: 1 addition & 1 deletion docs/fuzz-matrix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ scenarios:
- id: fuzz_cdc_wire_decode
what: "decoding a CDC change record off the replication wire into typed cells"
postgres: { test: pg_test_decoding }
mysql: { na: "binary binlog events are decoded by the mysql_common crate, not Rivet code — there is no Rivet-owned text/byte parser to fuzz" }
mysql: { gap: "binary binlog events are decoded by the patched mysql_common fork (blackbeam/rust_mysql_common#200); a property test over arbitrary binlog TIME bytes is open (2026-11-04), closes when the fuzz crate drives the fork decoder" }
mssql: { na: "change-table rows arrive as tiberius typed ColumnData (binary protocol, driver-decoded); Rivet only maps the enum in cell_to_rivet" }
mongo: { na: "BSON change events are deserialized into typed events by the mongodb driver, not Rivet code" }
oracle: { gap: "attempted 2026-10-08: a must-not-panic target over the LogMiner MINE_VALUE decoder (src/source/oracle/cdc.rs decode) is red on its first inputs, so it lands with the product fix, not before it. Measured with a throwaway unit probe: decode(Number, '1E9223372036854775807') panics `attempt to add with overflow` (cdc.rs:108); decode(TimestampTz, '2024-01-01T00:00:00 +00:9223372036854775807') panics `attempt to multiply with overflow` (cdc.rs:169); decode(TimestampTz, '2024-01-01T00:00:00 +99999999999999:00') panics `TimeDelta::seconds out of bounds` (chrono). The fuzz crate also builds without the `oracle` feature (fuzz/Cargo.toml: default-features = false), so the target needs that feature added" }
Expand Down
3 changes: 2 additions & 1 deletion docs/release-gate-matrix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,8 @@ infra:
# 2026-11-03: +1 structural N/A row from key-span-read-in-i64 (a Mongo collection has no range chunking).
# 2026-11-03: +1 structural N/A row from check-override-wire-not-refused (MongoDB declares no column wire type, so its check has no probe).
# 2026-11-03: +4 structural N/A rows from mysql-enum-label-escapes-unread (postgres, mssql, oracle, mongo carry no catalog-escaped ENUM or SET label).
na_ceiling: 487 # ratchet-pin: seeded-na
# 2026-11-04: +4 structural N/A rows from mysql-binlog-negative-time-fraction (PostgreSQL, SQL Server, MongoDB and Oracle have no MySQL binlog TIME decoder).
na_ceiling: 491 # ratchet-pin: seeded-na
note: "verify_seeded_recall re-introduces every known bug class in dev/seeded/seeds.yaml as a
source patch in a scratch worktree, builds it, and requires the declared catching cells
(green on the unpatched tree) to go red; MISSED / STALE / BROKEN / NO-CONTROL rows fail.
Expand Down
8 changes: 8 additions & 0 deletions docs/roast-ledger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,14 @@ entries:
status: deferred-past-gate
verdict: "confirmed live: a gc_orphans load between the first roll's upload and its manifest removed 1 orphan part (HDW-1 rework run, MySQL CDC); open_defect cells on MySQL and PostgreSQL"
closes: "fix/cdc-run-start-marker: the CDC sink writes a running manifest under the run's own key at start, the first Success rewrite supersedes it, a stale one is closed by state finish-run; bucket_writers then sees the run from its first byte"
- id: MYSQL-COMMON-LEGACY-TIME
date: 2026-11-04
lens: fix/mysql-binlog-time-fraction follow-up
title: the mysql_common legacy MYSQL_TYPE_TIME arm reads LeU24 unsigned and ignores the sign
copies: [src/binlog/value.rs:100-107 of the mysql_common crate]
status: deferred-past-gate
verdict: "read in the crate source, not run: affects only pre-5.6.4 temporal columns (MySQL 5.7), not 8.0"
closes: "an upstream fix to the legacy arm, or a property test over arbitrary binlog TIME bytes against the patched fork"
- id: CKPT-BUSY
date: 2026-11-04
lens: harness flake 2026-11-04
Expand Down
10 changes: 3 additions & 7 deletions tests/live/live_cdc_mbt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1142,11 +1142,7 @@ fn time_stream_legs_disagree(
.map(|n| format!("{n}: string"))
.collect::<Vec<_>>()
.join(", ");
let stream = |leg: &str| {
Rig::mysql_cdc(tbl)
.export_named(&format!("{tbl}_{leg}"))
.no_oracle("TF-1: the stream run may crash in the dependency; graded by MySQL's CAST text and the batch refusal")
};
let stream = |leg: &str| Rig::mysql_cdc(tbl).export_named(&format!("{tbl}_{leg}"));
let text = stream("text").export_line(&format!("columns: {{ {decl} }}"));
let refuse = stream("refuse");
text.pin_binlog_here();
Expand Down Expand Up @@ -1268,8 +1264,8 @@ fn time_stream_legs_disagree(

/// A negative MySQL TIME(1) or TIME(2) with a fraction is the stored duration on the stream leg: MySQL's own text in a `string` column, the snapshot's refusal in a default one.
#[test]
#[ignore = "live+gate-only: open defect TF-1; closes with fix/mysql-binlog-time-fraction"]
fn open_defect_mysql_cdc_negative_time_fraction_matches_the_snapshot() {
#[ignore = "live: requires docker compose mysql-cdc (binlog ROW + REPLICATION grant)"]
fn mysql_cdc_negative_time_fraction_matches_the_snapshot() {
let _serial = cross_process_serial("mysql_cdc_time_fraction");
let tbl = unique_name("cdc_tfrac");
let mut c = mysql::Pool::new(MYSQL_CDC_URL).unwrap().get_conn().unwrap();
Expand Down
3 changes: 2 additions & 1 deletion tests/offline/chunking_matrix_guard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@ const MATRICES: &[(&str, usize)] = &[
// write-only). 0 gaps: the surface Rivet parses is fully covered.
// Raised 0 -> 3 (2026-09-26): the Oracle column's honest gaps (batch-only phase 1).
// Lowered 3 -> 1 (2026-09-29): Oracle checkpoint + spill cells are structurally `na`.
("docs/fuzz-matrix.yaml", 1),
// Raised 1 -> 2 (2026-11-04): the MySQL binlog TIME decoder is the patched mysql_common fork, with no fuzz target yet; closes with the fork decoder driven by the fuzz crate.
("docs/fuzz-matrix.yaml", 2),
// URL & credential safety — the userinfo encode/decode/redact class that
// regressed THREE times (round-1 MSSQL round-trip, round-3 redact_pg_url, and
// the general log redactor), each invisible to point tests. `test:` cells are
Expand Down
3 changes: 2 additions & 1 deletion tests/offline/known_red_guard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ const LEDGER: &str = "dev/release_oracle/known_red.py";
// 10 -> 11 (2026-11-03): the MySQL CDC ENUM/SET label cell (TF-2, closes with fix/mysql-enum-label-escapes).
// 11 -> 26 -> 11 (2026-11-03): the 15 open_defect_ cells of the config count knobs HCF-1/3/4/8 opened and closed (fix/config-knob-quantity-counts).
// 11 -> 13 (2026-11-03): the gc_orphans-beside-a-CDC-run's-first-roll cells on MySQL and PostgreSQL, open defect CDC-RUN-START (fix/cdc-run-start-marker).
// 13 -> 14 (2026-11-04): the MySQL CDC negative TIME(1)/(2) fraction cell (TF-1, closes with fix/mysql-binlog-time-fraction).
// 13 -> 14 (2026-11-04): the MySQL CDC negative TIME(1)/(2) fraction cell (TF-1).
// 14 -> 28 (2026-11-04): the keyset key type cells, ER-1/ER-3/ER-6/RHS-3 (fix/seam-keyset-key-type).
// 28 -> 32 (2026-11-04): VP-8 missing-relation cells on MSSQL, Oracle and Mongo, and the MSSQL lock-timeout cell MT-F-F (close with fix/stop-class-by-code).
// 32 -> 31 (2026-11-04): the TF-2 cell is green on fix/mysql-enum-label-escapes and its entry is deleted.
// 31 -> 25 (2026-11-04): the six HDW-1 cells are plain cells again (fix/run-closing-cdc-begin).
// 25 -> 26 (2026-11-05): the S3 profile-beside-env-keys cell, open defect HFF-2 (closes with fix/destination-credential-every-leg).
// 26 -> 25 (2026-11-05): the TF-1 cell closed with fix/mysql-binlog-time-fraction.
// ratchet-pin: known-red-entries count dev/release_oracle/known_red.py ^ (_open|KnownRed)\(

/// The horizon every `_open` entry expires at; moves only here and in the ledger together.
Expand Down
53 changes: 53 additions & 0 deletions tests/offline/mysql_binlog_time_fraction.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
//! The MySQL binlog TIME2 decoder reads a negative TIME(1)/TIME(2) with a fraction as the server stored it.

use mysql_common::Value;
use mysql_common::binlog::misc::{my_time_packed_from_binary, time_from_packed};

fn decode(bytes: &[u8], dec: u32) -> Value {
time_from_packed(my_time_packed_from_binary(bytes, dec).expect("a TIME2 payload decodes"))
}

#[test]
fn a_negative_time_with_a_one_or_two_digit_fraction_is_read_as_stored() {
for dec in [1, 2] {
assert_eq!(
decode(&[0x7f, 0xff, 0xff, 0xce], dec),
Value::Time(true, 0, 0, 0, 0, 500_000),
"TIME({dec}) -00:00:00.50"
);
assert_eq!(
decode(&[0x7f, 0xff, 0xfe, 0xe7], dec),
Value::Time(true, 0, 0, 0, 1, 250_000),
"TIME({dec}) -00:00:01.25"
);
}
}

#[test]
fn a_negative_time_at_the_range_edge_with_a_fraction_is_read_as_stored() {
assert_eq!(
decode(&[0x7f, 0xff, 0xff, 0x9d], 2),
Value::Time(true, 0, 0, 0, 0, 990_000),
"TIME(2) -00:00:00.99"
);
}

#[test]
fn time_values_beside_a_negative_fraction_decode_as_before() {
assert_eq!(
decode(&[0x80, 0x00, 0x00, 0x32], 2),
Value::Time(false, 0, 0, 0, 0, 500_000)
);
assert_eq!(
decode(&[0x7f, 0xff, 0xff, 0x00], 2),
Value::Time(true, 0, 0, 0, 1, 0)
);
assert_eq!(
decode(&[0x7f, 0xff, 0xff, 0xec, 0x78], 3),
Value::Time(true, 0, 0, 0, 0, 500_000)
);
assert_eq!(
decode(&[0x7f, 0xff, 0xff, 0xec, 0x78], 4),
Value::Time(true, 0, 0, 0, 0, 500_000)
);
}
1 change: 1 addition & 0 deletions tests/offline/rig_oracle_ratchet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use std::path::{Path, PathBuf};
// 29 -> 30 (2026-11-03, #798): the ClickHouse cell a_load_from_another_state_db_does_not_strand_a_rolling_cdc_run_mysql loads beside a live MySQL CDC run, which the oracle cannot grade against the source mid-run; it reads the current-state view through the second client; closes when the oracle grades a load taken during a CDC run.
// 30 -> 31 (2026-11-04, TF-1): the negative TIME(1)/(2) fraction cell drives a stream run that panics in a debug binary and leaves a running row; graded by MySQL's CAST text and the batch refusal; the fix PR removes the opt-out.
// 31 -> 32 (2026-11-04): the datetime2(7) keyset cell under timestamp_ns delivers 700 ns ticks the oracle reads at microseconds; closes when the oracle reads datetime2(7) at full scale.
// 32 -> 31 (2026-11-04): the TF-1 cell closed with fix/mysql-binlog-time-fraction and its opt-out is gone.
// ratchet-pin: no-oracle-opt-outs count tests/live/ \.no_oracle\(|run_rivet_ok_no_oracle\(|"RIVET_TEST_NO_ORACLE"|NO_ORACLE_ENV

// Typed declarations in tests/live of what a run that does not exit 0 may leave. History frozen at 2026-11-04.
Expand Down
2 changes: 2 additions & 0 deletions tests/offline_suite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ mod mssql_column_data_fixture_guard;
mod mutation_gate_config;
#[path = "offline/mutation_gate_priority_guard.rs"]
mod mutation_gate_priority_guard;
#[path = "offline/mysql_binlog_time_fraction.rs"]
mod mysql_binlog_time_fraction;
#[path = "offline/mysql_wire_type_fixture_guard.rs"]
mod mysql_wire_type_fixture_guard;
#[path = "offline/oneshot_budget.rs"]
Expand Down
Loading