hapi-fhir icon indicating copy to clipboard operation
hapi-fhir copied to clipboard

Refactor BaseHapiFhirDao.getOrCreateTag method to run in a separate thread for XA transaction compatibility

Open iyt-trifork opened this issue 1 year ago • 2 comments

XA Transaction Issue with HAPI FHIR and PostgreSQL

We are experiencing issues in our HAPI FHIR application when using XA transactions, similar to those reported in issue #3412.

Problem

The PostgreSQL JDBC driver's PGXAConnection does not support suspend/resume operations, as detailed in the official documentation. This limitation causes exceptions when the PROPAGATION_REQUIRES_NEW transaction propagation behavior is used in XA environments, since it requires suspending the current transaction and resuming it later.

Proposed Solution

The solution focuses on simplifying the TagDefinition handling by addressing the primary concern of managing tag creation in a concurrent environment. Previously, complex retry and nested transaction logic was necessary due to a uniqueness constraint on the hfj_tag_def table, which prevented duplicate tag definitions. However, this constraint was relaxed, and duplicate tag definitions are now allowed, making the nested transaction and retry logic obsolete.

iyt-trifork avatar Aug 20 '24 12:08 iyt-trifork

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 83.58%. Comparing base (406db33) to head (b18c22b). Report is 87 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #6224      +/-   ##
============================================
+ Coverage     83.54%   83.58%   +0.04%     
- Complexity    27432    27560     +128     
============================================
  Files          1707     1716       +9     
  Lines        106185   106634     +449     
  Branches      13397    13430      +33     
============================================
+ Hits          88710    89135     +425     
+ Misses        11750    11740      -10     
- Partials       5725     5759      +34     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Aug 29 '24 09:08 codecov[bot]

FYI @michaelabuckley all tests go green now

jkiddo avatar Sep 03 '24 11:09 jkiddo