FHIR Chat · hapi fhir protect against race conditions · implementers

Stream: implementers

Topic: hapi fhir protect against race conditions


view this post on Zulip Pengyu Wang (May 24 2021 at 22:08):

Hi, we're running into an issue with HAPI FHIR where multiple resources are created with the same identifier, even though we're doing a condition create with the header If-None-Exist. We believe the issue is because of a race condition where we're sending multiple create requests simultaneously, so HAPI is not able to reliably synchronously find the existing resource for a given identifier, and thus ends up creating multiple duplicates.

We've made changes to the code so it's sending the requests synchronously to prevent this particular issue. But the root cause of the issue is still not solved because there could potentially be multiple processes writing to the HAPI server and we can't guarantee the order of operations.

What is the best practice for protecting against race conditions? Is it possible to manually enforce uniqueness constraints at the db level in HAPI?

view this post on Zulip Grahame Grieve (May 24 2021 at 23:06):

you might want to ask this on #hapi

view this post on Zulip Pengyu Wang (May 25 2021 at 04:59):

Grahame Grieve said:

you might want to ask this on #hapi

Thanks. Moved here: https://chat.fhir.org/#narrow/stream/179167-hapi/topic/hapi.20fhir.20protect.20agains.20race.20conditions/near/240119267


Last updated: Apr 12 2022 at 19:14 UTC