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
Please register or sign in to comment