Skip to content

[Bug]: CDC watermark drop race UT intermittently misses writer-first lock waiter #28282

Closed

Description

@gouhongshen

Is there an existing issue for the same bug?

  • I have checked the existing issues.

The original product bug #27666 is closed. Its comments record this exact test-failure signature on an unrelated PR, but no open issue tracks the recurring test failure.

Branch Name

agent/issue-28277-c4ea83b7

Commit ID

167bc74dca30644abf6222a82895dd9026b1ddbb

Other Environment Information

Actual Behavior

pkg/tests/issues.TestIssue27666CDCWatermarkWriteSerializesWithDrop/writer_wins intermittently waits 30 seconds without observing a waiter on the mo_cdc_task row lock:

Error: Condition never satisfied
Test: TestIssue27666CDCWatermarkWriteSerializesWithDrop/writer_wins
Messages: contender did not wait for the holder task-row lock

The coverage diagnostics report this as the only failed test; there are no build failures. The failure occurs at the pre-release lock-waiter assertion in issue_27666_test.go:127.

This exact signature was previously recorded in #27666 comment 5549595856 on unrelated PR #28145. On the current failing head, the focused command passed 3/3 locally in 15.245 seconds:

.agents/skills/mo-dev/scripts/mo-cgo-test -run ^TestIssue27666CDCWatermarkWriteSerializesWithDrop$ -count=3 -timeout=180s ./pkg/tests/issues
ok github.com/matrixorigin/matrixone/pkg/tests/issues 15.245s

PR #28278 changes remote-pipeline terminal-error and cancellation handling plus its tests. It does not change pkg/tests/issues, CDC, catalog locking, lockservice, or the internal SQL executor. The failed assertion runs before the test cancels either transaction, so none of the changed cancellation/error-arbitration paths is active.

Expected Behavior

The two-CN CDC race regression should deterministically observe the contender blocked behind the holder in both lock orderings, or report enough transaction/lock state to distinguish an implementation regression from an observation race.

Steps to Reproduce

  1. Run the coverage unit-test suite on a two-CN embedded configuration.
  2. Execute TestIssue27666CDCWatermarkWriteSerializesWithDrop.
  3. In the intermittent failure, observe that drop_wins passes and writer_wins times out in clusterHasLockWaiter after 30 seconds.
  4. Re-run the exact focused test; it may pass, as it did 3/3 on the failing head.

Additional information

  • Failed run attempt: 1.
  • Failed job completed at 2026-09-06T09:54:05Z.
  • The test entered main through PR fix(cdc): prevent watermark recreation after drop #27989 / commit 57af20eef8.
  • Investigation should determine whether the contender is not acquiring the expected task-row lock or whether clusterHasLockWaiter can miss a valid remote/bound lock waiter. The test should not be weakened without proving the intended serialization and final task/watermark atomicity.

Activity

  1. self-assigned this
    on Sep 6, 2026
  2. added
    kind/bug
    severity/s0
    ai-easy
    and removed on Sep 6, 2026
  3. gouhongshen commented on Sep 6, 2026

    @gouhongshen
    ContributorAuthor

    PR #28283 is trying to fix this issue.

  4. gouhongshen commented on Sep 6, 2026

    @gouhongshen
    ContributorAuthor

    PR #28283 has merged and is awaiting manual validation. The issue remains open.

  5. gouhongshen commented on Sep 8, 2026

    @gouhongshen
    ContributorAuthor

    Reopening: Matrixone UT Coverage failed again on run 34222510623, job 102049428094, attempt 1. TestIssue27666CDCWatermarkWriteSerializesWithDrop/drop_wins timed out after 30 seconds because no contender waiter was observed for the holder transaction. PR #28291 changes only four pkg/fileservice test files, so it cannot affect this CDC/lock-observation path. This is the same two-CN lock-waiter observability contract tracked here, now reproducing in the opposite lock ordering. The failed job will be rerun once under the CI policy.

  6. XuPeng-SH commented on Sep 9, 2026

    @XuPeng-SH
    Contributor

    Root cause and fix update

    This is the same failure tracked by this issue; no duplicate issue was opened.

    The failure was a test precondition race, not a GetWaitingList false negative. The fixture row was committed through CN0, but CN1 had not necessarily consumed the corresponding logtail yet. In drop_wins, the guarded watermark INSERT on CN1 could therefore complete with AffectedRows=0 before it requested the task-row lock, so the holder wait graph correctly contained no contender.

    Commit e5e7c1bacf fixes the test contract by:

    • waiting for the exact task row to become visible through an independent CN1 autocommit connection before starting the race;
    • generating a unique UUID task ID per ordering to prevent an older fixture generation satisfying the barrier;
    • failing immediately with transaction ID, last statement, affected rows, and error if the contender completes before entering the lock wait;
    • retaining exact waiter-ID, both lock orderings, cleanup, and final zero task/watermark assertions.

    Validation on the candidate:

    • focused two-CN regression: pass;
    • focused regression with -race: pass;
    • transaction/waiter helper tests with -race -count=3: pass;
    • owning package with the known unrelated TestIssue28313EmptyRemoteDispatch flaky skipped: pass;
    • go vet with repository CGo headers/libs and git diff --check: pass.
  7. XuPeng-SH commented on Sep 9, 2026

    @XuPeng-SH
    Contributor
  8. added a commit that references this issue on Sep 9, 2026
    7f173b4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

ai-easykind/bugseverity/s0

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions