Skip to content
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

Postgres foreign_key_violation not correctly mapped to XAException #1171

Closed
janvdbergh opened this Issue Apr 18, 2018 · 1 comment

Comments

3 participants
@janvdbergh
Copy link
Contributor

commented Apr 18, 2018

We have a database schema with several deferrable constraints. This means that constraints violations are noticed when the transaction is committed and not when the statement itself is executed. We are using the Atomikos distributed transaction manager as well.

Recently we noticed that a foreign_key_violation error from the server during the commit resulted in the transaction not being cleaned up in Atomikos. Further investigation revealed that:

  • An PSQLException was thrown during commitOnePhase() with SQLState: "23503" (foreign_key_violation).
  • This resulted in an PGXAException with errorCode XAER_RMFAIL. As a result Atomikos did not know what was happening which resulted in a heuristic hazard exception.

In our opinion it would be better to map SQLState "23503" to an XAException with error code XA_RBROLLBACK. Doing so would result in the correct behaviour.

We are using PostgreSQL 9.6.6 with JDBC driver version 42.2.2 and Atomikos transactions-essentials 4.0.6. You can find the (redacted) stacktrace in attachment.
stacktrace.txt

@davecramer

This comment has been minimized.

Copy link
Member

commented Apr 18, 2018

Seems reasonable to me. Can you provide a PR ?

@vlsi vlsi added this to the 42.2.4 milestone Jul 14, 2018

@vlsi vlsi closed this in f2d1352 Jul 14, 2018

@davecramer davecramer added this to In progress in 42.2.4 Release Jul 14, 2018

@davecramer davecramer moved this from In progress to Done in 42.2.4 Release Jul 14, 2018

golovnin added a commit to golovnin/pgjdbc that referenced this issue Jul 24, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.