Skip to content

Race condition with JsonFileDatabaseAdapter #39

@Arcensoth

Description

@Arcensoth

This was observed with the WIP automod extension. If a user sends a command that causes a write operation (such as adding a rule), there will be a race condition between the command handler and any rules that are listening for send_message event.

My guess it that these are two separate asyncio tasks running concurrently, and each one hits the get_cache() method independently. Whoever's second will cause self.__cache to overwrite itself.

Assuming these are indeed separate asyncio tasks, the solution should be as simple as surrounding the critical portion of get_cache() method with a lock so that only a single task is ever evaluating and/or initializing __cache at any given time.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions