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
- Any way to temporarily bypass the email ...
Hey guys, any way to bypass the email verification to use the accounts again? i need to recover some projects that due to recent changes have been stopped, and ...
- Create a new paid tier
Current pricing seems reasonable enough about what is someone getting for 25$. But for some people most of these resouces are getting wasted. Like the bandwidt...
- [Bug] Appwrite Auth User Prefs
User prefs are decoded as blank although there are plenty of data and add preference button not working in this case