WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Possible race conditions #81

@Iain-S

Description

@Iain-S

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions