Skip to content

[Bug]: Cross-CN Transaction Visibility Race Causes ExpectedEOB Error #23899

Closed

Description

@XuPeng-SH

Problem

Concurrent data branch operations on different CN nodes cause visibility race condition:

  • cn2: data branch create database exp_no_gate_182841988883 (txn afe68)
  • cn1: data branch create table exp_no_gate_182841988883.agent_events (txn bfc7)

cn1's snapshot TS (1773858521993681333) is ~6ms earlier than cn2's commit TS (1773858521999921877), so cn1's transaction cannot see the newly created database.

Error Chain

  1. cn2: create database exp_no_gate_182841988883 commits at TS 1773858521999921877
  2. cn1: txn with snapshot TS 1773858521993681333 tries to access the database
  3. Engine.Database() returns ExpectedEOB (database not found in snapshot view)
  4. getSubscriptionMeta wraps all errors into moerr.NewNoDB(ctx)
  5. User sees misleading "No database selected" instead of visibility issue

Root Cause

  1. Snapshot Timestamp Too Early: cn1's transaction snapshot predates the database commit
  2. ExpectedEOB Misleading Error: publication_subscription.go:1630 converts all errors to "No database selected"
  3. Missing Retry Logic: No mechanism to retry when database becomes visible

Code Issue

// publication_subscription.go:1630
dbMeta, err := getPu(ses.GetService()).StorageEngine.Database(ctx, dbName, txn)
if err != nil {
ses.Errorf(ctx, "Get Subscription database %s meta error: %s", dbName, err.Error())
return nil, moerr.NewNoDB(ctx) // ← Wrong: converts ExpectedEOB to "No database selected"
}

Suggested Fix

  1. Distinguish between "database does not exist" (ExpectedEOB) and "no database selected" (NewNoDB)
  2. Add retry logic when database is not yet visible in snapshot
  3. Or ensure data branch create table waits until target database is visible

Activity

  1. added this to the MO-202603 milestone on Mar 19, 2026
  2. added
    kind/bug
    severity/s0
    on Mar 19, 2026
  3. added theissue type on Mar 19, 2026
  4. added
    ai-heavy
    and removed
    severity/s0
    on Jul 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

ai-heavydeferredkind/bug

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions