In response to this: https://discord.com/channels/564160730845151244/1212740439438917652/1214247596046942218
Could the system reliably manage a scenario where it needs to check the balance before updating it? For example, if the current balance is $10, and a transaction requires verifying the balance before adding an amount, would the queued events guarantee that the second order waits for the completion of the first order before checking the balance? An example situation where the first order completes, resulting in a new balance of $15, and the second order should then consider this updated balance. "In situations of high traffic"
Hi 👋 You could implement a locking mechanism to prevent two executions from doing the same action. We even do this inside Appwrite for an edge case with GItHub comments - we need to get and then update - and we dont want 2 deployments to override at the same time. Here is how we do it: https://github.com/appwrite/appwrite/blob/7273d0e1177c70ee45fe8049459e70ef574515a6/src/Appwrite/Platform/Workers/Builds.php#L606-L633
Relevant support thread on similar topic: https://discord.com/channels/564160730845151244/1212189084793966632/1212700149390778438
Thanks @Meldiron based on the similar topic if I'm correct it's basically:
- Create a lock collection in the appwrite database that holds lock documents
- Create the function
- The function checks to see if a lock document already exists
- If it does exist it has to retry after a certain time period let's say 1 second
- If it doesn't exist create a new lock document in the lock collection, and the function can proceed
- After the function execution is complete, delete the lock file that it created.
- Loop
Is this correct?
Recommended threads
- is `account.get()` safe to be used in th...
I want to user's `id` for authentication. However, a while ago I was told in this server not to use `account.get()` and instead add user preferences for that us...
- Appwrite console is too heavy
The Appwrite console is too heavy And all of my services broken Any support , please
- router_deployment_not_found
I updated my function a few times and now i am getting the error: router_deployment_not_found I even reverted back to my original code but i am still getting th...