From 26415b8fb7cfbaf2b1271b1f6477be52cb380266 Mon Sep 17 00:00:00 2001 From: srbiswal Date: Thu, 6 Aug 2026 13:52:31 -0700 Subject: [PATCH] HIVE-28405: Align hive.repl.cm.retain declared time unit with metastore (documentation only) hive.repl.cm.retain declared a DAYS-based TimeValidator, while the equivalent metastore config metastore.repl.cm.retain uses a HOURS base unit. A unit-less value (e.g. "10") was therefore documented as days here but interpreted as hours by the metastore, which is misleading. Change the HiveConf TimeValidator to HOURS and express the default as "240h" so the declared unit and value match the metastore counterpart. Add a TestHiveConf case asserting the default resolves to 10 days and that unit-less values are interpreted in hours. Documentation-only: HiveConf.REPL_CM_RETAIN is not read anywhere via getTimeVar and the default is unchanged (240h == 10d), so there is no functional impact. --- .../org/apache/hadoop/hive/conf/HiveConf.java | 7 ++++--- .../apache/hadoop/hive/conf/TestHiveConf.java | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java b/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java index 54516007d32a..c838cc70a3c5 100644 --- a/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java +++ b/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java @@ -401,9 +401,10 @@ public static enum ConfVars { "Turn on ChangeManager, so delete files will go to cmrootdir."), REPL_CM_DIR("hive.repl.cmrootdir","/user/${system:user.name}/cmroot/", "Root dir for ChangeManager, used for deleted files."), - REPL_CM_RETAIN("hive.repl.cm.retain","10d", - new TimeValidator(TimeUnit.DAYS), - "Time to retain removed files in cmrootdir."), + REPL_CM_RETAIN("hive.repl.cm.retain","240h", + new TimeValidator(TimeUnit.HOURS), + "Time to retain removed files in cmrootdir. A unit-less value is interpreted in hours, " + + "matching the metastore counterpart metastore.repl.cm.retain. Default is 240h (10 days)."), REPL_CM_ENCRYPTED_DIR("hive.repl.cm.encryptionzone.rootdir", ".cmroot", "Root dir for ChangeManager if encryption zones are enabled, used for deleted files."), REPL_CM_FALLBACK_NONENCRYPTED_DIR("hive.repl.cm.nonencryptionzone.rootdir", diff --git a/common/src/test/org/apache/hadoop/hive/conf/TestHiveConf.java b/common/src/test/org/apache/hadoop/hive/conf/TestHiveConf.java index a9b3c089c3f2..299abd0d44eb 100644 --- a/common/src/test/org/apache/hadoop/hive/conf/TestHiveConf.java +++ b/common/src/test/org/apache/hadoop/hive/conf/TestHiveConf.java @@ -124,6 +124,25 @@ public void testUnitFor() throws Exception { Assert.assertEquals(TimeUnit.NANOSECONDS, HiveConf.unitFor("nsecs", null)); } + @Test + public void testReplCmRetainTimeUnit() throws Exception { + HiveConf conf = new HiveConf(); + + // The default (240h) is 10 days. Guards against accidentally changing the default duration. + Assert.assertEquals(10, conf.getTimeVar(ConfVars.REPL_CM_RETAIN, TimeUnit.DAYS)); + Assert.assertEquals(240, conf.getTimeVar(ConfVars.REPL_CM_RETAIN, TimeUnit.HOURS)); + + // A unit-less value is interpreted in hours, matching the metastore counterpart + // metastore.repl.cm.retain, which uses a HOURS base unit. + Assert.assertEquals(TimeUnit.HOURS, HiveConf.getDefaultTimeUnit(ConfVars.REPL_CM_RETAIN)); + conf.setVar(ConfVars.REPL_CM_RETAIN, "10"); + Assert.assertEquals(10, conf.getTimeVar(ConfVars.REPL_CM_RETAIN, TimeUnit.HOURS)); + + // An explicit unit suffix is still honoured. + conf.setVar(ConfVars.REPL_CM_RETAIN, "10d"); + Assert.assertEquals(10, conf.getTimeVar(ConfVars.REPL_CM_RETAIN, TimeUnit.DAYS)); + } + @Test public void testToSizeBytes() throws Exception { Assert.assertEquals(1L, HiveConf.toSizeBytes("1b"));