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
- Apple OAuth Scopes
Hi Hi, I've configured sign in with apple and this is the response i'm getting from apple once i've signed in. I cant find anywhere I set scopes. I remember se...
- Sign In With Apple OAuth Help
Hi All! I've got a flutter & appwrite app which Im trying to use sign in with apple for. I already have sign in with google working and the function is the sam...
- Custom Domains
Hi All, Should be a quick config issue. I'm setting up custom domains on the hosted version. I have verified the domain with the CNAME but appwrite isn't gene...