-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Add the parameter: metastore.drop-partition-ignore-nonexistent to ignore exceptions when a Hive partition does not exist. #7969
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -50,3 +50,5 @@ Cargo.lock | |
| *libvortex_jni* | ||
| ### Tantivy lib ### | ||
| *libtantivy_jni* | ||
|
|
||
| .cursor-svg-check/ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -65,6 +65,7 @@ | |
| import org.apache.hadoop.hive.metastore.TableType; | ||
| import org.apache.hadoop.hive.metastore.api.Database; | ||
| import org.apache.hadoop.hive.metastore.api.FieldSchema; | ||
| import org.apache.hadoop.hive.metastore.api.MetaException; | ||
| import org.apache.hadoop.hive.metastore.api.NoSuchObjectException; | ||
| import org.apache.hadoop.hive.metastore.api.Partition; | ||
| import org.apache.hadoop.hive.metastore.api.PartitionEventType; | ||
|
|
@@ -443,6 +444,7 @@ public void dropPartitions(Identifier identifier, List<Map<String, String>> part | |
| TableSchema schema = this.loadTableSchema(identifier); | ||
| CoreOptions options = CoreOptions.fromMap(schema.options()); | ||
| boolean tagToPart = options.tagToPartitionField() != null; | ||
| boolean ignorePartitionNonexistent = options.metastoreDropPartitionIgnoreNonexistent(); | ||
| if (metastorePartitioned(schema)) { | ||
| List<Map<String, String>> metaPartitions = | ||
| tagToPart | ||
|
|
@@ -461,6 +463,20 @@ public void dropPartitions(Identifier identifier, List<Map<String, String>> part | |
| false)); | ||
| } catch (NoSuchObjectException e) { | ||
| // do nothing if the partition not exists | ||
| } catch (MetaException e) { | ||
| if (ignorePartitionNonexistent | ||
| && !partitionExistsInHms(identifier, partitionValues)) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the MetaException returned by HMS is very likely still remaining in the HMS.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Therefore, I suggest that when this configuration is enabled, we ignore HMS errors, log a warning, and then delete the Paimon data. |
||
| LOG.warn( | ||
| "Drop partition {} of table {} returned MetaException, but " | ||
| + "the partition is confirmed not to exist in HMS. " | ||
| + "Ignoring the error and continuing with Paimon-side drop. " | ||
| + "Original exception: {}", | ||
| part, | ||
| identifier, | ||
| e.getMessage()); | ||
| } else { | ||
| throw new RuntimeException(e); | ||
| } | ||
| } catch (Exception e) { | ||
| throw new RuntimeException(e); | ||
| } | ||
|
|
@@ -471,6 +487,31 @@ public void dropPartitions(Identifier identifier, List<Map<String, String>> part | |
| } | ||
| } | ||
|
|
||
| private boolean partitionExistsInHms(Identifier identifier, List<String> partitionValues) { | ||
| try { | ||
| clients.run( | ||
| client -> | ||
| client.getPartition( | ||
| identifier.getDatabaseName(), | ||
| identifier.getTableName(), | ||
| partitionValues)); | ||
| return true; | ||
| } catch (NoSuchObjectException e) { | ||
| return false; | ||
| } catch (Exception e) { | ||
| // In case of HMS connection or other unknown errors, conservatively assume the | ||
| // partition may exist and redirect the original exception upwards to avoid accidental | ||
| // deletion. | ||
| LOG.warn( | ||
| "Failed to verify partition existence in HMS for table {}, " | ||
| + "partition values {}: {}", | ||
| identifier, | ||
| partitionValues, | ||
| e.getMessage()); | ||
| return true; | ||
| } | ||
| } | ||
|
|
||
| private String getDataFilePath(Identifier tableIdentifier, Table hmsTable) { | ||
| String tableLocation = getTableLocation(tableIdentifier, hmsTable).toString(); | ||
| return hmsTable.getParameters().containsKey(DATA_FILE_PATH_DIRECTORY.key()) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this file from the PR