sails: Race condition in update
Reopening #189, since it doesn’t appear to be resolved.
There is a race condition in update (in adapter.js) that I’ve run into a few times. The current update implementation works by:
- Query with the given criteria to get a list of ids
- Update with the given criteria
- Query with the list of ids from step 1 to get the updated objects
The problem is that if other updates happen between steps 1 and 2, the data returned in step 3 could be inaccurate (either omitting/including records that were/were not affected).
Since this is a MySQL specific driver, there’s a pretty clever way of capturing the ids for updated records.
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 19 (10 by maintainers)
I don’t think transactions alone would help; at least not with the default isolation level.
From the MySQL docs: