From 39dea916b3a35c27c1c745fbd2a8f170975f4ec0 Mon Sep 17 00:00:00 2001 From: apoonia Date: Thu, 23 Oct 2025 23:45:01 +0530 Subject: [PATCH] HBASE-29684 Replication peer config is not honored in few cases --- .../ReplicationPeerConfigUtil.java | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/replication/ReplicationPeerConfigUtil.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/replication/ReplicationPeerConfigUtil.java index 5618a4166afe..a81619f0f468 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/replication/ReplicationPeerConfigUtil.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/replication/ReplicationPeerConfigUtil.java @@ -431,14 +431,19 @@ public static ReplicationPeerConfig appendTableCFsToReplicationPeerConfig( } /** - * Helper method to add/removev base peer configs from Configuration to ReplicationPeerConfig This - * merges the user supplied peer configuration - * {@link org.apache.hadoop.hbase.replication.ReplicationPeerConfig} with peer configs provided as - * property hbase.replication.peer.base.configs in hbase configuration. Expected format for this - * hbase configuration is "k1=v1;k2=v2,v2_1;k3=""". If value is empty, it will remove the existing - * key-value from peer config. + * Helper method to add/remove base peer configs from Configuration to ReplicationPeerConfig. + * + * Precedence rules: + * - If a key exists in both the provided ReplicationPeerConfig and base configs, the value in the + * provided ReplicationPeerConfig is preserved (user-provided wins). + * - If a key exists only in base configs (non-empty), it is added to the ReplicationPeerConfig. + * - If a key exists in base configs with an empty value (e.g. k1=""), the key is removed from + * the ReplicationPeerConfig. + * + * The base configs come from the property hbase.replication.peer.base.config in the HBase + * configuration. Expected format: "k1=v1;k2=v2,v2_1;k3=\"\"". * @param conf Configuration - * @return ReplicationPeerConfig containing updated configs. + * @return ReplicationPeerConfig containing updated configs per the precedence rules above. */ public static ReplicationPeerConfig updateReplicationBasePeerConfigs(Configuration conf, ReplicationPeerConfig receivedPeerConfig) { @@ -458,8 +463,8 @@ public static ReplicationPeerConfig updateReplicationBasePeerConfigs(Configurati // is required so that it doesn't remove any other config unknowingly. if (Strings.isNullOrEmpty(configValue)) { copiedPeerConfigBuilder.removeConfiguration(configName); - } else if (!receivedPeerConfigMap.getOrDefault(configName, "").equals(configValue)) { - // update the configuration if exact config and value doesn't exists + } else if (!receivedPeerConfigMap.containsKey(configName)) { + // Only add base config if the key is absent in the provided config copiedPeerConfigBuilder.putConfiguration(configName, configValue); } }