[Bug]: CDC pause/resume can permanently lose a DELETE across a pending-watermark pause
Maintainers usually reply within 1 day
@jiangxinmeng1 is already working on this.
Since Nov 26, 2026.
Assessment
This issue has not been assessed yet.
Description
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.
- 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