-
Notifications
You must be signed in to change notification settings - Fork 841
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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
Compare
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
Compare
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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"
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
Compare
@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
Compare
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}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a note: exception message does not reflect the cause. Something like "invalid state" should be used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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...?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vlsi Does the exception message still need changing to "invalid state" ? Or something similar ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Invalid protocol state requested. Attempted Transaction interleaving is not supported. xid={0}, currentXid={1}"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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
Compare
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 pgjdbc#236 pgjdbc#510 pgjdbc#683
df2cb3e
to
1ca93b4
Compare
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