Skip to content

[Bug]: Transient 'Unknown database' (Error 1049) for a database that just executed DDL successfully (tenant account) #25512

Closed as not planned

Description

@endlesschasey-ai

Is there an existing issue for the same bug?

  • I have checked the existing issues.

Branch Name

v4.0.0-rc4 (official docker image registry.cn-shanghai.aliyuncs.com/matrixorigin/matrixone:4.0.0-rc4)

Commit ID

unknown (image tag 4.0.0-rc4)

Other Environment Information

  • Hardware parameters: amd64 Linux CI runner (docker-in-docker), single-node MatrixOne launched from the official image
  • OS type: Linux
  • Others: MySQL protocol on port 6001. The workload is a tenant-upgrade pipeline: it connects as a non-sys tenant account (account:user login) with DBName=moi and executes a chain of DDL migrations against that tenant's moi database, while other test groups concurrently run CREATE/DROP DATABASE and CREATE ACCOUNT elsewhere on the same instance.

Actual Behavior

In the middle of a migration chain, a CREATE TABLE IF NOT EXISTS statement transiently fails with Error 1049 (HY000): Unknown database moi — for a database in which the two immediately preceding migration steps had just executed DDL successfully (seconds earlier, same tenant account, same connection parameters).

Raw state dump from the failing run (2026-07-07; tasks id=39/40 completed fine in database moi, task id=41 then hit 1049):

tenant upgrade failed: task_id=41 target=1.0.0.60 error_class=transient
error=ensure tenant migration table: Error 1049 (HY000): Unknown database moi
tenant_tasks=[
  {id=41 target=1.0.0.60 attempts=1 last_error="ensure tenant migration table: Error 1049 (HY000): Unknown database moi"},
  {id=40 target=1.0.0.55 state=completed},
  {id=39 target=1.0.0.52 state=completed}]

The database obviously still exists: a scheduler retry of the same statement succeeds, and the same test passed on the rerun of the identical commit. Frequency is roughly one occurrence per dozens of full CI runs.

Expected Behavior

A database that exists (and just successfully executed DDL in the same session lineage) must never be reported as Unknown database to a subsequent statement. Catalog visibility of committed objects should be monotonic.

Steps to Reproduce

No minimal standalone repro yet — observed as a low-frequency race under the MOI integration suite's tenant-upgrade tests with concurrent multi-tenant DDL on the same instance. Evidence trail: matrixorigin/matrixflow#12822 (internal, signature 2); CI job with raw logs: https://github.com/matrixorigin/matrixflow/actions/runs/28841569270/job/85542178472 (internal, attempt 1).

Additional information

Likely the same visibility root class as the sibling reports filed alongside this one (transient FK-parent-not-visible Error 1452, and transient tenant-account-not-found) — three facets of committed-object visibility under concurrent multi-tenant DDL load.

Activity

  1. endlesschasey-ai commented on Jul 7, 2026

    @endlesschasey-ai
    Author

    Third independent occurrence within ~27h, same fingerprint on yet another branch/workspace/runner (2026-07-07T08:27Z, branch fix-10739):

    tenant upgrade failed: task_id=39 target=1.0.0.60 error_class=transient
    error=ensure tenant migration table: Error 1049 (HY000): Unknown database moi
    tenant_tasks=[{id=39 target=1.0.0.60 attempts=1 last_error="...Unknown database moi"},
                  {id=38 target=1.0.0.55 state=completed}, {id=37 target=1.0.0.52 state=completed}]
    

    Again: offsets .52/.55 had just executed DDL successfully in the same tenant database seconds earlier, then .60 got Unknown database. Frequency is roughly 2-3 hits per day across the CI fleet.

  2. aptend commented on Jul 7, 2026

    @aptend
    Contributor

    I checked the raw logs from the failing attempt (matrixorigin/matrixflow/actions/runs/28841569270, attempt 1, job 85542178472). This looks like the same test lifecycle race as #25513, not a committed-catalog visibility issue.

    Timeline for the failing workspace:

    UTC Event
    05:39:19.158 MatrixFlow created workspace bf6b3dd3-6d14-bea6-198c-61c412bdddea, account ws_b33da816.
    05:39:36.225 sys:dump started dropAccount ws_b33da816 and selected mo_catalog.__mo_account_lock ... for update.
    05:39:36.812 dropAccount started drop database if exists moi.
    05:39:39.401 dropAccount deleted mo_catalog.mo_account row for ws_b33da816.
    05:39:39.497 TN handled drop of moi_tenant_schema_migrations under database moi, txn ...4c17df.
    05:39:39.518 TN committed the drop DDL txn ...4c17df: [Committed].
    05:39:39.542 Tenant worker for account id 71 read database moi and got engine.database.not-found.in-cache.
    05:39:39.543 Same tenant worker/account ws_b33da816 failed CREATE TABLE IF NOT EXISTS moi_tenant_schema_migrations ... with Unknown database moi.

    So the observed Unknown database moi happened after the same account's DROP ACCOUNT had already committed and dropped moi. The tenant upgrade worker continued to use a tenant that the test cleanup/drop path had just removed.

    Key log references from the artifact:

    • coverage/logs/auto-upgrade.log:10219 workspace/account creation: bf6b3dd3..., ws_b33da816
    • coverage/logs/auto-upgrade.log:10249 failing task task_id=41, target 1.0.0.60, Unknown database moi
    • logs/matrixone-docker.log:471282 dropAccount ws_b33da816 begins
    • logs/matrixone-docker.log:471895 drop database if exists moi
    • logs/matrixone-docker.log:473324 delete from mo_catalog.mo_account for ws_b33da816
    • logs/matrixone-docker.log:473777 drop relation moi_tenant_schema_migrations in database moi
    • logs/matrixone-docker.log:473820 TN commit [Committed] for txn ...4c17df
    • logs/matrixone-docker.log:473867 engine.database.not-found.in-cache, name=moi, account-id=71
    • logs/matrixone-docker.log:473880 failed CREATE TABLE IF NOT EXISTS moi_tenant_schema_migrations ..., Unknown database moi, account ws_b33da816

    Conclusion: this issue should be treated as a MatrixFlow/MOI test framework cleanup vs tenant-upgrade-worker race. It does not show MO losing visibility of an existing committed database.

  3. added
    severity/s0
    and removed on Jul 7, 2026
  4. added theissue type on Jul 7, 2026
  5. added this to the MO-202607 milestone on Jul 7, 2026
  6. assigned and unassigned on Jul 7, 2026
  7. XuPeng-SH commented on Jul 7, 2026

    @XuPeng-SH
    Contributor

    @heni02 please help to close it

  8. endlesschasey-ai commented on Jul 7, 2026

    @endlesschasey-ai
    Author

    @aptend Thank you for the thorough timeline — you are right, and we have now traced the exact origin on our side.

    The dropper is CleanupSuiteOrphanedMOAccounts in the MatrixFlow test framework: our CI runs make ci-test and make test-python-sdk in parallel against the same MO instance, and the python-sdk integration step is itself another go test process of the same tests package. When it finishes, its TestMain sweeps "orphaned" test accounts (SHOW ACCOUNTS → drop everything whose admin user has the test_ prefix, 2s timeout per drop — which matches the exact 2-second drop cadence in the MO logs at 05:39:20-05:39:48, catching ws_b33da816 that the concurrently running auto-upgrade test had created 17s earlier).

    Confirmed not an MO bug. Closing; the fix (scoping the sweeper / serializing the parallel suites) will land in MatrixFlow. Sorry for the noise, and thanks again for the txn-level analysis.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugseverity/s0

    Type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions