Hello Bubble Community,
I am facing challenges with data consistency when using the “scheduled API workflow on a list of things” feature, specifically when attempting to modify lists (e.g., adding chapters to a storybook). Although each chapter is individually created in the database without issues, when it comes to adding these chapters to the respective storybook’s list of chapters, not all entries are successfully added. For instance, in a scenario where I expect 15 chapters to be added, sometimes only a fraction of them appear in the storybook’s list.
The issue appears to be mitigated when I increase the “interval (seconds)” in the scheduled API workflow settings, suggesting a timing or concurrency problem. Below are the detailed steps to reproduce this issue, including the specific action that frequently fails due to what appears to be a race condition:
Steps to Reproduce:
- Create two data types:
Storybook
andChapter
. EnsureStorybook
includes a field that is a list ofChapter
s. - Develop an API workflow that accomplishes two main tasks:
- Creates a
Chapter
based on input (e.g., text content). - Makes a change to a
Storybook
to add the newly createdChapter
to the storybook’schapters list
.
- Schedule this API workflow on a list of things (texts representing the chapters’ contents), initially setting a minimal interval (seconds).
- Notice that not all
Chapter
items are added to theStorybook
’s list upon execution. When the interval (seconds) is significantly increased, a higher success rate in chapters being added is observed.
Troubleshooting Steps:
- Adjusting the interval between each call in the scheduled API workflow has been my primary strategy for addressing this issue. The longer the interval, the more successful the “add to list” actions seem to be, reinforcing the theory of a timing-related problem.
Hypothesis:
- The close succession of scheduled API workflow calls might be leading to an override of the current
Storybook
’schapters list
variable. This is likely because the “add to list” action completes slower than the rate at which the workflows are scheduled, causing the next call to begin before the previous one has fully updated the list.
Proposed Solution:
- Implementing an option for the “scheduled API workflow on a list of things” to execute synchronously could address this issue by ensuring that each operation within the workflow is fully completed before the next begins. This change would greatly improve data integrity and consistency for operations involving list modifications.
I would greatly appreciate any insights into potential workarounds, solutions, or practices within Bubble.io that could help maintain data consistency in similar scenarios.
Thank you for your time and assistance.