Skip to content

Commit eccedb5

Browse files
authored
Fix transaction conditional URL prefetch on non-token params (#6818)
* Fix transaction conditional URL prefetch on non-token params * Drop a check * Adjust query counts * Improve performance * Single token optimized * Test fixes * About to try to ensure we prefetch resource bodies for conditional create * Test fixes * Some test fixes * Test fixes * Test fixes * Test fixes * Work on tests * Test fix * Spotless * Add docs * Address review comments
1 parent 445cb01 commit eccedb5

File tree

18 files changed

+703
-159
lines changed

18 files changed

+703
-159
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
type: fix
3+
issue: 6818
4+
title: "When performing a conditional create/update/etc in a FHIR transaction, if the conditional
5+
URL had parameters with a type other than `token`, the transaction processor could fail with
6+
a constraint error if the target already existed. This has been corrected. Thanks to
7+
Brian Lind for reporting!"
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
type: perf
3+
issue: 6818
4+
title: "When executing a FHIR transaction containing multiple conditional create operations,
5+
a series of SQL resource version lookups have been collapsed into a single query for
6+
better performance."

hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirResourceDao.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -494,14 +494,17 @@ private DaoMethodOutcome doCreateForPostOrPut(
494494
Supplier<IIdType> idSupplier = () -> myTxTemplate.execute(tx -> {
495495
IIdType retVal = myIdHelperService.translatePidIdToForcedId(myFhirContext, myResourceName, pid);
496496
if (!retVal.hasVersionIdPart()) {
497-
Long version = myMemoryCacheService.getIfPresent(
498-
MemoryCacheService.CacheEnum.RESOURCE_CONDITIONAL_CREATE_VERSION, pid.getId());
497+
Long version = pid.getVersion();
498+
if (version == null) {
499+
version = myMemoryCacheService.getIfPresent(
500+
MemoryCacheService.CacheEnum.RESOURCE_CONDITIONAL_CREATE_VERSION, pid);
501+
}
499502
if (version == null) {
500503
version = myResourceTableDao.findCurrentVersionByPid(pid);
501504
if (version != null) {
502505
myMemoryCacheService.putAfterCommit(
503506
MemoryCacheService.CacheEnum.RESOURCE_CONDITIONAL_CREATE_VERSION,
504-
pid.getId(),
507+
pid,
505508
version);
506509
}
507510
}

0 commit comments

Comments
 (0)