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

Safety around NextWriteNoWriteConflictRange logic in parallel context. #206

Open
Speedy37 opened this issue Sep 27, 2020 · 0 comments
Open
Labels
help wanted Extra attention is needed question Further information is requested

Comments

@Speedy37
Copy link
Contributor

Currently set_option only require a reference to the transaction to work.

This means it can be called by multiple thread in parallel without ownership of the transaction.
There is currently one option that concerns me: NextWriteNoWriteConflictRange

The next write performed on this transaction will not generate a write conflict range. As a result, other transactions which read the key(s) being modified by the next write will not conflict with this transaction. Care needs to be taken when using this option on a transaction that is shared between multiple threads. When setting this option, write conflict ranges will be disabled on the next write operation, regardless of what thread it is on.

There are multiple ways to prevent that :

  • give access to a new API with mutex protection (add complexity on Transaction struct Option<Box<Mutex>>)
  • protect the affected method/option by requiring a mutable reference to the transaction, safe but might create a pain to use it
  • only protect NextWriteNoWriteConflictRange with a global (😒) mutex (or something clever)
  • do nothing and let users handle that themselves
@Speedy37 Speedy37 added help wanted Extra attention is needed question Further information is requested labels Sep 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant