lirui-apache commented on code in PR #12637: URL: https://github.com/apache/iceberg/pull/12637#discussion_r2020815560
########## hive-metastore/src/test/resources/hive-schema-3.1.0.derby.sql: ########## @@ -130,7 +130,7 @@ CREATE TABLE "APP"."TAB_COL_STATS"( "BIT_VECTOR" BLOB ); -CREATE TABLE "APP"."TABLE_PARAMS" ("TBL_ID" BIGINT NOT NULL, "PARAM_KEY" VARCHAR(256) NOT NULL, "PARAM_VALUE" CLOB); Review Comment: Good to know the direct SQL is made more robust. Maybe we can revisit this change when we upgrade our hive dependency. ########## hive-metastore/src/main/java/org/apache/iceberg/hive/HiveTableOperations.java: ########## @@ -287,15 +277,33 @@ protected void doCommit(TableMetadata base, TableMetadata metadata) { e); } - LOG.error( - "Cannot tell if commit to {}.{} succeeded, attempting to reconnect and check.", - database, - tableName, - e); commitStatus = BaseMetastoreOperations.CommitStatus.UNKNOWN; - commitStatus = - BaseMetastoreOperations.CommitStatus.valueOf( - checkCommitStatus(newMetadataLocation, metadata).name()); + if (e.getMessage() != null + && e.getMessage() + .contains( + "The table has been modified. The parameter value for key '" + + HiveTableOperations.METADATA_LOCATION_PROP + + "' is")) { + // It's possible the HMS client incorrectly retries a successful operation, due to network + // issue for example, and triggers this exception. So we need double-check to make sure + // this is really a concurrent modification. Hitting this exception means no pending + // requests, if any, can succeed later, so it's safe to check status in strict mode + commitStatus = checkCommitStatusStrict(newMetadataLocation, metadata); + if (commitStatus == BaseMetastoreOperations.CommitStatus.FAILURE) { + throw new CommitFailedException( + e, "The table %s.%s has been modified concurrently", database, tableName); + } + } else { + LOG.error( + "Cannot tell if commit to {}.{} succeeded, attempting to reconnect and check.", + database, + tableName, + e); + commitStatus = Review Comment: I believe it was introduced in #10001 when we had two enums: `BaseMetastoreTableOperations::CommitStatus` and `BaseMetastoreOperations::CommitStatus`, and is not needed anymore. I'd be happy to remove it in this PR if you think that's better. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org