Subscription seems to have fired twice concurrentl...
# support
n
I have a Subscription tied to Communication resources that creates Tasks. In the Medplum UI, the Subscription shows to have only fired once at that time for the particular Communication resource based on the Event history table, however, two Task resources were created. The Task creation Bot cannot create multiple tasks for the same Communication resource unless it was called an extra time concurrently that is not represented in the event log. I'm going to look into implementing a locking mechanism to mitigate this issue but curious - is there is an explanation for what I'm seeing? This is the audit event: https://app.medplum.com/AuditEvent/c67dacec-cfc6-4af4-a512-00fbdc4d4d61 I understand that with the way BullMQ is configured we should expect at-least-once delivery. I know there is some nuance here as technically there isn't an at least once guarantee based on this issue https://github.com/medplum/medplum/issues/3565
r
Hi @node5585 , I don't have an immediate explanation for this behavior, but I can point you to some debugging resources. If you navigate to the Communication resource that triggered this, you can click on the
Events
tab and see all the Audit Events that were fired based on that resource. You can get more information by adding the "Entity" and "Types" columns to the table
n
Just wanting to close the loop here - I believe this is a non-issue and may have been the result of a race condition in the Bot code which was updating the Communication resource prior to finding/creating the Task. A quick remediation was leveraging the interaction subscription extension to only fire the bot on create. Also, defering the Communication update until after task creation would have also prevented this from happening. Sorry for any alarms this may have raised!
r
Thanks so much for closing the loop @node5585 ! This will help others in the community