This repository has been archived by the owner on May 14, 2022. It is now read-only.
Bug Report: Duplicate Data can be added to the database #113
Labels
Backend
A task for the backend of the system
bug
Something isn't working
Database
A task related to the database
High Priority
Important item
Bug Discovered
The backend was not starting because in one of its initialization checks, it found multiple records for the role/user/permission that it selected.
More details
It turns out that when starting the kubernetes instances (n instances), k of n instances such that 1 <= k <= n start running concurrently, with n-k instances waiting to be run.
For these k instances, each running concurrently, reads the database to find there is no data. These k instances run the data initialization script to populate the database - resulting in repeated initial data.
Possible Ramifications
Considering that these are 5 servers accessing the same database:
CREATE
requests multiple times at the same time could result in the same query being executed multiple timesUPDATE
requests multiple times could result in a race condition (if updating the same record with different values).DELETE
requests multiple times should not be affected. But if combined with anUPDATE
prREAD
could create a race condition.READ
requests multiple times should not be affected - or it might show slightly older data.Solution carried out:
The data was deleted and 1 server was started. Then, when the data was initialized, the other 4 were started.
Proposed Solution:
For initial data:
.sql
file which we run when we need to initialize the databases.For concurrency:
The text was updated successfully, but these errors were encountered: