Adjust XAException return codes for better compatibility with XA specification #782
Conversation
Codecov Report
@@ Coverage Diff @@
## master #782 +/- ##
============================================
+ Coverage 67.38% 67.47% +0.08%
- Complexity 3687 3710 +23
============================================
Files 170 170
Lines 15638 15681 +43
Branches 2531 2552 +21
============================================
+ Hits 10538 10581 +43
+ Misses 3917 3914 -3
- Partials 1183 1186 +3 |
f6d333e
to
b9fa629
fixed forgotten checkstyle failures |
So short of any way to really test this I'm inclined to +1 |
@davecramer thanks for looking at this! |
b9fa629
to
dccbe28
hi @davecramer , I've got back to this. I re-based the changes and the CI tests seem to pass. Then I built the driver with this changes and run WildFly Narayana integration testsuite with the driver and PostgreSQL 9.3 and 9.4 and all passed. Would that be ok to merge this PR or is there something more to do/check? |
cc to @vlsi and @whitingjr as we were discussing the issue #510 which this PR covers |
@ochaloup long week :) If nobody else has objections I'm fine with it |
@davecramer I've looked over the changes. They look ok. |
if (PSQLState.isConnectionError(ex.getSQLState())) { | ||
errorCode = XAException.XAER_RMFAIL; | ||
} | ||
throw new PGXAException(GT.tr("Error rolling back prepared transaction"), ex, errorCode); |
vlsi
Jan 23, 2018
Member
@ochaloup , I might be a bit late to the party, however what do you think of printing things like xid
, preparedXid
, committedOrRolledBack
in the error message?
I'm sure, that would be crucial information if somebody receives ""Error rolling back prepared transaction"
.
@ochaloup , I might be a bit late to the party, however what do you think of printing things like xid
, preparedXid
, committedOrRolledBack
in the error message?
I'm sure, that would be crucial information if somebody receives ""Error rolling back prepared transaction"
.
ochaloup
Jan 25, 2018
Author
Contributor
@vlsi : I agree. Just I was not sure if I can change the format as those information was not part of the messages previously. I'm going to add the proposed info to the messages, push it to the PR and please check that then again.
@vlsi : I agree. Just I was not sure if I can change the format as those information was not part of the messages previously. I'm going to add the proposed info to the messages, push it to the PR and please check that then again.
@@ -442,18 +464,22 @@ private void commitOnePhase(Xid xid) throws XAException { | |||
"Not implemented: one-phase commit must be issued using the same connection that was used to start it"), | |||
XAException.XAER_RMERR); | |||
} | |||
if (!xid.equals(currentXid) || committedOrRolledBack) { | |||
throw new PGXAException(GT.tr("One-phase commit with unknown xid "), XAException.XAER_NOTA); |
vlsi
Jan 23, 2018
Member
space at the end of string
space at the end of string
@ochaloup , the changes look ok, however, I think it makes sense to add xids (and other relevant state information) to the error messages. Otherwise the error messages are cryptic and it would be hard to analyze. |
dccbe28
to
677ffb0
@vlsi can you please review the current form. I changed some of the error messages, added few debug information printing. Would be fine this way? Does have no harm for translation? |
677ffb0
to
8c5ec76
I haven't recognized that I need to run manually |
// In fact, we don't know if xid is bogus, or if it just wasn't associated with this | ||
// connection. | ||
if (xid.equals(preparedXid)) { | ||
throw new PGXAException(GT.tr("One-phase commit called for xid {0} but connection was prepared with xid {1}", |
vlsi
Jan 27, 2018
Member
@ochaloup , Did you really mean xid.equals(preparedXid)
above?
I think the negation is missing. Can you please clarify the logic here?
@ochaloup , Did you really mean xid.equals(preparedXid)
above?
I think the negation is missing. Can you please clarify the logic here?
@@ -195,12 +197,12 @@ public void start(Xid xid, int flags) throws XAException { | |||
// It's ok to join an ended transaction. WebLogic does that. | |||
if (flags == TMJOIN) { | |||
if (state != State.ENDED) { | |||
throw new PGXAException(GT.tr("Transaction interleaving not implemented"), | |||
throw new PGXAException(GT.tr("Transaction interleaving not implemented. xid={0}, currentXid={1}", xid, currentXid), |
vlsi
Jan 28, 2018
Member
Just a note: exception message does not reflect the cause. Something like "invalid state" should be used.
Just a note: exception message does not reflect the cause. Something like "invalid state" should be used.
ochaloup
Feb 2, 2018
Author
Contributor
@vlsi thank you for your fixes. I haven't managed to understand how the call should be compound correctly (eating humble pie).
In the case of the message - do you expect me to change the message? I can only guess what is the purpose. Do you want to change the message to something like Start called with transaction join flag while transaction is still active. Transaction interleaving not implemented...
, or...?
@vlsi thank you for your fixes. I haven't managed to understand how the call should be compound correctly (eating humble pie).
In the case of the message - do you expect me to change the message? I can only guess what is the purpose. Do you want to change the message to something like Start called with transaction join flag while transaction is still active. Transaction interleaving not implemented...
, or...?
whitingjr
Feb 19, 2018
•
Contributor
@vlsi Does the exception message still need changing to "invalid state" ? Or something similar ?
@vlsi Does the exception message still need changing to "invalid state" ? Or something similar ?
whitingjr
Feb 19, 2018
Contributor
"Invalid protocol state requested. Attempted Transaction interleaving is not supported. xid={0}, currentXid={1}"
"Invalid protocol state requested. Attempted Transaction interleaving is not supported. xid={0}, currentXid={1}"
ochaloup
Feb 19, 2018
Author
Contributor
@whitingjr thank you. I changed the PR to the text you suggested. I only wonder if that's right to say that the protocol state is invalid.
@whitingjr thank you. I changed the PR to the text you suggested. I only wonder if that's right to say that the protocol state is invalid.
c06f31e
to
c369a64
This commit fixes error codes which are thrown from PostgreSQL XAResource jdbc driver to comply better with xa specification. There are three main adjustments * XAException.XAER_RMFAIL is used when some connection error happens and it is expected that reconnection of RM could occur * XAException.XAER_NOTA is used when RM does not know anything about the provided Xid * XAException.XAER_PROTO is used when some wrong sequence of method calls is invoked This addresses issues #236 #510 #683
…ification (pgjdbc#782) There are three main adjustments * XAException.XAER_RMFAIL is used when some connection error happens and it is expected that reconnection of RM could occur * XAException.XAER_NOTA is used when RM does not know anything about the provided Xid * XAException.XAER_PROTO is used when some wrong sequence of method calls is invoked Fixes pgjdbc#236, pgjdbc#510, pgjdbc#683
…ification (pgjdbc#782) There are three main adjustments * XAException.XAER_RMFAIL is used when some connection error happens and it is expected that reconnection of RM could occur * XAException.XAER_NOTA is used when RM does not know anything about the provided Xid * XAException.XAER_PROTO is used when some wrong sequence of method calls is invoked Fixes pgjdbc#236, pgjdbc#510, pgjdbc#683
This commit fixes error codes which are thrown from PostgreSQL
XAResource jdbc driver to comply better with xa specification.
There are three main adjustments
and it is expected that reconnection of RM could occur
provided Xid
calls is invoked
This addresses issues
#236
#510
#683