[Bug]: system_metrics.metric duplicate rows after commit-result-unknown triggers CSV fallback and ETL re-import
Los mantenedores suelen responder en 1 día
Evaluación
Este issue todavía no se ha evaluado.
Descripción
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
- Lenguaje dominante
- Go
- Estrellas
- 1.9k
- Forks
- 312
- Merge medio
- 21 h 57 min
- PR fusionados (30 d)
- 730
Preparar el entorno
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de matrixorigin/matrixone
-
kind/bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
matrixorigin/matrixone#33363 ·
Los mantenedores suelen responder en 1 día
-
kind/bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
matrixorigin/matrixone#33362 ·
Los mantenedores suelen responder en 1 día
-
SLEEP rejects NULL and negative durations that MySQL acceptsPosiblemente ocupada @XuPeng-SH la tomó hace 7 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
matrixorigin/matrixone#32653 ·
Los mantenedores suelen responder en 1 día
-
[Bug]: TestChangeWatchProxy loses its first tenant connection during PingContext in Ubuntu CIPosiblemente ocupada @XuPeng-SH la tomó hoy. Abiertokind/bug needs-triage
matrixorigin/matrixone#33371 · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
[Bug]: TestDaemonClaimSQLRoundTrip exhausts its shared deadline during the stale claim update in Ubuntu CIPosiblemente ocupada @XuPeng-SH la tomó hoy. Abiertokind/bug needs-triage
matrixorigin/matrixone#33370 · 1 asignado ·
Los mantenedores suelen responder en 1 día
Todos los issues de matrixorigin/matrixone
Issues similares
-
area/ui-schema good first issue type/bug
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
Los mantenedores suelen responder en 4 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
router-for-me/CLIProxyAPI#8573 ·
Los mantenedores suelen responder en 9 días
-
bug: minute-granularity sync timestamp makes e2e tests asserting "Already in sync" fail sporadicallyAbiertobug package:cmd priority:3-low
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
docToolchain/Bausteinsicht#761 ·
Los mantenedores suelen responder en 1 día
-
Flaky test: kb TestUnknownLabelValuesAreFoldedNotExported fails when the start epoch contains 799Abiertoarea/knowledge kind/bug priority/p1 status/accepted
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
openagentix/openagentix#253 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 76/100
quii/learn-go-with-tests#934 · 1 comentario ·