diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/Database.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/Database.java
index 548119dfb7..2d7359a9f1 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/catalog/Database.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/Database.java
@@ -30,6 +30,8 @@ import org.apache.doris.common.io.Text;
import org.apache.doris.common.io.Writable;
import org.apache.doris.common.util.DebugUtil;
import org.apache.doris.common.util.PropertyAnalyzer;
+import org.apache.doris.common.util.QueryableReentrantReadWriteLock;
+import org.apache.doris.common.util.Util;
import org.apache.doris.datasource.CatalogIf;
import org.apache.doris.persist.CreateTableInfo;
import org.apache.doris.persist.gson.GsonUtils;
@@ -58,7 +60,6 @@ import java.util.Objects;
import java.util.Set;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.TimeUnit;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.stream.Collectors;
/**
@@ -83,7 +84,8 @@ public class Database extends MetaObject implements Writable, DatabaseIf
private long id;
@SerializedName(value = "fullQualifiedName")
private volatile String fullQualifiedName;
- private final ReentrantReadWriteLock rwLock;
+
+ private QueryableReentrantReadWriteLock rwLock;
// table family group map
private final Map idToTable;
@@ -133,7 +135,7 @@ public class Database extends MetaObject implements Writable, DatabaseIf
if (this.fullQualifiedName == null) {
this.fullQualifiedName = "";
}
- this.rwLock = new ReentrantReadWriteLock(true);
+ this.rwLock = new QueryableReentrantReadWriteLock(true);
this.idToTable = Maps.newConcurrentMap();
this.nameToTable = Maps.newConcurrentMap();
this.lowerCaseToTableName = Maps.newConcurrentMap();
@@ -173,7 +175,14 @@ public class Database extends MetaObject implements Writable, DatabaseIf
public boolean tryWriteLock(long timeout, TimeUnit unit) {
try {
- return this.rwLock.writeLock().tryLock(timeout, unit);
+ if (!this.rwLock.writeLock().tryLock(timeout, unit)) {
+ Thread owner = this.rwLock.getOwner();
+ if (owner != null) {
+ LOG.info("database[{}] lock is held by: {}", getName(), Util.dumpThread(owner, 10));
+ }
+ return false;
+ }
+ return true;
} catch (InterruptedException e) {
LOG.warn("failed to try write lock at db[" + id + "]", e);
return false;