zhangbutao commented on code in PR #6088:
URL: https://github.com/apache/hive/pull/6088#discussion_r2564478222


##########
ql/src/java/org/apache/hadoop/hive/ql/lockmgr/HiveTxnManagerImpl.java:
##########
@@ -162,7 +167,8 @@ public int lockDatabase(Hive hiveDB, LockDatabaseDesc 
lockDb) throws HiveExcepti
             String.valueOf(System.currentTimeMillis()),
             "EXPLICIT", lockDb.getQueryStr(), conf);
 
-    HiveLock lck = lockMgr.lock(new HiveLockObject(dbObj.getName(), lockData), 
mode, true);
+    // Using the catalogName@databaseName format to uniquely identify a 
database.
+    HiveLock lck = lockMgr.lock(new HiveLockObject(catName + "@" 
+dbObj.getName(), lockData), mode, true);

Review Comment:
   Fixed in 
https://github.com/apache/hive/pull/6088/commits/88a24cd836431409358a643dfa570de2141aba5a
   
   I suddenly realized that this hack isn't a good approach. I referenced the 
method for obtaining lock objects for tables and created a similar method for 
databases, which might be better.
   
   Additionally, I noticed that the SHOW LOCKS statement could only display 
table-related locks but not database-related locks.
   Here's the test query, referenced from lockneg_try_lock_db_in_use.q:
   ```
   set hive.lock.numretries=0;
   set hive.support.concurrency=true;
   create database lockneg2;
   
   lock database lockneg2 shared;
   show locks;
   ```
   
   After this code optimization 
https://github.com/apache/hive/pull/6088/commits/88a24cd836431409358a643dfa570de2141aba5a,
 the lock information for lockneg2 can now be seen:
   ```
   0: jdbc:hive2://127.0.0.1:10000/default> show locks;
   INFO  : Compiling 
command(queryId=hive_20251126170301_32696de3-7d1e-490f-a3b4-d956be706897): show 
locks
   +----------------+---------+
   |    tab_name    |  mode   |
   +----------------+---------+
   | hive@lockneg2  | SHARED  |
   +----------------+---------+
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to