Skip to content

CREATE ACCOUNT returns before tenant is visible across all CNs (race condition in multi-CN cluster) #25520

Closed

Description

@Ariznawlll

Summary

CREATE ACCOUNT IF NOT EXISTS returns success but the newly created tenant is not immediately visible on other CN nodes. Subsequent connections routed to a different CN via proxy fail with ERROR 20101: internal error: there is no tenant <name>.

The tenant becomes visible after a few seconds (~7s observed), indicating asynchronous metadata propagation rather than synchronous commit.

Environment

Reproduction

# Step 1: Create account (routed to CN-A via proxy)
mysql -h <proxy> -udump -P6001 -p111 \
  -e "create account if not exists ac1 ADMIN_NAME 'admin' IDENTIFIED BY '123'";

# Step 2: Immediately connect as new account (may route to CN-B via proxy)
mysql -h <proxy> -uac1:admin -P6001 -p123 \
  -e "set global experimental_ivf_index=1";
# => ERROR 20101 (HY000): internal error: there is no tenant ac1

Timeline from CI log

23:36:14.723  CREATE ACCOUNT IF NOT EXISTS ac1   returns OK
23:36:15.216  mysql -uac1:admin ... set global   FAIL: there is no tenant ac1
              (only ~0.5s gap)
23:36:22.301  cdc_test.py connects as ac1:admin   SUCCESS
              (~7s after CREATE ACCOUNT)

Root Cause Analysis

In a multi-CN cluster behind a proxy:

  1. CREATE ACCOUNT executes on CN-A, writes metadata to shared storage
  2. CREATE ACCOUNT returns success to client
  3. Next connection is routed by proxy to CN-B
  4. CN-B has not yet synced the new tenant metadata => there is no tenant ac1
  5. After ~7s, metadata propagates to all CNs => connections succeed

This is a DDL visibility problem: CREATE ACCOUNT (a DDL operation) returns before the result is visible to all CN nodes.

Expected Behavior

CREATE ACCOUNT should ensure the new tenant is visible across all CNs before returning success to the client. This is consistent with how other DDL operations (CREATE TABLE, etc.) should behave in a multi-CN cluster -- the client should be able to use the created object immediately after the DDL returns.

Impact

  • CDC test fails intermittently (depends on proxy routing)
  • Any workflow that creates an account and immediately uses it will fail
  • Currently worked around with sleep between CREATE ACCOUNT and subsequent operations

Related Occurrences

This same error has been observed in multiple nightly runs:

