Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check that read happend before save. #66

Open
lavrukov opened this issue Apr 25, 2024 · 0 comments
Open

Check that read happend before save. #66

lavrukov opened this issue Apr 25, 2024 · 0 comments
Labels
feature New feature or request

Comments

@lavrukov
Copy link
Contributor

In our service, we predominantly do not use blind writes. We encountered a bug in the user code where we read an object in one transaction and saved it in another without a preliminary read. As a result, we ended up with an incorrect value in the database.

It's difficult to protect against such issues, however, an optional check can be added in the InMemoryRepository before saving: if the object is present in the database, we check the cache, and if the required object is not there, we fail. There are several problems here:

  • In our current implementation, we often use readAll(), so we cannot rely solely on the storage output.
  • Relying on the standard cache is not feasible, as it does not always contain all read objects. A custom cache is needed.
  • We need to consider how to add exceptions for cases where blind writing is justified. For example, adding a wrapper similar to the one in FullScanDetector.
@lavrukov lavrukov added the feature New feature or request label Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant