Mike H
Mike H

Reputation: 125

Handle race condition with two cloud functions changing the same data

I have two cloud functions that potentially change the same documents.

How do I avoid a potential race condition and ensure that one of the cloud functions finishes before the other one starts?

Thank you in advance.

Upvotes: 0

Views: 481

Answers (1)

Frank van Puffelen
Frank van Puffelen

Reputation: 599041

There is no way to guarantee ordering of Cloud Function invocations.

This means that you will have to solve the problem in your implementation. It's impossible to say how to precisely do that for you use-case without seeing an MCVE, but it'll typically involve one of more database transactions.

Also see:

Upvotes: 2

Related Questions