# Are BizEvents triggering workflows too early, before the BizEvent is persisted?

**URL:** <https://community.dynatrace.com/t/are-bizevents-triggering-workflows-too-early-before-the-bizevent-is-persisted/48602>\
**Category:** Automations\
**Tags:** bizevents, workflows, site-reliability-guardian\
**Created:** [October 29, 2024, 11:36am UTC](https://community.dynatrace.com/t/are-bizevents-triggering-workflows-too-early-before-the-bizevent-is-persisted/48602 "2024-10-29T11:36:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![r\_weber](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/r_weber/32/24884_2.png) [@r\_weber](https://community.dynatrace.com/u/r_weber)\
**Post date:** [October 29, 2024, 11:36am UTC](https://community.dynatrace.com/t/are-bizevents-triggering-workflows-too-early-before-the-bizevent-is-persisted/48602/1 "2024-10-29T11:36:58Z")

</div>

I made an interesting observation today, which seems like a race condition when triggering an SRG from a workflow.

I have this situation:

- A workflow is triggered upon a bizevent. The bizevent contains some information in a JSON payload
- the workflow then triggers a SRG, with objectives that query the exact same bizevent to perform analysis on the payload.
- I have noticed that _sometimes_&nbsp;when the SRG executes the query for the bizevent the data seems to be not there yet? e.g. the DQL in the obejctive would get the last Bizevent of that type. Querying that bizevent in the objective with:

```markup
| sort timestamp desc
| limit 1​

```

should give us the exact last injected BizEvent. But it sometimes isn’t…it’s the previous one.

I have tested this by adding a time delay on the workflow, to have it wait 30s between the trigger and the SRG execution. Then this works.  
So could it really be that the WF triggers are executed directly upon ingest before the bizevent is actually persisted so it can be queried by DQL?

---

<div class="post-metadata">

**Author:** ![PacoPorro](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/pacoporro/32/36087_2.png) [@PacoPorro](https://community.dynatrace.com/u/PacoPorro)\
**Post date:** [October 29, 2024, 12:32pm UTC](https://community.dynatrace.com/t/are-bizevents-triggering-workflows-too-early-before-the-bizevent-is-persisted/48602/2 "2024-10-29T12:32:51Z")

</div>

Do you mean the workflow is fired before the Bizevent is available in the Bizevents table?  
Did you confirm the event firing the Workflow was present after some time?

---

<div class="post-metadata">

**Author:** ![ChristopherHejl](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/christopherhejl/32/20735_2.png) [@ChristopherHejl](https://community.dynatrace.com/u/ChristopherHejl)\
**Post date:** [October 29, 2024, 1:57pm UTC](https://community.dynatrace.com/t/are-bizevents-triggering-workflows-too-early-before-the-bizevent-is-persisted/48602/3 "2024-10-29T13:57:40Z")

</div>

You are correct. The workflow is triggered as soon as the event is coming in, but Grail might take 10-15 seconds until the new data point is stored and is returned by queries.  
We are looking into delaying event triggers internally to get around this, but not confirmed yet.

---

<div class="post-metadata">

**Author:** ![r\_weber](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/r_weber/32/24884_2.png) [@r\_weber](https://community.dynatrace.com/u/r_weber)\
**Post date:** [October 29, 2024, 2:34pm UTC](https://community.dynatrace.com/t/are-bizevents-triggering-workflows-too-early-before-the-bizevent-is-persisted/48602/4 "2024-10-29T14:34:32Z")

</div>

[@PacoPorro](https://community.dynatrace.com/user/40713)&nbsp;yes that is correct and confirmed by&nbsp;[@ChristopherHejl](https://community.dynatrace.com/user/44096)&nbsp;.  
This is important to know, because with this behavior it means that a new BizEvent can trigger a workflow which then works on old data 🙂  
Simple workaround: you need to add a delay on the srg execution task.

---

<div class="post-metadata">

**Author:** ![r\_weber](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/r_weber/32/24884_2.png) [@r\_weber](https://community.dynatrace.com/u/r_weber)\
**Post date:** [October 29, 2024, 2:34pm UTC](https://community.dynatrace.com/t/are-bizevents-triggering-workflows-too-early-before-the-bizevent-is-persisted/48602/5 "2024-10-29T14:34:52Z")

</div>

Thanks for confirming this!
