Skip to content

[Bug] Chaos TPCC (4164cfb/cb94136cf): district-level oorder/order_line consistency check false positive — cross-partition read snapshot skew under chaos #25232

Closed

Description

Environment

Field Value
Cluster mo-chaos-4-0-dev-4164cfb-202606242212
Namespace mo-chaos-4-0-dev-4164cfb-202606242212
Build / image matrixone:commit-cb94136cf
Endpoint 10.222.6.253:6001
Artifact root /data1/chaos-test/28087898861_4164cfb
Workload TPCC 10 warehouses / 10 terminals + chaos (kill CN/DN/Log, mem/network stress)
Analysis window 2026-06-24 22:12 CST (deploy) → 2026-06-29 15:21 CST (~4.7d; tests stopped by ops)

Scope: MatrixOne distributed read consistency for single-statement cross-table aggregate used by TPCC ConsistencyCheck query #5 — transient bmsql_oorder.o_ol_cnt vs bmsql_order_line district mismatch that self-heals within one verify cycle (~35s).

Out of scope: Permanent TPCC data corruption (ytd / D_NEXT_O_ID drift), duplicate-key (1062) defects, Payment 20638 ambiguous commit (see 7cbeacd durable corruption issue).

Summary

During chaos long-run on 4164cfb / cb94136cf, TPCC runVerify.sh / io.mo.ConsistencyCheck reported 2 failures (out of 7701 verify runs, 0.026%) on this SQL only:

(SELECT o_w_id, o_d_id, sum(o_ol_cnt) FROM bmsql_oorder  GROUP BY o_w_id, o_d_id)
EXCEPT
(SELECT ol_w_id, ol_d_id, count(ol_o_id) FROM bmsql_order_line GROUP BY ol_w_id, ol_d_id);

Both failures recovered on the next verify cycle (same check PASS). After 2026-06-26 18:00 CST, 3822 consecutive PASS with 0 FAIL until test stop.

This is NOT permanent data corruption. Evidence:

