[Bug]: CDC pause/resume can permanently lose a DELETE across a pending-watermark pause
I maintainer di solito rispondono entro 1 giorno
@jiangxinmeng1 ci sta già lavorando.
Dal 26/11/2026.
Valutazione
Questa issue non è ancora stata valutata.
Descrizione
Description
Tested on MatrixOne main commit c0cef5c9cce2164fedd201c188bfffe4d2d09a96 (git_version() = c0cef5c) with a table-level MatrixOne-to-MatrixOne CDC task. The minimal scenario reproduced in 3/3 fresh runs.
If a second PAUSE CDC TASK arrives after the sink transaction is visible but before its durable CDC watermark is published, the next RESUME can permanently omit a DELETE. The task remains running with an empty error and continues replicating later inserts, so this is silent source/sink divergence rather than ordinary replication lag.
Actual behavior
The reproducer below performs two pause/resume rounds:
- Initially replicate IDs
(1,2)and wait for a nonzero durable watermark. - Pause; commit
DELETE 2 + INSERT 3; resume. - As soon as the sink visibly contains
(1,3), pause again without waiting for the watermark to advance. - Commit
DELETE 3 + INSERT 4; resume. - Insert ID
5as a liveness control.
Observed in all three runs:
after-resume-1: sink = (1,3)
source: (1,4,5)
sink: (1,3,4,5) -- deleted ID 3 survives permanently
task: state=running, err_msg=''
ID 5 reaches the sink after the mismatch, and the expected (1,4) state was not reached during a 30-second poll. A control that waits for the durable watermark to advance after every resume converges correctly.
Expected behavior
Every committed source DELETE must eventually be applied exactly once to the sink after resume. The final sink must be (1,4,5). CDC must not advance its watermark past a tombstone that was omitted from the emitted changes, and a pause must not discard watermark state for a transaction already committed to the sink.
Runnable reproduction
Requires Python 3, pymysql, and a local MatrixOne SQL endpoint on 127.0.0.1:6001. Adjust the three endpoint/password constants if necessary. The source and sink are separate databases on the same instance.
Python reproducer
import time
import pymysql
conn = pymysql.connect(
host='127.0.0.1', port=6001,
user='root', password='111', autocommit=True,
)
def rows(cur, db):
cur.execute(f'SELECT id FROM {db}.t ORDER BY id')
return cur.fetchall()
def wait_rows(cur, expected, timeout=45):
deadline = time.time() + timeout
last = None
while time.time() < deadline:
try:
last = rows(cur, 'qa_delins_sink')
if last == expected:
return last
except Exception as e:
last = str(e).splitlines()[0]
time.sleep(0.25)
raise RuntimeError(f'want={expected!r} last={last!r}')
def wait_state(cur, expected, timeout=45):
deadline = time.time() + timeout
state = None
while time.time() < deadline:
cur.execute("SELECT state FROM mo_catalog.mo_cdc_task "
"WHERE task_name='qa_cdc_delins'")
state = cur.fetchone()[0]
if str(state).lower() == expected:
return
time.sleep(0.25)
raise RuntimeError(f'state timeout: want={expected} last={state}')
def wait_initial_watermark(cur, timeout=60):
deadline = time.time() + timeout
while time.time() < deadline:
cur.execute("""
SELECT w.watermark
FROM mo_catalog.mo_cdc_watermark w
JOIN mo_catalog.mo_cdc_task t
ON t.account_id=w.account_id AND t.task_id=w.task_id
WHERE t.task_name='qa_cdc_delins'
""")
row = cur.fetchone()
if row and row[0] != '0-0':
print('initial-watermark', row[0])
return
time.sleep(0.25)
raise RuntimeError('initial watermark timeout')
with conn.cursor() as cur:
cur.execute('DROP CDC IF EXISTS qa_cdc_delins')
cur.execute('DROP DATABASE IF EXISTS qa_delins_src')
cur.execute('DROP DATABASE IF EXISTS qa_delins_sink')
cur.execute('CREATE DATABASE qa_delins_src')
cur.execute('CREATE DATABASE qa_delins_sink')
cur.execute('CREATE TABLE qa_delins_src.t(id INT PRIMARY KEY)')
cur.execute('INSERT INTO qa_delins_src.t VALUES(1),(2)')
# CREATE CDC on this commit requires a PITR window of at least two hours.
cur.execute("CREATE PITR IF NOT EXISTS qa_cdc_delins_pitr "
"FOR ACCOUNT RANGE 2 'h'")
cur.execute("""
CREATE CDC qa_cdc_delins
'mysql://root:[email protected]:6001'
'matrixone'
'mysql://root:[email protected]:6001'
'qa_delins_src.t:qa_delins_sink.t'
{'Level'='table'}
""")
print('initial', wait_rows(cur, ((1,), (2,))))
wait_initial_watermark(cur)
cur.execute('PAUSE CDC TASK qa_cdc_delins')
wait_state(cur, 'paused')
cur.execute('BEGIN')
cur.execute('DELETE FROM qa_delins_src.t WHERE id=2')
cur.execute('INSERT INTO qa_delins_src.t VALUES(3)')
cur.execute('COMMIT')
cur.execute('RESUME CDC TASK qa_cdc_delins')
wait_state(cur, 'running')
print('after-resume-1', wait_rows(cur, ((1,), (3,))))
# Deliberately do not wait for watermark publication here.
cur.execute('PAUSE CDC TASK qa_cdc_delins')
wait_state(cur, 'paused')
cur.execute('BEGIN')
cur.execute('DELETE FROM qa_delins_src.t WHERE id=3')
cur.execute('INSERT INTO qa_delins_src.t VALUES(4)')
cur.execute('COMMIT')
cur.execute('RESUME CDC TASK qa_cdc_delins')
wait_state(cur, 'running')
try:
print('after-resume-2', wait_rows(cur, ((1,), (4,)), timeout=30))
except RuntimeError as e:
print('MISMATCH', e)
cur.execute('INSERT INTO qa_delins_src.t VALUES(5)')
deadline = time.time() + 30
while time.time() < deadline:
if any(row[0] == 5 for row in rows(cur, 'qa_delins_sink')):
break
time.sleep(0.25)
print('source', rows(cur, 'qa_delins_src'))
print('sink', rows(cur, 'qa_delins_sink'))
cur.execute("SELECT state,err_msg FROM mo_catalog.mo_cdc_task "
"WHERE task_name='qa_cdc_delins'")
print('task', cur.fetchall())
cur.execute('DROP CDC qa_cdc_delins')
Code analysis and controls
The failure window involves sink commit preceding watermark publication. A pause in that interval can discard the already-committed transaction's pending watermark update. On resume, CDC reads both transactions again; normal net-effect collection folds the replayed INSERT id=3 together with the later DELETE id=3, even though the sink already contains that inserted row. The final watermark then advances beyond the omitted tombstone.
Relevant paths at the tested commit include:
pkg/cdc/reader_v2_txn_manager.go: sink commit and watermark-only update ordering.pkg/frontend/cdc_exector.goandpkg/cdc/watermark_updater.go: pause/watermark handling.pkg/cdc/change_handle.go: collection does not retain the trailing DELETE required by this replay case.
Only-DELETE short sequences did not reproduce the mismatch. Repeating the mixed-DML scenario while waiting for a strictly advancing durable watermark after each resume passed, which isolates the bug to the pending-watermark pause window rather than ordinary pause/resume replication.
Duplicate check
Searched CDC pause/resume, watermark, DELETE and net-effect reports. #24797 and #25794 concern inconsistent pause states; #26633 concerns recovery from a target-table error; #30647 concerns sink-outage retries; #30512 concerns source-generation changes. None reports this committed-sink/pending-watermark sequence silently losing a DELETE.
- Lingua principale
- Go
- Stelle
- 1.9k
- Fork
- 312
- Merge medio
- 22h 59m
- PR unite (30g)
- 736
Preparare l'ambiente
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di matrixorigin/matrixone
-
kind/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
matrixorigin/matrixone#33363 ·
I maintainer di solito rispondono entro 1 giorno
-
kind/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
matrixorigin/matrixone#33362 ·
I maintainer di solito rispondono entro 1 giorno
-
SLEEP rejects NULL and negative durations that MySQL acceptsForse già presa @XuPeng-SH l’ha presa 7 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
matrixorigin/matrixone#32653 ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug]: TestChangeWatchProxy loses its first tenant connection during PingContext in Ubuntu CIForse già presa @XuPeng-SH l’ha presa oggi. Apertakind/bug needs-triage
matrixorigin/matrixone#33371 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug]: TestDaemonClaimSQLRoundTrip exhausts its shared deadline during the stale claim update in Ubuntu CIForse già presa @XuPeng-SH l’ha presa oggi. Apertakind/bug needs-triage
matrixorigin/matrixone#33370 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di matrixorigin/matrixone
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
pg-sharding/spqr#3314 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
zalando/postgres-operator#3257 ·
I maintainer di solito rispondono entro 2 giorni
-
[inputs.internal] README lists go_version tag on internal_gather instead of internal_agentForse già presa @cvas22 l’ha presa oggi. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
influxdata/telegraf#20264 ·
I maintainer di solito rispondono entro 1 giorno