jad-grepr commented on code in PR #18356:
URL: https://github.com/apache/iceberg/pull/18356#discussion_r4185504799
##########
flink/v2.3/flink/src/main/java/org/apache/iceberg/flink/sink/dynamic/TableUpdater.java:
##########
@@ -104,23 +105,39 @@ private void findOrCreateBranch(TableIdentifier
identifier, String branch) {
String fromCache = cache.branch(identifier, branch);
if (fromCache == null) {
Table table = catalog.loadTable(identifier);
- try {
- table.manageSnapshots().createBranch(branch).commit();
- LOG.info("Branch {} for {} created", branch, identifier);
- } catch (CommitFailedException e) {
- table.refresh();
- if (table.refs().containsKey(branch)) {
- LOG.debug("Branch {} concurrently created for {}.", branch,
identifier);
- } else {
- LOG.error("Failed to create branch {} for {}.", branch, identifier,
e);
- throw e;
- }
+ // Another writer may have created the branch since the cache loaded the
table.
+ if (hasBranch(table, branch)) {
+ LOG.debug("Branch {} for {} created by another writer.", branch,
identifier);
+ } else {
+ createBranch(identifier, table, branch);
}
Review Comment:
The createBranch() call now catches the additional IllegalArgumentException
below.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]