I’ve been trying to diagnose an issue in my app recently and have come across a possible solution, but it raises more questions and concerns for me.
Overview:
As part of my app a user can create a new project, and set different attributes on that project. Because the attributes can be dynamic and defined by the user I send these attributes to a backend workflow to be created and linked to the project once they have been created.
Initial Problem:
At some point, the attributes were create in the backend workflows as intended, but they were not all being linked back to the project. Some would be linked, some wouldn’t. If I set 4 attributes, sometimes 1 would be linked, sometimes 2, and there seems to be no pattern to this at all. They would ALWAYS be created, but the linking aspect of the workflow seemed to be temperamental.
Solution (kind of):
When scheduling the backend workflow to link the attributes to the project, I have found it works as intended if I add an “Interval (seconds)” of 1 second to the schedule:
I am concerned about why this is fixing the issue though. After reading the bubble documentation on this feature - Custom | Bubble Docs - It seems like leaving this field empty is always the best option as the backend workflows should be queued and completed asap. This makes me think that for some reason bubble wasn’t queueing these jobs correctly when no interval was set?
Any thoughts or help on this topic would be very much appreciated, eventhough my problem is temporarily fixed I want to get to the bottom of what’s going on so that I can avoid issues in the future.
Presumably your backend workflow adds an attribute to a list on the Project data type.
You’re encountering race conditions, where the Make changes to Thing is running at the same time as the same action in another backend workflow, erasing the previous Make changes to Thing’s result.
Set the interval to 2 seconds and you should be fine. Bubble improved the performance of Schedule API workflow on a list but this broke all existing workflows that involve adding things to lists…
@georgecollier Thanks, that sounds about right, I didn’t even know that was a thing…
There is another backend workflow that is scheduled at pretty much the exact same time to also makes changes to the project based on other datapoints. These two changes would be happening at basically the same time so I can see why there could be a conflict if the changes aren’t being handled correctly.
Any other advice for avoiding this in the future? Luckily I can set an interval on these workflows and it won’t make too much different to the end user but if feels a workaround.
And do you know if this is something bubble are aware of / a well known issue? Seems like this could be a really serious problem for some apps.
@georgecollier For my situation where I have two backend workflows scheduled at the same time, would you recommend setting both to a 2 second interval or would you recommend staggering them e.g. set one workflow to a 1 second interval and the other to 2 seconds etc?
Is this something you build into your backend workflows by default to avoid issues or do you only implement a fix like this if you see an issue?