colinwerner opened a new issue, #2665:
URL: https://github.com/apache/activemq/issues/2665

   When the database commit fails during an XA `prepare`, or during the 
`commit` of a prepared transaction, on the JDBC store, the client does not see 
the real error. It gets `Not started.`:
   - prepare: `XAException: Not started.` (`XAER_RMFAIL`), caused by 
`JMSException: Not started.` and `IOException: Not started.`;
   - commit: `XAException: STORE COMMIT FAILED: Not started.` (`XA_RETRY`).
   
   The broker logs the real failure (`JDBCPersistenceAdapter - Commit failed: 
...`), but the transaction manager and the application only see `Not started.`, 
which makes the failure hard to diagnose from the client side.
   
   ### Cause
   `TransactionContext.commit()` handles a `SQLException` by rolling back, 
setting `inTx = false` and closing the connection before rethrowing. Its 
callers then roll back again:
   - `JdbcMemoryTransactionStore.prepare()`: `catch (IOException e) { 
persistenceAdapter.rollbackTransaction(ctx); throw e; }`
   - `MemoryTransactionStore.Tx.commit()`: the same pattern.
   
   `TransactionContext.rollback()` throws `IOException("Not started.")` because 
the transaction has already ended, and that exception replaces the original one.
   
   ### Reproduce
   With a JDBC persistence adapter whose `DataSource` fails the next 
`Connection.commit()` with a `SQLException`, send a message in an XA 
transaction and call `prepare` (or `prepare`, then `commit`). The `XAException` 
chain contains only `Not started.`.
   
   ### Proposed fix
   Keep the original exception and add any failure from the follow-up rollback 
to it as suppressed. XA error codes stay the same.


-- 
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]
For further information, visit: https://activemq.apache.org/contact


Reply via email to