[Bug]: system_metrics.metric duplicate rows after commit-result-unknown triggers CSV fallback and ETL re-import
Maintainers usually reply within 1 day
Assessment
This issue has not been assessed yet.
Description
Is there an existing issue for the same bug?
- I have checked the existing issues. Related closed issue: #22517 (same failing SQL assertion, previously closed without identifying the root cause); related upstream trigger: #19483 (
too large wal message error handle, still open).
Branch Name
main
Commit ID
ca5325ce683 (observed in CI run 45584592765 on PR #32989, unrelated to the PR diff)
Actual Behavior
In Pessimistic multi-CN BVT, test/distributed/cases/log/column_metric.sql (line 3) fails with 693 duplicate metric groups (2 rows per group):
select count(1) cnt, metric_name, collecttime, `node`, role, account, type
from system_metrics.metric
group by metric_name, collecttime, `node`, role, account, account_id, type
having cnt > 1;
Root-cause evidence chain (CN + TN + ETL logs)
- Upstream TN commit queue stall (103s):
- A background merge task
[MT-18264]-275681-rfc_t(txn01A2120FB5097037B7DB100F8F623FDA) stalled in TNPrePrepareDedupfor 1m43.07s and then failed on oversized WAL:2026/11/25 09:35:49.001059 +0000 INFO mergesort/task.go:458 [MERGE-START] {"task": "[MT-18264]-275681-rfc_t", "txn-info": "ctx[01A2120FB5097037B7DB100F8F623FDA]..."} 2026/11/25 09:37:51.088862 +0000 INFO txnimpl/txndb.go:558 SLOW-LOG-PrePrepareDedup {"txn": "ctx[01A2120FB5097037B7DB100F8F623FDA]...", "duration": "1m43.074878513s"} 2026/11/25 09:37:51.088992 +0000 ERROR txnimpl/store.go:849 error: internal error: txn 01a2120fb5097037b7db100f8f623fda WAL entry approxSize 249561088 is too large, max is 73400320
- A background merge task
- CN receives commit-result-unknown while TN commits:
- While
preWalQueuewas blocked (09:36–09:38 UTC / 17:36–17:38 CST), 24LOAD DATA INLINEtransactions intosystem_metrics.metric(plus 5 intosystem_metrics.sql_statement_cu) timed out on CN with commit result unknown (pkg/txn/rpc/sender.go:193). - Once the stall cleared, TN logged all 29 transactions as
Committed(commit latency 11–103s for the 24metricwrites).
- While
- Unconditional CSV fallback + missing deduplication in ETL import:
- On any
err != nilfromsqlFlusher.FlushBuffer,ContentWriter.FlushAndClose(pkg/util/export/etl/content.go:140-161) writes the same buffer to a fallback CSV file. - At
09:40:12 UTC, ETL (pkg/util/export/merge.go:404-461) processed and deleted all 24metricCSV files. db_holder.IsRecordExisted(pkg/util/export/etl/db/db_holder.go:423-462) only checksstatement_infoand unconditionally returnsfalse, nilforsystem_metrics.metric(andsql_statement_cu), which have no primary key.- The 24 fallback CSV files match all 693 duplicate groups by
(collecttime second, node, role), producing exact 2x duplicates whencolumn_metric.sqlran at09:46:33 UTC.
- On any
Expected Behavior
- When a metrics
LOAD DATA INLINEreturns an ambiguous/unknown commit outcome (ErrTxnResultUnknown/ stream error after commit sent) and TN actually committed the transaction, the CSV fallback + ETL import path must not insert duplicate rows intosystem_metrics.metric(orsql_statement_cu). - When the original transaction genuinely rolled back / failed before commit, the CSV fallback + ETL import path must still deliver the batch exactly once (no data loss).
Proposed Fix Direction
- Delivery / fallback boundary (
pkg/util/export/etl/content.go,pkg/util/export/merge.go,pkg/util/export/etl/db/db_holder.go):- Distinguish definite rollback/failure from unknown commit outcome (
moerr.IsMoErrCode(..., moerr.ErrTxnResultUnknown)or equivalent transport error after commit). - Ensure fallback CSV files written on unknown outcome cannot race ahead of an in-flight TN commit still draining in
preWalQueue, and verify whether one CSV file corresponds to one atomic SQLLOADbatch or multiple batches. - Extend existence / idempotency protection in ETL import (e.g.,
db_holder.IsRecordExistedforsystem_metrics.metricleveragingCLUSTER BY (collecttime, account_id, metric_name)andsystem_metrics.sql_statement_culeveragingCLUSTER BY (account, collecttime), or batch-level idempotent identity) so already-committed batches are skipped while genuinely rolled-back batches are still imported.
- Distinguish definite rollback/failure from unknown commit outcome (
- Follow-up on upstream oversized WAL stall: Tracked under #19483 (
MT-18264249MB WAL failing after 103s inPrePrepareDedup).
Additional Information
- CI run: https://github.com/matrixorigin/matrixone/actions/runs/45584592765/attempts/1
- Related closed issue (same symptom): #22517
- Related open issue (oversized WAL handling): #19483
- Dominant language
- Go
- Stars
- 1.9k
- Forks
- 312
- Avg merge
- 22h 59m
- Merged PRs (30d)
- 736
Getting set up
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from matrixorigin/matrixone
-
kind/bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
matrixorigin/matrixone#33363 ·
Maintainers usually reply within 1 day
-
kind/bug
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
matrixorigin/matrixone#33362 ·
Maintainers usually reply within 1 day
-
SLEEP rejects NULL and negative durations that MySQL acceptsPossibly taken @XuPeng-SH claimed this 7 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
matrixorigin/matrixone#32653 ·
Maintainers usually reply within 1 day
-
[Bug]: TestChangeWatchProxy loses its first tenant connection during PingContext in Ubuntu CIPossibly taken @XuPeng-SH claimed this today. Openkind/bug needs-triage
matrixorigin/matrixone#33371 · 1 assignee ·
Maintainers usually reply within 1 day
-
[Bug]: TestDaemonClaimSQLRoundTrip exhausts its shared deadline during the stale claim update in Ubuntu CIPossibly taken @XuPeng-SH claimed this today. Openkind/bug needs-triage
matrixorigin/matrixone#33370 · 1 assignee ·
Maintainers usually reply within 1 day
All issues in matrixorigin/matrixone
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
zalando/postgres-operator#3257 ·
Maintainers usually reply within 2 days
-
[inputs.internal] README lists go_version tag on internal_gather instead of internal_agentPossibly taken @cvas22 claimed this today. Open
Difficulty 1/5 Under an hour Newbie friendliness 90/100
influxdata/telegraf#20264 ·
Maintainers usually reply within 1 day
-
[Bug] Standalone migration breaks existing Ingress routes using the envoy-http Service port nameOpenaccepted bug wg/enterprise-environment
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
vllm-project/semantic-router#7483 · 1 comment ·
Maintainers usually reply within 1 day
-
needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
stacklok/toolhive-catalog#2076 ·
Maintainers usually reply within 1 day