Check Result
pass / fail 7701 / 2
Max consecutive FAIL 1
Fail → PASS interval ~35s (#1: 04:36:16 → 04:36:51) and ~31s (#2: 10:22:14 → 10:22:45)
Other ConsistencyCheck queries (ytd, D_NEXT_O_ID, dup having count(1)>1) 0 failures
ErrorCode 1062 / Duplicate entry / 20638 (full run) 0
Jun 26 fail windows ±5min 0×1062, 0×20638
Post-incident window (Jun 26 18:00+) 3822 pass / 0 fail

MatrixOne issue (same class as 83cc163 read-skew): under chaos + concurrent NewOrder, a single EXCEPT over district aggregates on bmsql_oorder and bmsql_order_line can observe different effective snapshot / LogTail apply watermarks across partitions, producing transient district-level skew. When in-flight NewOrders complete and LogTail catches up, the check passes again.

Release gate: PASSED — transient only; distinguish from 7cbeacd permanent corruption.

Failing SQL invariant

TPCC invariant per district:

$$\sum_{\text{orders}} o_ol_cnt = \text{count}(\text{order_line rows})$$

NewOrder sets o_ol_cnt and inserts matching order_line rows in one transaction (jTPCCTData.executeNewOrder → db.commit()). Exception rows in the log are the left side (sum(o_ol_cnt) per (w_id, d_id)), meaning the reader saw more committed order headers than matching line counts at snapshot time.

Timeline (2 failures)

# Fail time (CST) Next PASS Self-heal Nearby chaos Exception scope
1 06-26 04:36:16 04:36:51 35s task_mem_cn active 04:33:04–04:38:04 (fail at +3m12s into CN mem stress) 73 districts across w_id 3–9
2 06-26 10:22:14 10:22:45 31s task_kill_dn 10:05, task_kill_log 10:11, task_mem_dn cleanup 10:21:36 (fail 38s after DN mem stress ends) 37 districts across w_id 3,4,6,7

Last PASS before each fail:

Fail Last PASS
#1 04:35:44
#2 10:21:40

Fail #1 exception sample (left = sum(o_ol_cnt))

w_id  d_id  sum(o_ol_cnt)
3     7     46565
3     9     47391
4     1     49851
5     10    44798
6     7     54869
...

(73 rows total; warehouses 3–9 all represented.)

Fail #2 exception sample

w_id  d_id  sum(o_ol_cnt)
3     1     50581
3     10    52019
4     1     59966
6     5     63526
7     9     75357
...

(37 rows; warehouses 3, 4, 6, 7; partial district coverage on wh 4.)

What this is NOT

Ruled out Evidence
Duplicate key / dup insert 0 ErrorCode 1062, 0 Duplicate entry entire run
Payment ambiguous commit (20638) 0 in benchmarksql-error-10-10.log
Permanent ytd / order-id drift 0 ytd / D_NEXT_O_ID consistency fails
Durable txn corruption Max consecutive FAIL = 1; 3822 pass after Jun 26 18:00
Chaos kill causing durable loss Would stay FAIL; other consistency queries would also fail
7cbeacd class defect That run: 5506 fail, 6209×1062, ytd drift billions, never recovered

Root cause analysis

Symptom

District-level EXCEPT returns many rows; ~30–35s later same query returns empty.

Mechanism

  1. Concurrent NewOrder (10 terminals, multi-CN) commits bmsql_oorder + bmsql_order_line in one txn across partitions (PARTITION BY KEY(o_w_id)).
  2. ConsistencyCheck runs query [#4] Add a new document: CHANGELOG.md #5 as auto-commit Statement.executeQuery() (RR default on MO).
  3. During CN mem stress (Add README.md #1) or DN kill + log kill + DN mem stress chain (integrate mysql parser from pingcap #2), LogTail apply / CN read path is perturbed; single EXCEPT scans both tables with per-district SUM / COUNT.
  4. Reader sees committed oorder headers (o_ol_cnt) for multiple districts before all matching order_line rows are visible in the same logical snapshot → district aggregate mismatch on the left side only.
  5. After apply catches up (~seconds, bounded by next 30s verify), aggregates align → PASS.

Multi-district / multi-warehouse blast radius (73 and 37 rows) is consistent with global snapshot watermark lag, not a single bad order row.

Earliest fixable defect

# Defect Layer
R1 Single SELECT with multi-table aggregates must use one consistent snapshot across all partitions; LogTail apply must not return partial post-commit visibility for related tables MO pkg/vm/engine/disttae
R2 NewOrder commit visibility: bmsql_oorder and bmsql_order_line of same txn must become visible atomically at one CommitTimestamp MO txn / disttae apply
R3 ConsistencyCheck has no retry — any transient skew fails verify immediately TPCC harness (ConsistencyCheck.java)

Expected vs actual

Expected (RR, one SQL statement) Actual
EXCEPT subqueries see same committed view 2/7701 checks show district skew (0.026%)
Skew implies dup or missing rows at rest 0×1062; max consecutive FAIL = 1
Chaos FAIL = durable inconsistency 2/2 self-healed within one verify period

Proposed fixes

P1 — MatrixOne (read / snapshot) — same as 83cc163

  1. pkg/vm/engine/disttae: for a single read-only statement, ensure all partitions share the same SnapshotTimestamp and reads block until LogTail apply watermark ≥ snapshot for all subscribed partitions.
  2. NewOrder commit visibility: header + line rows visible atomically at one CommitTimestamp.
  3. Regression: chaos soak with runVerify.sh every 30s; query [#4] Add a new document: CHANGELOG.md #5 fail rate < 1/10000; per-order JOIN 0 rows at fail instant and after 60s.

P2 — Chaos / TPCC harness (parallel)

  1. ConsistencyCheck.java: retry query [#4] Add a new document: CHANGELOG.md #5 up to 3× with 5s sleep before exit(1).
  2. Replace district EXCEPT with per-order JOIN (more precise):
SELECT o.o_w_id, o.o_d_id, o.o_id, o.o_ol_cnt, COUNT(ol.ol_number) AS lines
FROM bmsql_oorder o
LEFT JOIN bmsql_order_line ol
  ON o.o_w_id = ol.ol_w_id AND o.o_d_id = ol.ol_d_id AND o.o_id = ol.ol_o_id
GROUP BY o.o_w_id, o.o_d_id, o.o_id, o.o_ol_cnt
HAVING o.o_ol_cnt <> COUNT(ol.ol_number)
LIMIT 10;
  1. Chaos pass criteria: FAIL only on 3 consecutive query [#4] Add a new document: CHANGELOG.md #5 failures or per-order JOIN rows still present after 60s.

P3 — Ops / release gate

Treat single ol_cnt EXCEPT fail with PASS on next cycle and 0×1062/20638 as transient (non-blocking); block release only on sustained FAIL or dup/20638 storms (per 7cbeacd pattern).

Reproduce

  1. Deploy mo-chaos-4-0-dev-4164cfb-* class cluster (commit-4164cfb or cb94136cf).
  2. Run chaos TPCC (props_10.mo: 10 wh, 10 terminals) + runVerify.sh every 30s + full chaos loop (kill CN/DN/Log, mem/network).
  3. Run >24h.
  4. Observe rare query [#4] Add a new document: CHANGELOG.md #5 EXCEPT failures (this run: 2 in ~4.7d); confirm:
    • Next verify PASS within ~35s
    • 0 1062 / 20638 at fail time
    • 0 ytd / D_NEXT_O_ID fails

check log:128 /data1/chaos-test/28087898861_4164cfb/mo-chaos/test-tool/mo-tpcc/check.log

Activity

  1. ghost added this to the MO-202606 milestone on Jun 29, 2026
  2. ghost added theissue type on Jun 29, 2026
  3. ghost added
    kind/bug
    on Jun 29, 2026
  4. ghost added
    severity/s0
    on Jun 29, 2026
  5. added
    ai-heavy
    on Jul 4, 2026
  6. added a commit that references this issue on Jul 7, 2026
    84e9bd8
  7. added a commit that references this issue on Jul 13, 2026
    7b8ffcb
  8. added a commit that references this issue on Jul 13, 2026
    f88bc22
  9. ghost closed this as completedon Jul 30, 2026
  10. added 3 commits that reference this issue on Sep 17, 2026
    90786fe
    264253d
    1a3ed4e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ai-heavykind/bugseverity/s0

    Type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions