Repository navigation
Description
Is there an existing issue for the same bug?
- I have checked the existing issues.
Searched open and closed issues for DROP ACCOUNT + clone/reindex/lock, FastFail, lock options conflict + clone, and the failing run ID. Related issues are distinguished below.
Branch Name
move-aobject-create-outside-txn-v2, targeting main (PR #30629).
Commit ID
817b06715df4671fbdf4fa9a37ec00d5827992cb — head SHA recorded by the failing workflow.
Other Environment Information
- Linux/x64, multi-CN Compose BVT, pessimistic transactions.
- Run 40156869915, attempt 1.
- Failing job 121061954291, step
Start BVT Test. - Diagnostic artifact: 12585499065,
Compose-multi-CN-e2e-BVT-Test-on-Linux-x64(PESSIMISTIC)-reports-attempt-1. - Evidence inspected: mo-tester report, CN1 log and TN log. No local runtime reproduction or clean-base comparison has been performed for this occurrence.
Actual Behavior
The sequential clone BVT fails during tenant teardown:
test/distributed/cases/pessimistic_transaction/clone/clone.sql:719
SQL: drop account acc05;
Expected: success
Actual: lock options conflict, wait policy is fast fail
This case reports 561 statements: 559 successful, 1 failed, 1 ignored. These are case-level counts, not the whole job's totals.
The account-drop internal transaction fails while deleting test13_new_new. At the same time, a background transaction is rebuilding that database's cloned HNSW index and publishing its ISCP initialization state.
Relevant server log excerpts, 2026-10-25 UTC:
03:23:34.825003 CN1 sql_executor exec:
SELECT ... FROM test13_new_new.vector_ip_01 ... CROSS APPLY hnsw_create(...)
txn-id: 70f70f4866a9b62a18e1a762cd670c87
03:23:34.833843 CN1:
dropAccount acc05 sql: drop database if exists `test13_new_new`;
outer txn: 70f70f4866a9b62a18e1a762cd670c7c
03:23:34.836354 CN1:
UPDATE mo_catalog.mo_iscp_log SET job_state = 3, ... job_status ...
txn-id: 70f70f4866a9b62a18e1a762cd670c87
03:23:34.837611 CN1 failed to lock on local:
txn: 70f70f4866a9b62a18e1a762cd670c7e
table: 1
row count: 1
opts: Exclusive-Row-FastFail
error: lock options conflict, wait policy is fast fail
03:23:34.838586 CN1:
statement: drop account acc05
status: fail
03:23:34.839101 TN tn.handle.commit.with.ddl:
txn: 70f70f4866a9b62a18e1a762cd670c87
state: Committed
Table ID 1 is mo_catalog.mo_database. The internal DROP transaction ...c7e rolls back, and the lock conflict propagates to the user statement. This is an immediate lock-conflict rejection, not a long lock-wait timeout or an observed HNSW build failure.
Expected Behavior
Keep index initialization asynchronous and preserve the lifecycle lock-order/FastFail protection. A short-lived internal background-maintenance conflict should have a bounded, transaction-safe recovery path for standalone DROP ACCOUNT, instead of immediately failing otherwise valid tenant teardown.
Cancellation and persistent contention must remain bounded and observable. Do not promise eventual success under arbitrary sustained concurrent DDL, suppress genuine errors, change expected results to accept failure, or introduce an unbounded retry loop.
Steps to Reproduce
The executed evidence is the linked CI run. To investigate the original scheduling-sensitive trigger:
- Use the recorded revision and the multi-CN pessimistic BVT topology.
- Run the original clone.sql.
- Preserve its two clone generations:
test13 -> test13_new -> test13_new_new, including HNSW-indexed tables. - The script waits for index initialization on
test13_newat lines 655–669, but does not wait for the second generation beforeDROP ACCOUNT acc05at line 719. - Correlate DROP's result with background HNSW initialization transactions and the database-name lock.
This is not a claim that every rerun reproduces the failure. A deterministic regression should control the real background transaction after it owns the database shared lock and before commit, then exercise DROP ACCOUNT and release the blocker. Capture the holder/key to close the remaining attribution gap.
Additional information
Mechanism and evidence boundary
- ALTER TABLE INPLACE, used by ALTER REINDEX, takes a shared database metadata lock. ISCP initialization executes initialization and its lifecycle-state update in one transaction, finishing that transaction afterward.
- DROP ACCOUNT owns an internal transaction, enters lifecycle admission and performs tenant cleanup before its database-drop loop. Those locks remain held until transaction completion.
- Lifecycle admission selects FastFail when the caller retains non-private locks; its database-lock path also uses FastFail for an exclusive snapshot gate. This protects against reverse lock-order waits.
- A conflicting database lock is therefore returned as an error from the DROP loop, and the existing transaction cleanup rolls back. There is no bounded whole-operation retry here.
- The second-clone test has no initialization-completion barrier. Ordinary SELECT success does not establish that background index DDL has committed.
Confirmed: database-row exclusive FastFail rejection during DROP ACCOUNT, propagation/rollback, and overlapping HNSW initialization that subsequently commits.
Strongly supported but not fully captured: that specific HNSW transaction is the conflicting lock holder. The failure log omits the holder identity and row key; cross-service timestamps alone do not prove the precise ownership interval.
Not established: a regression introduced by #30629, an affected release range, data corruption, or a clean-main reproduction.
Proposed bounded fix and acceptance
Keep the asynchronous design and existing lock protocol. Evaluate recovery at the standalone DROP ACCOUNT transaction owner:
- Retry only a narrowly identified, pre-commit lifecycle lock conflict after a confirmed successful full rollback. Release all locks before a context-cancellable bounded backoff; start a new transaction and re-read catalog identities.
- Do not retry an individual DROP DATABASE while retaining the failed transaction's earlier locks.
- Keep per-attempt lists/results local to the attempt. Run post-commit side effects once. Reuse existing transaction machinery; audit the current nested BEGIN/finish ownership rather than add another overlapping transaction owner.
- Do not replay permission/semantic errors, failed rollback, uncertain commit outcomes or post-commit failures. A restore call borrowing an outer transaction must leave recovery to that owner.
- No new polling or scans on ordinary SQL/index-build paths; retry cost is confined to the contended teardown path and must be bounded.
For the existing clone functional BVT, add an observable completion barrier for the second clone rather than a fixed sleep. Separately preserve a deterministic concurrency test that deliberately overlaps initialization and teardown, so the barrier does not hide the production behavior.
Validate conflict-then-success, continuous conflict exhausting the bound, cancellation during backoff, rollback failure, borrowed-transaction behavior, and no duplicated post-commit effects. Check tenant/catalog atomicity and absence of leaked locks after failure.
This is a proposed scope, not an implemented or validated fix.
Related but distinct
- [Bug]: Fulltext2 DROP DATABASE deadlocks with ISCP watermark flush in pessimistic BVT #31063: Fulltext2 DROP DATABASE versus batched ISCP watermark updates, with a captured
mo_iscp_logrow-lock deadlock cycle. This occurrence is database metadata FastFail, without a captured cycle. - [Bug]: CREATE OR REPLACE VIEW takes database locks before lifecycle admission and spuriously FastFails #30090: CREATE OR REPLACE VIEW manufactured retained locks before lifecycle admission. DROP ACCOUNT legitimately already owns cleanup/lifecycle locks.
- [Bug]: DROP ACCOUNT and cluster-table DELETE deadlock on inverted table/SNAPSHOT lifecycle locks #29335: DROP ACCOUNT versus cluster-table DELETE/TRUNCATE lock-order deadlock.
- [Bug]: Slow DROP DATABASE blocks unrelated database DDL on the global SNAPSHOT lifecycle gate #29400: unrelated-database DDL convoy on the global SNAPSHOT gate; changing that architecture is outside this issue's proposed scope.
Activity
fix: resolve async index lock contention during catalog teardown (#31076