Commit 88a078cb authored by Igor Chorazewicz's avatar Igor Chorazewicz
Browse files

concurrent_hash_map: implement rehash_bucket using a transaction

This fixes problem with inconsistent state after crash. In previous implementation
if application crashed in the middle of rehash it was possible that two buckets
(old and new) pointed to the same element. This meant that size could be too big
(some elements could be counted twice). Putting all operations which change list
pointers inside of a transction solves this issue and eliminates requirement
to have 'restore_after_crash' logic.

set_rehashed is done outside of a transaction because otherwise:
- on abort rehashed flag would be rolled back by obj using memcpy instead of
  std::atomic API which could be UB
- some thread could check for rehashed flag and decide that rehash is not needed
  but after that transaction could abort and move elements back
parent 326d0c8a
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment