dimas-b commented on code in PR #8857: URL: https://github.com/apache/iceberg/pull/8857#discussion_r1373340680
########## nessie/src/main/java/org/apache/iceberg/nessie/NessieIcebergClient.java: ########## @@ -540,4 +612,59 @@ public void close() { api.close(); } } + + private void commitRetry(String message, Operation... ops) + throws BaseNessieClientServerException { + commitRetry(message, false, builder -> builder.operations(Arrays.asList(ops))); + } + + private void commitRetry(String message, boolean retryConflicts, CommitEnhancer commitEnhancer) + throws BaseNessieClientServerException { + + // Retry all errors except for NessieNotFoundException and also NessieConflictException, unless + // retryConflicts is set to true. + Predicate<Exception> shouldRetry = + e -> + !(e instanceof NessieNotFoundException) + && (!(e instanceof NessieConflictException) || retryConflicts); + + Tasks.range(1) + .retry(5) + .shouldRetryTest(shouldRetry) + .throwFailureWhenFinished() + .onFailure((o, exception) -> refresh()) // FIXME is this necessary? + .run( + i -> { + try { + Branch branch = + commitEnhancer + .enhance(api.commitMultipleOperations()) + .commitMeta(NessieUtil.buildCommitMetadata(message, catalogOptions)) + .branch((Branch) getReference()) + .commit(); + getRef().updateReference(branch); Review Comment: tangential: I wonder whether it actually makes sense to keep a `NessieIcebergClient` in `NessieCatalog`. At the catalog level, all changes (namespace updates mostly) are independent of each other, so what is the point of tracking a catalog-level "reference"?... Perhaps something we could revisit later. -- 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