singhpk234 commented on code in PR #7569:
URL: https://github.com/apache/iceberg/pull/7569#discussion_r1188863373
##########
core/src/main/java/org/apache/iceberg/rest/CatalogHandlers.java:
##########
@@ -361,4 +364,32 @@ private static TableMetadata commit(TableOperations ops,
UpdateTableRequest requ
return ops.current();
}
+
+ public static void commitTransaction(Catalog catalog,
CommitTransactionRequest request) {
+ List<Transaction> transactions = Lists.newArrayList();
+
+ for (CommitTransactionRequest.CommitTableRequest tableChange :
request.tableChanges()) {
+ Table table = catalog.loadTable(tableChange.identifier());
+ if (table instanceof BaseTable) {
+ UpdateTableRequest updateTableRequest =
+ new UpdateTableRequest(tableChange.requirements(),
tableChange.updates());
+
+ Transaction transaction =
+ Transactions.newTransaction(
+ tableChange.identifier().toString(), ((BaseTable)
table).operations());
+ transactions.add(transaction);
+
+ BaseTransaction.TransactionTable txTable =
+ (BaseTransaction.TransactionTable) transaction.table();
+
+ // this performs validations and makes temporary commits that are
in-memory
+ commit(txTable.operations(), updateTableRequest);
+ } else {
+ throw new IllegalStateException("Cannot wrap catalog that does not
produce BaseTable");
+ }
+ }
+
+ // only commit if validations passed previously
+ transactions.forEach(Transaction::commitTransaction);
Review Comment:
[doubt] let's say we had transactions {T1, T2, T3} whose validations passed
but then there was an update which made T2 conflict with current state, so when
we actually commit T1 is applied but T2 can't now we need to rollback T1, how
are we handling this case ?
Is there a write up for this ?
--
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]