Skip to content
This repository has been archived by the owner on Aug 3, 2022. It is now read-only.

Race condition. #20

Open
ChangXiaoning opened this issue Apr 12, 2021 · 0 comments
Open

Race condition. #20

ChangXiaoning opened this issue Apr 12, 2021 · 0 comments

Comments

@ChangXiaoning
Copy link

Hi, I think there is a race condition in your project: Since I want to store all objects in a single file, set the type option to single. Then, I have two non-blocking requests r1 and r2. r1 saves object o1 with id 1 and r2 deletes the object by id 1. json-file-store will prepare different this._cache to asynchronously write into file. Since two file writing are asynchronously executed, the content of the file is non-deterministic. In other words, it is non-deterministic whether is object with id 1 exists in the file. Maybe a better solution is to utilize a queue, which sequentializes multiple requests.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant