MartijnVisser commented on code in PR #259:
URL: 
https://github.com/apache/flink-connector-jdbc/pull/259#discussion_r4676625685


##########
flink-connector-jdbc-core/src/main/java/org/apache/flink/connector/jdbc/datasource/transactions/xa/XaTransaction.java:
##########
@@ -87,16 +85,24 @@ public void open(JdbcWriterState state) throws IOException {
         try {
             xaConnectionProvider.open();
             recoverState(state);
-            hangingXids = new 
LinkedList<>(failOrRollback(hangingXids).getForRetry());
+            XaTransactionResult<TransactionId> rolledBack = 
failOrRollback(hangingXids);
+            if (rolledBack.getTransientFailure().isPresent()) {

Review Comment:
   Right, I only covered the transient case. Applied, and `rollbackIfKnown` now 
forgets a heuristic outcome first: Oracle, Db2 or SQL Server report one after 
an operator decision, on every rollback until it is forgotten, and the job 
would fail on every restart 
(`testOpenFailsOnceIfRestoredHangingCompletedHeuristically`). It also accepts 
`XAER_NOTA` after `end()` returned a rollback code. On a real database I could 
reproduce PostgreSQL refusing the rollback to another user, 
`testOpenFailsIfRollbackOfRestoredHangingIsRefused`.
   cf4c85df, 617a3895
   



##########
flink-connector-jdbc-core/src/main/java/org/apache/flink/connector/jdbc/datasource/transactions/xa/XaTransaction.java:
##########
@@ -170,6 +249,7 @@ public void prepareTx() throws IOException {
             ExceptionUtils.rethrowIOException(e);
         }
         currentTid = null;
+        return Optional.ofNullable(prepared);
     }
 
     public void commitTx() {

Review Comment:
   I've made the writer fail instead, as it does for the hanging transactions, 
and the restart commits it. A retry in `snapshotState()` may never run: a 
record that touches a row of that transaction waits for its lock in the flush 
before it, and PostgreSQL waits forever by default. The transient commit 
failures I got from PostgreSQL and MySQL also came from a dead connection, 
which `SimpleXaConnectionProvider` doesn't reestablish. 
`testOpenFailsIfCommitOfPreparedOfVersion2StateFailsTransiently` checks that 
the second attempt commits it.
   0d657655
   



-- 
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]

Reply via email to