# Very strange database behavior

**URL:** <https://forum.bubble.io/t/very-strange-database-behavior/38506>\
**Category:** Bugs\
**Created:** [September 22, 2018, 10:34pm UTC](https://forum.bubble.io/t/very-strange-database-behavior/38506 "2018-09-22T22:34:03Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![tom1](https://avatars.discourse-cdn.com/v4/letter/t/b487fb/32.png) [@tom1](https://forum.bubble.io/u/tom1)\
**Post date:** [September 22, 2018, 10:34pm UTC](https://forum.bubble.io/t/very-strange-database-behavior/38506/1 "2018-09-22T22:34:03Z")

</div>

In my app I have a page-load workflow that creates a new piece of data. The information used to create this requires some input fields that are hidden that populate figures based on background calculations. At first I noticed that some of the data wasn’t being written when the “thing” is created and I assumed this was because the input fields hadn’t finished calculating before this step in the workflow. I added a ten second pause before this step to see if this would remedy the issue, and it did.

I pushed to live thinking the problem was solved and started tinkering with other things, and then I noticed that the log that had been created reverted back to not displaying the correct information. I checked the database and saw that although I had tested this effectively several times the database showed all 0’s for the fields in question. I could have sworn I had seen it work, so I started testing again.

![image](https://us1.discourse-cdn.com/bubble/original/3X/0/3/03ff3e3cc29a3364f2aa3ed47ede73a6b55494fc.png)

Here is the data showing correctly on the page. But in the database I saw this:

 ![image](https://us1.discourse-cdn.com/bubble/original/3X/9/e/9ed674c1648e2489d722733f24b797d4661e0ef3.png)

And when I refresh the page, the data disappears. I took a video to demonstrate this.

[http://cloud.wattsupsolar.ca/029a8f5fc51f](http://cloud.wattsupsolar.ca/029a8f5fc51f)

It’s as though the data is written correctly, then deleted from the database and consequently removed from the page. Very strange!

Has anyone experienced anything like this? I’m not sure how to troubleshoot this.

---

<div class="post-metadata">

**Author:** ![keith](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/keith/32/56020_2.png) [@keith](https://forum.bubble.io/u/keith)\
**Post date:** [September 22, 2018, 11:06pm UTC](https://forum.bubble.io/t/very-strange-database-behavior/38506/2 "2018-09-22T23:06:23Z")

</div>

So first of all, you realize that the dev and live databases are separate, yeah? If you populated dev with the info you rely on, that data is not also in live unless you copy the dev dB to live.

You can copy just the data types you need so you don’t do something bad like overwrite live users that do not exist in dev.

---

<div class="post-metadata">

**Author:** ![tom1](https://avatars.discourse-cdn.com/v4/letter/t/b487fb/32.png) [@tom1](https://forum.bubble.io/u/tom1)\
**Post date:** [September 22, 2018, 11:24pm UTC](https://forum.bubble.io/t/very-strange-database-behavior/38506/3 "2018-09-22T23:24:06Z")

</div>

Yes I know there are two databases. You’ll see in the video the data is changed on page refresh. To be clear though the log isn’t erased as it appears in the video, the RG just filters out logs with an offset of 0. But you do see the offset go from being correct back to zero and thus removed from the RG.

---

<div class="post-metadata">

**Author:** ![keith](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/keith/32/56020_2.png) [@keith](https://forum.bubble.io/u/keith)\
**Post date:** [September 22, 2018, 11:56pm UTC](https://forum.bubble.io/t/very-strange-database-behavior/38506/4 "2018-09-22T23:56:43Z")

</div>

Sorry, just offering the most common cause of such questions/issues. Am mobile and can’t properly review the video ATM! Sounds like one of those simple/but-vexing problems…

---

<div class="post-metadata">

**Author:** ![tom1](https://avatars.discourse-cdn.com/v4/letter/t/b487fb/32.png) [@tom1](https://forum.bubble.io/u/tom1)\
**Post date:** [September 22, 2018, 11:59pm UTC](https://forum.bubble.io/t/very-strange-database-behavior/38506/5 "2018-09-22T23:59:12Z")

</div>

Hopefully it’s a simple fix yeah. I’ve never seen data get written and then changed like that so I’m thinking it might be a bubble bug I’ve stumbled on. I will likely submit a report if I don’t find a fix tonight. Thanks!

---

<div class="post-metadata">

**Author:** ![laurence](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/laurence/32/24296_2.png) [@laurence](https://forum.bubble.io/u/laurence)\
**Post date:** [September 24, 2018, 1:52am UTC](https://forum.bubble.io/t/very-strange-database-behavior/38506/6 "2018-09-24T01:52:15Z")

</div>

Sorry, but I must ask the dumb question: do you know the data was written to the thing before it was removed or is that a supposition based on observed behavior?

From your description and the video, I’m not clear on what’s being calculated in the page loaded event, what’s being written to the thing, and in what order.

Again, not seeing the Bubble workflows, is it possible something is triggering a second “make changes to a thing” that has a source of zeros after the initial correct update? If so, would workflows running in the wrong sequence explain the behavior you see?

Naturally, I don’t have a clue, but I’m hoping to trigger some thinking and digging on your part. I’ve found Bubble to be very finicky with regard to timing of workflow actions. And I’ve created scenarios where two events (workflows) conflict and produce results suggesting that workflows and workflow actions don’t run in the sequence you might expect.

---

<div class="post-metadata">

**Author:** ![vini\_brito](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/vini_brito/32/22187_2.png) [@vini\_brito](https://forum.bubble.io/u/vini_brito)\
**Post date:** [September 24, 2018, 2:55am UTC](https://forum.bubble.io/t/very-strange-database-behavior/38506/7 "2018-09-24T02:55:43Z")

</div>

> [@laurence](#):
>
> I’ve found Bubble to be very finicky with regard to timing of workflow actions.

Not wanting to hijack the thread, but… can you elaborate a bit more on this? Maybe point to some resource explaining more of it.

I’ve never found a workflow timing issue so far and am afraid of that. Not the first time I see others mentioning it.

---

<div class="post-metadata">

**Author:** ![JohnMark](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/johnmark/32/42431_2.png) [@JohnMark](https://forum.bubble.io/u/JohnMark)\
**Post date:** [September 24, 2018, 3:04am UTC](https://forum.bubble.io/t/very-strange-database-behavior/38506/8 "2018-09-24T03:04:05Z")

</div>

Keep in mind, Bubble is the strong platform NodeJS. It mean, process is done in parallel most of the time and it’s not synchronized as expected in many results.  
What you think it will be one by one is in fact simultaneous.  
Workflow\_1: action\_1 + action\_2 + action\_3 is treated like this:

action\_1  
action\_2  
action\_3

If you add a condition on action\_3 ’ IF action\_2 is not empty ’ then it will be:

action\_2 + action\_3 not

action\_2  
action\_3

Hope it help.

---

<div class="post-metadata">

**Author:** ![laurence](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/laurence/32/24296_2.png) [@laurence](https://forum.bubble.io/u/laurence)\
**Post date:** [September 24, 2018, 3:54am UTC](https://forum.bubble.io/t/very-strange-database-behavior/38506/9 "2018-09-24T03:54:08Z")

</div>

This may get off-topic, so I’d suggest searching the forum for discussions of timing. Here’s just one example of the kind of thing I’ve experienced:

> [@Simple workflow does not work as written](http://forum.bubble.io/t/simple-workflow-does-not-work-as-written/38510):
>
> Here’s a relatively simple page: [image] The page has a workflow triggered by the calender-x icon being clicked. The first two steps of the workflow are simple. 1. Set the value of a custom state to empty. [image] Trigger a workflow in which the first step is Make changes to a thing.Among other fields updated is DateDue which is set to the value (empty) of the custom state set in step 1. [image] After execution: the custom state is empty, as it should be, the Action thing still conta…

JohnMark touches on timing above.

> [@JohnMark](#):
>
> Keep in mind, Bubble is NodeJS. It mean, process is done in parallel most of the time and it’s not synchronized as expected in many results.  
> What you think it will be one by one is in fact simultaneous.

Frequently, people suggesting adding a pause to help with timing, but there is no reliable rule for how long a pause should be for consistent results. Here’s another take on that:

> [@Pausing Makes Things Faster and More Reliable. Huh?](http://forum.bubble.io/t/pausing-makes-things-faster-and-more-reliable-huh/38474):
>
> Here’s the question: Why would adding a pause to the Page is Loaded workflow result in two improvements? The page loads noticeably faster. An action that is otherwise skipped is executed as it should be. Why does a pause speed things up and make them work as they should??? The app has a page that loads an Action thing (think "To Do") along with some other associated things. One "trick" in the app is to set a page-level custom state, "isDirty", to indicate when any element on the page has …

Doing something about timing is clearly an issue for Bubble, according to the roadmap, [https://bubble.io/roadmap:](https://bubble.io/roadmap:)  
" Now

App performance

Systematically optimize most data-intensive queries

Monitor and reduce JS / JSON size

Apps bug-free at scale

Workflow consistency guarantees"

Perhaps I’m misinterpreting, but “Workflow consistency guarantees” sounds to me like workflows running as expected every time, i.e. timing and sequencing.

---

<div class="post-metadata">

**Author:** ![vini\_brito](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/vini_brito/32/22187_2.png) [@vini\_brito](https://forum.bubble.io/u/vini_brito)\
**Post date:** [September 24, 2018, 4:08am UTC](https://forum.bubble.io/t/very-strange-database-behavior/38506/10 "2018-09-24T04:08:46Z")

</div>

Thank you both for your answers! I’ll dip my toes in that water now

---

<div class="post-metadata">

**Author:** ![JohnMark](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/johnmark/32/42431_2.png) [@JohnMark](https://forum.bubble.io/u/JohnMark)\
**Post date:** [September 24, 2018, 5:05am UTC](https://forum.bubble.io/t/very-strange-database-behavior/38506/11 "2018-09-24T05:05:20Z")

</div>

There’s no way at the moment to add any pause between actions as I know. The pause action is only on client side.

---

<div class="post-metadata">

**Author:** ![emmanuel](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/emmanuel/32/27657_2.png) [@emmanuel](https://forum.bubble.io/u/emmanuel)\
**Post date:** [September 24, 2018, 5:06am UTC](https://forum.bubble.io/t/very-strange-database-behavior/38506/12 "2018-09-24T05:06:37Z")

</div>

What we mean by “Workflow consistency guarantees” is making sure that if two workflows touch the same thing in the database exactly at the same time we have a clear rule about the way the data is impacted. This is a corner case at scale that you’re very likely not hitting (i think I already told you that in another thread).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/bubble/original/3X/2/8/2847faa74692c2ffa5d939d3dc3724cdd060d247.png) [@system](https://forum.bubble.io/u/system)\
**Post date:** [October 6, 2018, 10:34pm UTC](https://forum.bubble.io/t/very-strange-database-behavior/38506/13 "2018-10-06T22:34:07Z")

</div>

Closed on October 6, 2018, 10:34pm UTC

This topic was automatically closed after 14 days. New replies are no longer allowed.
