This is an urgent issue for us, I reported to Retool Support back at the end of November, and received a reply yesterday stating that Support no longer deal with technical defects within the Workflows product, and that community support is the correct channel. This seems odd for something we pay for, however I'm willing to follow the instruction.
I'm investigating a recurring intermittent issue, whereby it appears that when a workflow is triggered, sometimes the blocks run twice, causing issues (e.g. attempting to insert data twice).
For the sake of example, in a workflow triggered by a webhook, we receive an array called subscriptions
, which has two objects in it, the values of which will be inserted into a database table.
The blocks involved only have single connections, so are structured as startTrigger
> payload
> createSubscriptions
This has a startTrigger
block (webhook trigger) linked to a JavaScript block (called payload
) which contains:
console.log(startTrigger.data)
return startTrigger.data
Which triggers the createSubscriptions
block which is a loop block.
In the Run history, when selecting payload
we see:
--- Running query: payload --- Th 11/30/2023 14:15:42
the logged data
--- Successfully finished running query: payload --- Th 11/30/2023 14:15:42
--- Running query: payload --- Th 11/30/2023 14:15:46
the logged data
--- Successfully finished running query: payload --- Th 11/30/2023 14:15:46
Indicating that the block ran twice, 4 seconds apart, it should not have run twice.
Then when selecting the createSubscriptions
entry in the run history we see:
--- Running query: createSubscriptions --- Th 11/30/2023 14:15:43
--- Running triggered block: query11 --- Th 11/30/2023 14:15:43
--- Running triggered block: query11 --- Th 11/30/2023 14:15:43
--- Successfully finished running triggered block: query11 --- Th 11/30/2023 14:15:44
--- Successfully finished running triggered block: query11 --- Th 11/30/2023 14:15:44
--- Successfully finished running query: createSubscriptions --- Th 11/30/2023 14:15:44
--- Running query: createSubscriptions --- Th 11/30/2023 14:15:47
--- Running triggered block: query11 --- Th 11/30/2023 14:15:47
--- Running triggered block: query11 --- Th 11/30/2023 14:15:47
Error evaluating query11: Duplicate entry '810972e8-649d-4cc3-8883-d1f90a38fc68' for key 'PRIMARY' Th 11/30/2023 14:15:47
--- Failed running triggered block: query11 --- Th 11/30/2023 14:15:47
Error evaluating createSubscriptions: Error: Duplicate entry '810972e8' for key 'PRIMARY' (line 6) Th 11/30/2023 14:15:47
--- Failed running query: createSubscriptions --- Th 11/30/2023 14:15:47
Error evaluating query11: Duplicate entry '8fc3f0d1' for key 'PRIMARY' Th 11/30/2023 14:15:47
--- Failed running triggered block: query11 ---Th 11/30/2023 14:15:47
Here we can see that createSubscriptions
ran twice, I assume because payload
ran twice, but I don't know why payload
executed twice from the webhook trigger.
query11 is the loop lambda, and it ran twice (because there were two objects in the array) to insert the data into the database. Then a few seconds afterwards, it ran again, presumably because the payload
block executed twice.
This is causing the workflow to fail (because the same entries cannot be inserted twice).
Why is the workflow or workflow blocks executing twice?
The previous 28 runs of this workflow do not exhibit this behaviour, and then the 29th did the same thing. There is no retry logic on any of the blocks. This is happening sufficiently regularly enough that I'm considering moving our workflows from Retool to AWS Step Functions for reliability.