You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by de...@apache.org on 2026/08/03 06:52:58 UTC

(hive) branch master updated: HIVE-29762: Synchronization logic added as a part of HIVE-24428 is having hash collision issue. (#6651)

This is an automated email from the ASF dual-hosted git repository.

dengzhhu653 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git


The following commit(s) were added to refs/heads/master by this push:
     new 569c064edc3 HIVE-29762: Synchronization logic added as a part of HIVE-24428 is having hash collision issue. (#6651)
569c064edc3 is described below

commit 569c064edc3813409362d6b8bb914828fe9d145e
Author: Dayakar M <da...@gmail.com>
AuthorDate: Mon Aug 3 12:22:52 2026 +0530

    HIVE-29762: Synchronization logic added as a part of HIVE-24428 is having hash collision issue. (#6651)
---
 .../java/org/apache/hadoop/hive/metastore/conf/MetastoreConf.java | 8 ++++++--
 .../org/apache/hadoop/hive/metastore/handler/BaseHandler.java     | 5 ++++-
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/conf/MetastoreConf.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/conf/MetastoreConf.java
index 3a4d7a173d4..b03bed9b51e 100644
--- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/conf/MetastoreConf.java
+++ b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/conf/MetastoreConf.java
@@ -2017,8 +2017,12 @@ public enum ConfVars {
             + "e.g. javax.net.ssl.trustStore=/tmp/truststore,javax.net.ssl.trustStorePassword=pwd.\n " +
             "If both this and the metastore.dbaccess.ssl.* properties are set, then the latter properties \n" +
             "will overwrite what was set in the deprecated property."),
-    METASTORE_NUM_STRIPED_TABLE_LOCKS("metastore.num.striped.table.locks", "hive.metastore.num.striped.table.locks", 32,
-        "Number of striped locks available to provide exclusive operation support for critical table operations like add_partitions."),
+    METASTORE_NUM_STRIPED_TABLE_LOCKS(
+        "metastore.num.striped.table.locks", "hive.metastore.num.striped.table.locks", 65536,
+        "Number of striped locks available to provide exclusive operation support for critical table "
+            + "operations like add_partitions.\n The locks are lazily allocated and weakly referenced "
+            + "so unused stripes will not impose memory cost.\n A larger value reduces the probability of "
+            + "hash-collision-induced false contention between unrelated tables."),
     COLSTATS_RETAIN_ON_COLUMN_REMOVAL("metastore.colstats.retain.on.column.removal",
         "hive.metastore.colstats.retain.on.column.removal", true,
         "Whether to retain column statistics during column removals in partitioned tables - disabling this "
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/handler/BaseHandler.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/handler/BaseHandler.java
index 5c4f5d868ba..4664529ccd9 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/handler/BaseHandler.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/handler/BaseHandler.java
@@ -271,7 +271,10 @@ private void initDefaultSchema() throws MetaException {
       if (tablelocks == null) {
         int numTableLocks = MetastoreConf.getIntVar(conf,
             MetastoreConf.ConfVars.METASTORE_NUM_STRIPED_TABLE_LOCKS);
-        tablelocks = Striped.lock(numTableLocks);
+        // lazyWeakLock: lock objects are allocated on first use and held via weak references,
+        // so unused stripes are GC'd. A large stripe count keeps hash collisions between
+        // unrelated (db, tbl) keys without paying permanent memory cost.
+        tablelocks = Striped.lazyWeakLock(numTableLocks);
       }
     }
   }