How to avoid Race condition in Appsheet?

I am creating an app on the Seating Management for our offices. Admin can set number of seats for any specific location and employee can book that many number of seat (first come first serve basis)
Now in order to ensure there is no overbooking, I am doing the following,

  1. Check Office Capacity value that Admin has configured
  2. Check already booked record count for one particular day
  3. Subtract (1-2)
  4. If 3 is greater than 0 then only I am allowing new entries, so far so good.

Now the issue arises when multiple users are accessing the App simultaneously.
Assume only 1 place is left for the location and 3 users are accessing the App simultaneosuly. All 3 will see 1 place left and can book the same as there is no validation happening on Actual Save (Submit) form event.

Any thoughts on how to resolve this?

For Tech-Savvy friends : ‘How to avoid race condition in Appsheet?’

1 Like

Maybe you can use an action to navigate to that form view and force sync? You can refer this post META POST: Deep Links & URL Parameters

Its a problem you cannot stop, due to the fact Appsheet uses syncing and not a live connection to a SQL database. Turning off Delayed sync will help as this forces a sync after every save. But users will hate it. The only way I got around the issue was to create a bot that ran nightly to check for duplicate bookings and then report them so a human could sort them out.

Simon@1minManager.com

1 Like
2 Likes

Not possible.

2 Likes

Understood, thanks all for your suggestion/replies.

Hopefully this can be taken as a feature request as there are many use cases which needs to maintain the capacity/values in check.