branch-3.0: [fix](database) Fix insert into race with drop table #55264#55347
Merged
dataroaring merged 1 commit intobranch-3.0from Sep 5, 2025
Merged
branch-3.0: [fix](database) Fix insert into race with drop table #55264#55347dataroaring merged 1 commit intobranch-3.0from
insert into race with drop table #55264#55347dataroaring merged 1 commit intobranch-3.0from
Conversation
### What problem does this PR solve?
1. insert into hold table lock to get db lock in function
getUsedDataQuotaWithLock
2. drop table hold db lock to get table lock
3. deadlock
```
"mysql-nio-pool-371" #1548056 daemon prio=5 os_prio=0 cpu=39804.63ms elapsed=6822.19s tid=0x00007fd16c224d60 nid=0x407f1 waiting on condition [0x00007fcffccfa000]
java.lang.Thread.State: WAITING (parking)
at jdk.internal.misc.Unsafe.park(java.base@17.0.2/Native Method)
- parking to wait for <0x00007fd42bd9b588> (a java.util.concurrent.locks.ReentrantReadWriteLock$FairSync)
at java.util.concurrent.locks.LockSupport.park(java.base@17.0.2/LockSupport.java:211)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(java.base@17.0.2/AbstractQueuedSynchronizer.java:715)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireShared(java.base@17.0.2/AbstractQueuedSynchronizer.java:1027)
at java.util.concurrent.locks.ReentrantReadWriteLock$ReadLock.lock(java.base@17.0.2/ReentrantReadWriteLock.java:738)
at org.apache.doris.common.lock.MonitoredReentrantReadWriteLock$ReadLock.lock(MonitoredReentrantReadWriteLock.java:69)
at org.apache.doris.catalog.Database.readLock(Database.java:166)
at org.apache.doris.catalog.Database.getUsedDataSize(Database.java:307)
at org.apache.doris.catalog.Database.getUsedDataQuotaWithLock(Database.java:300)
at org.apache.doris.transaction.DatabaseTransactionMgr.checkDatabaseDataQuota(DatabaseTransactionMgr.java:387)
at org.apache.doris.transaction.DatabaseTransactionMgr.beginTransaction(DatabaseTransactionMgr.java:324)
at org.apache.doris.transaction.GlobalTransactionMgr.beginTransaction(GlobalTransactionMgr.java:175)
at org.apache.doris.transaction.GlobalTransactionMgr.beginTransaction(GlobalTransactionMgr.java:139)
at org.apache.doris.nereids.trees.plans.commands.insert.OlapInsertExecutor.beginTransaction(OlapInsertExecutor.java:100)
at org.apache.doris.nereids.trees.plans.commands.insert.InsertIntoTableCommand.initPlan(InsertIntoTableCommand.java:256)
at org.apache.doris.nereids.trees.plans.commands.insert.InsertIntoTableCommand.initPlan(InsertIntoTableCommand.java:195)
at org.apache.doris.nereids.trees.plans.commands.insert.InsertIntoTableCommand.runInternal(InsertIntoTableCommand.java:495)
at org.apache.doris.nereids.trees.plans.commands.insert.InsertIntoTableCommand.run(InsertIntoTableCommand.java:179)
at org.apache.doris.qe.StmtExecutor.executeByNereids(StmtExecutor.java:657)
at org.apache.doris.qe.StmtExecutor.execute(StmtExecutor.java:525)
at org.apache.doris.qe.StmtExecutor.queryRetry(StmtExecutor.java:487)
at org.apache.doris.qe.StmtExecutor.execute(StmtExecutor.java:472)
at org.apache.doris.qe.ConnectProcessor.executeQuery(ConnectProcessor.java:349)
at org.apache.doris.qe.ConnectProcessor.handleQuery(ConnectProcessor.java:249)
at org.apache.doris.qe.MysqlConnectProcessor.handleQuery(MysqlConnectProcessor.java:233)
at org.apache.doris.qe.MysqlConnectProcessor.dispatch(MysqlConnectProcessor.java:261)
at org.apache.doris.qe.MysqlConnectProcessor.processOnce(MysqlConnectProcessor.java:443)
at org.apache.doris.mysql.ReadListener.lambda$handleEvent$0(ReadListener.java:52)
at org.apache.doris.mysql.ReadListener$$Lambda$1480/0x0000000801baec60.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(java.base@17.0.2/ThreadPoolExecutor.java:1136)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(java.base@17.0.2/ThreadPoolExecutor.java:635)
at java.lang.Thread.run(java.base@17.0.2/Thread.java:833)
Locked ownable synchronizers:
- <0x00007fd2e3bdcca0> (a java.util.concurrent.ThreadPoolExecutor$Worker)
"mysql-nio-pool-367" #1548052 daemon prio=5 os_prio=0 cpu=34141.80ms elapsed=6822.19s tid=0x00007fd16800f040 nid=0x407ed waiting on condition [0x00007fcffd4fe000]
java.lang.Thread.State: WAITING (parking)
at jdk.internal.misc.Unsafe.park(java.base@17.0.2/Native Method)
- parking to wait for <0x00007fd42bd77428> (a java.util.concurrent.locks.ReentrantReadWriteLock$FairSync)
at java.util.concurrent.locks.LockSupport.park(java.base@17.0.2/LockSupport.java:211)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(java.base@17.0.2/AbstractQueuedSynchronizer.java:715)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(java.base@17.0.2/AbstractQueuedSynchronizer.java:938)
at java.util.concurrent.locks.ReentrantReadWriteLock$WriteLock.lock(java.base@17.0.2/ReentrantReadWriteLock.java:959)
at org.apache.doris.common.lock.MonitoredReentrantReadWriteLock$WriteLock.lock(MonitoredReentrantReadWriteLock.java:106)
at org.apache.doris.catalog.Table.writeLock(Table.java:234)
at org.apache.doris.datasource.InternalCatalog.dropTableInternal(InternalCatalog.java:953)
at org.apache.doris.datasource.InternalCatalog.dropTable(InternalCatalog.java:921)
at org.apache.doris.catalog.Env.dropTable(Env.java:4791)
at org.apache.doris.nereids.trees.plans.commands.DropTableCommand.run(DropTableCommand.java:79)
at org.apache.doris.qe.StmtExecutor.executeByNereids(StmtExecutor.java:657)
at org.apache.doris.qe.StmtExecutor.execute(StmtExecutor.java:525)
at org.apache.doris.qe.StmtExecutor.queryRetry(StmtExecutor.java:487)
at org.apache.doris.qe.StmtExecutor.execute(StmtExecutor.java:472)
at org.apache.doris.qe.ConnectProcessor.executeQuery(ConnectProcessor.java:349)
at org.apache.doris.qe.ConnectProcessor.handleQuery(ConnectProcessor.java:249)
at org.apache.doris.qe.MysqlConnectProcessor.handleQuery(MysqlConnectProcessor.java:233)
at org.apache.doris.qe.MysqlConnectProcessor.dispatch(MysqlConnectProcessor.java:261)
at org.apache.doris.qe.MysqlConnectProcessor.processOnce(MysqlConnectProcessor.java:443)
at org.apache.doris.mysql.ReadListener.lambda$handleEvent$0(ReadListener.java:52)
at org.apache.doris.mysql.ReadListener$$Lambda$1480/0x0000000801baec60.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(java.base@17.0.2/ThreadPoolExecutor.java:1136)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(java.base@17.0.2/ThreadPoolExecutor.java:635)
at java.lang.Thread.run(java.base@17.0.2/Thread.java:833)
Locked ownable synchronizers:
- <0x00007fd2e3b8fc08> (a java.util.concurrent.ThreadPoolExecutor$Worker)
- <0x00007fd42bd9b588> (a java.util.concurrent.locks.ReentrantReadWriteLock$FairSync)
```
Issue Number: close #xxx
Related PR: #xxx
Problem Summary:
### Release note
None
### Check List (For Author)
- Test <!-- At least one of them must be included. -->
- [ ] Regression test
- [ ] Unit Test
- [ ] Manual test (add detailed scripts or steps below)
- [ ] No need to test or manual test. Explain why:
- [ ] This is a refactor/code format and no logic has been changed.
- [x] Previous test can cover this change.
- [ ] No code files have been changed.
- [ ] Other reason <!-- Add your reason? -->
- Behavior changed:
- [x] No.
- [ ] Yes. <!-- Explain the behavior change -->
- Does this need documentation?
- [x] No.
- [ ] Yes. <!-- Add document PR link here. eg:
apache/doris-website#1214 -->
### Check List (For Reviewer who merge this PR)
- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label <!-- Add branch pick label that this PR
should merge into -->
Contributor
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
Contributor
|
run buildall |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cherry-picked from #55264