Activity

  1. added
    kind/bug
    severity/s0
    on Jul 8, 2026
  2. added theissue type on Jul 8, 2026
  3. added this to the MO-202607 milestone on Jul 8, 2026
  4. matrix-meow commented on Jul 8, 2026

    @matrix-meow
    Contributor

    Related Issues (same root cause: multi-CN logtail propagation race)

    # State Title Scenario
    #25032 closed CREATE USER fails: 'there is no user attacker' CREATE USER → other CN can't read user
    #25513 closed mo_account transiently returns no row mo_account read before metadata arrives
    #23652 open get the default role of the user dump failed user/role metadata visibility on multi-CN
    #12043 closed 'there is no user admin' when altering account ALTER ACCOUNT → user not visible

    All share the same root cause: DDL writes return before logtail metadata propagates to all CN nodes. The ~7s propagation delay observed in this issue matches the behavior seen in #25032 (where logtail delay caused CREATE USER → connect failure within ~62ms on a different CN).

    This is a systemic issue requiring a DDL-level barrier to ensure metadata visibility across all CNs before returning success.

  5. Ariznawlll commented on Jul 8, 2026

    @Ariznawlll
    CollaboratorAuthor

    This is a session consistency issue across CN nodes, not a bug.

    In a multi-CN cluster, DDL metadata propagation is asynchronous. CREATE ACCOUNT returns after the local CN commits the metadata, but other CNs may not have synced it yet. Subsequent connections routed to a different CN via proxy may not see the new tenant.

    This is consistent with how distributed databases handle cross-node DDL visibility — the client may need to retry or wait briefly for metadata to propagate.

    Closing as expected behavior (session consistency).

  6. iamlinjunhong commented on Aug 14, 2026

    @iamlinjunhong
    Contributor

    Regression evidence from PR #27016 CI (the failure matches this issue's cross-CN visibility race).

    The BVT reporter attributed the first failure to test/distributed/cases/system_variable/system_variables.sql:124:

    2026-08-14 14:19:24 ERROR ... [drop account acc_idx;] MO does not return result in 300000 ms
    

    The complete CN/proxy logs show that the causal event happened earlier, while the script was switching to the newly created tenant:

    14:18:24.508 CN0 authenticate user failed: internal error: there is no tenant acc_idx (connectionId 957)
    14:18:24.514 CN0 authenticate user failed: internal error: there is no tenant acc_idx (connectionId 958)
    14:18:24.508 Proxy failed to connect to backend: Auth failed (ConnID 957)
    14:18:24.514 Proxy failed to connect to backend: Auth failed (ConnID 958)
    14:19:13.677 CN1 storage_usage.new_account name=acc_idx, created-time=14:18:24
    14:19:24.526 CN1 accepts acc_idx:root
    14:19:55.886 CN1 only then starts the retried dropAccount acc_idx cleanup
    

    Thus the reported DROP ACCOUNT timeout is downstream of the same behavior documented here: CREATE ACCOUNT was committed/visible on one CN, while an immediate proxy-routed tenant connection hit another CN that still returned there is no tenant acc_idx. The later wait_timeout mismatch and duplicate-account error are cascades after reconnect. The Coverage job did not expose another defect; its prerequisite step says coverage merge skipped because at least one required producer was skipped or failed.

    Comparison evidence:

    • Clean current main at f9af0064116f885ce68b0db4d94d4fafdc9bafc3, native 2-CN + Proxy topology: 50 consecutive create/connect/create-db/drop-db/drop-account cycles completed (drop-account 0.38–2.79s).
    • Exact PR head, same topology, mo-tester b95f5c09930c42bdbe77828b6ae72d39f2be48ed: the full system_variables.sql passed 175/175 in 3.668s; an additional 50-cycle loop also completed (0.62–3.44s per drop-account).
    • The PR changes only MySQL string metadata length calculation/tests (pkg/frontend/mysql_protocol.go, pkg/frontend/util.go, pkg/frontend/util_test.go); the direct cross-CN logs above are the independent cache/metadata-propagation evidence.

    Per the automated CI intake policy, I will request one failed-job rerun for run 31805711526 after this evidence comment is confirmed.

  7. iamlinjunhong commented on Aug 20, 2026

    @iamlinjunhong
    Contributor

    Regression evidence from PR #27157 CI; this matches the cross-CN account-visibility race tracked here.

    Stable BVT signature:

    05:04:30 system_variables.sql:121 drop account acc_idx;
    MO does not return result in 300000 ms
    05:05:01 system_variables.sql:183 show variables like 'wait_timeout';
    expected 10, actual 86400
    05:05:01 system_variables.sql:222 create account acc_idx ...
    internal error: the tenant acc_idx exists
    

    The complete CN/proxy logs expose the causal cache/metadata event before those reporter errors:

    05:03:29 CREATE ACCOUNT acc_idx committed (created-time recorded by storage usage)
    05:03:30.299 CN0 connection 843: internal error: there is no tenant acc_idx
    05:03:30.306 CN0 connection 844: internal error: there is no tenant acc_idx
    05:03:30.301/.307 Proxy: backend authentication failed for connections 843/844
    05:04:09.476 CN0 storage_usage.new_account first reports acc_idx, created-time 05:03:29
    05:05:01.403 Proxy routes the recovered dump session (connection 846) to CN1
    05:05:01.536 CN1: create account acc_idx -> tenant already exists
    05:05:01.584 CN1 starts the delayed dropAccount cleanup
    

    This is the same create-account → immediate cross-CN connect visibility behavior documented in this issue, with the later DROP timeout, session-variable mismatch, and duplicate-account error cascading after the failed tenant session. The coverage job has no independent product failure: Verify coverage prerequisites reports that coverage merge was skipped because a required producer failed.

    Comparison/independence evidence: the PR changes MongoDB default configuration/runtime metadata and related tests; it does not modify account creation, tenant authentication/cache propagation, proxy routing, or system_variables.sql. More importantly than diff distance, the current CI artifacts directly show the cross-CN cache inconsistency, and this issue already records the same behavior on clean main (00d2f57ca) and a prior independent PR. Current up/main was fetched at 592ad2190a90e063e3877059f4018427a10a4998; the local Darwin host has no Docker runtime, so I am using the direct cache evidence path allowed by the automated CI intake standard rather than claiming an unmatched local compose reproduction.

    The current PR head's reviewer regression also passes via the repository CGo wrapper:

    TestMongoDBParametersProgrammaticOptOutSurvivesRepeatedDefaulting PASS
    pkg/config PASS
    

    After this evidence comment is confirmed, I will request the single allowed failed-job rerun for run 32331886226.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bugseverity/s0

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions