Open chgl opened 1 year ago
I was thinking of something like this to solve a problem with concurrent PUTs of the same resource: https://github.com/hapifhir/hapi-fhir/issues/4690
A similar scheme could be used for conditional creates by locking on the ifNoneExists string rather than the resource ID. It would not work in all cases, but would when the clients are creating equal ifNoneExists strings for the same resource.
Thanks for sharing! I believe that would only address one Hapi fhir process with multiple threads, so no synchronisation across network boundaries unfortunately.
If multiple clients are sending conditional-create (or update) transactions in parallel, instead of just one succeeding they all do causing duplicate resources to be created.
I was initially investigating the multi-replica behavior of the HAPI FHIR server (once more, see https://github.com/hapifhir/hapi-fhir-jpaserver-starter/issues/48) but noticed this happening on single-instance setups as well. To reproduce in a local Kubernetes cluster:
deployment.yaml
:And finally run:
If the pods ran at least once, the issue should surface. To confirm, access the FHIR server by port-forwarding:
and checking the number of Patient resources:
The total is 3, however when using conditional-creates I would have expected it to just be 1.
Note that URL-decoding the
ifNoneExist
URL doesn't seem to make a difference.Interestingly, I can't seem to reproduce the same behavior on HAPI FHIR v5.4.1.