-
Notifications
You must be signed in to change notification settings - Fork 1
Description
The RCTab web server may have race conditions. Though these do not seem to have caused noticeable exceptions, nor obvious data corruption to date, we should still take precautions against them.
We are using an async app with multiple workers (at least in production), which means that there is potential for race conditions. As an example, we call refresh_desired_states() from several async routes. These routes could be called simultaneously by the different function apps.
Possible methods of mitigation include:
- DB row locking
- Avoiding ever writing to the same tables
- Using asyncio locks
- Using a single worker with synchronous router functions
- Using some kind of synchronous task queue
See https://github.com/Hypro999/racy-django for a brief explanation of the root case of race conditions in CRUD apps and a tool to experiment with methods of remediation.
See https://github.com/Iain-S/racy-fastapi for a simple repo to test possible solutions.