Skip to content

Commit 0ee0d41

Browse files
HIVE-29191: Gracefully Handle Removed Configuration Properties in Hive 4 to Avoid Job Failures
1 parent 97a9677 commit 0ee0d41

File tree

4 files changed

+58
-4
lines changed

4 files changed

+58
-4
lines changed

common/src/java/org/apache/hadoop/hive/conf/HiveConf.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5607,11 +5607,16 @@ public static enum ConfVars {
56075607
HIVE_MM_AVOID_GLOBSTATUS_ON_S3("hive.mm.avoid.s3.globstatus", true,
56085608
"Whether to use listFiles (optimized on S3) instead of globStatus when on S3."),
56095609

5610+
HIVE_IGNORE_REMOVED_CONFIGS_LIST("hive.ignore.removed.configs.list",
5611+
"",
5612+
"Comma separated list of configuration options which are removed from hive code. Silently ignore if the user tries to set them"),
5613+
56105614
// If a parameter is added to the restricted list, add a test in TestRestrictedList.Java
56115615
HIVE_CONF_RESTRICTED_LIST("hive.conf.restricted.list",
56125616
"hive.security.authenticator.manager,hive.security.authorization.manager," +
56135617
"hive.security.metastore.authorization.manager,hive.security.metastore.authenticator.manager," +
56145618
"hive.users.in.admin.role,hive.server2.xsrf.filter.enabled,hive.server2.csrf.filter.enabled,hive.security.authorization.enabled," +
5619+
"hive.ignore.removed.configs.list," +
56155620
"hive.distcp.privileged.doAs," +
56165621
"hive.server2.authentication.ldap.baseDN," +
56175622
"hive.server2.authentication.ldap.url," +
@@ -7261,6 +7266,10 @@ public static String generateDeprecationWarning() {
72617266
+ "versions. Please adjust DDL towards the new semantics.";
72627267
}
72637268

7269+
public static String generateRemovedWarning() {
7270+
return "This config does not exist in the current version of Hive. Consider removing this config.";
7271+
}
7272+
72647273
private static final Object reverseMapLock = new Object();
72657274
private static HashMap<String, ConfVars> reverseMap = null;
72667275

itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestRestrictedList.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ public static void startServices() throws Exception {
7070

7171
// Add the parameter here if it cannot change at runtime
7272
addToExpectedRestrictedMap("hive.conf.restricted.list");
73+
addToExpectedRestrictedMap("hive.ignore.removed.configs.list");
7374
addToExpectedRestrictedMap("hive.security.authenticator.manager");
7475
addToExpectedRestrictedMap("hive.security.authorization.manager");
7576
addToExpectedRestrictedMap("hive.security.metastore.authorization.manager");

ql/src/java/org/apache/hadoop/hive/ql/processors/SetProcessor.java

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
import static org.apache.hadoop.hive.conf.SystemVariables.*;
2626

27+
import java.util.HashSet;
2728
import java.util.Map;
2829
import java.util.Properties;
2930
import java.util.Set;
@@ -55,19 +56,26 @@ public class SetProcessor implements CommandProcessor {
5556
private static final SessionState.LogHelper console = SessionState.getConsole();
5657

5758
private static final String prefix = "set: ";
58-
private static final Set<String> removedConfigs =
59+
private static final Set<String> removedHiveConfigs =
5960
Sets.newHashSet("hive.mapred.supports.subdirectories",
6061
"hive.enforce.sorting","hive.enforce.bucketing",
6162
"hive.outerjoin.supports.filters",
6263
"hive.llap.zk.sm.principal",
63-
"hive.llap.zk.sm.keytab.file"
64+
"hive.llap.zk.sm.keytab.file",
65+
"hive.stats.fetch.partition.stats",
66+
"hive.optimize.sort.dynamic.partition",
67+
"hive.metastore.initial.metadata.count.enabled",
68+
"hive.cli.pretty.output.num.cols",
69+
"hive.debug.localtask",
70+
"hive.timedout.txn.reaper.start"
6471
);
6572
// Allow the user to set the ORC properties without getting an error.
73+
private static final Set<String> allowOrcConfigs = new HashSet<>();
6674
static {
6775
for(OrcConf var: OrcConf.values()) {
6876
String name = var.getHiveConfName();
6977
if (name != null && name.startsWith("hive.")) {
70-
removedConfigs.add(name);
78+
allowOrcConfigs.add(name);
7179
}
7280
}
7381
}
@@ -140,6 +148,10 @@ private boolean isHidden(String key) {
140148
return false;
141149
}
142150

151+
public Set<String> getRemovedHiveConfigs() {
152+
return removedHiveConfigs;
153+
}
154+
143155
private void dumpOption(String s) {
144156
SessionState ss = SessionState.get();
145157

@@ -228,6 +240,22 @@ static String setConf(SessionState ss, String varName, String key, String varVal
228240
throws IllegalArgumentException {
229241
String result = null;
230242
HiveConf conf = ss.getConf();
243+
244+
String removedHiveConfigsList = conf.getVar(HiveConf.ConfVars.HIVE_IGNORE_REMOVED_CONFIGS_LIST);
245+
if (removedHiveConfigsList != null && !removedHiveConfigsList.isEmpty()) {
246+
for (String entry : removedHiveConfigsList.split(",")) {
247+
if (!removedHiveConfigs.contains(entry.trim())) {
248+
removedHiveConfigs.add(entry.trim());
249+
}
250+
}
251+
}
252+
if (removedHiveConfigs.contains(key)) {
253+
// do not do anything. do not throw any error, just silently return
254+
result = HiveConf.generateRemovedWarning();
255+
LOG.warn(result);
256+
return result;
257+
}
258+
231259
String value = new VariableSubstitution(new HiveVariableSource() {
232260
@Override
233261
public Map<String, String> getHiveVariable() {
@@ -251,7 +279,7 @@ public Map<String, String> getHiveVariable() {
251279
message.append("' FAILED in validation : ").append(fail).append('.');
252280
throw new IllegalArgumentException(message.toString());
253281
}
254-
} else if (!removedConfigs.contains(key) && key.startsWith("hive.")) {
282+
} else if (!allowOrcConfigs.contains(key) && key.startsWith("hive.")) {
255283
throw new IllegalArgumentException("hive configuration " + key + " does not exists.");
256284
}
257285
}

ql/src/test/org/apache/hadoop/hive/ql/processors/TestSetProcessor.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,22 @@ public void testSystemPropertyIndividual() throws Exception {
107107
Assert.assertTrue(output.contains("hidden"));
108108
}
109109

110+
@Test
111+
public void testRemovedConfigs() throws Exception {
112+
Assert.assertEquals(baos.size(),0);
113+
for (String entry : processor.getRemovedHiveConfigs()) {
114+
// trying to set value
115+
runSetProcessor(entry + "=Something");
116+
// trying to get the value based on the previous set
117+
runSetProcessor(entry);
118+
Assert.assertTrue(baos.size() > 0);
119+
String output = baos.toString();
120+
Assert.assertTrue(output.contains("undefined"));
121+
Assert.assertFalse(output.contains("Something"));
122+
}
123+
Assert.assertTrue(baos.size() > 0);
124+
}
125+
110126
/*
111127
* Simulates the set <command>;
112128
*/

0 commit comments

Comments
 (0)