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

thread safety: KV::Store::clear() requires version spinlock #855

Closed
douglasism opened this issue Feb 18, 2020 · 1 comment · Fixed by #900
Closed

thread safety: KV::Store::clear() requires version spinlock #855

douglasism opened this issue Feb 18, 2020 · 1 comment · Fixed by #900
Assignees
Labels

Comments

@douglasism
Copy link

Description

kv.h::Store::clear needs a version spinlock

      std::lock_guard<SpinLock> vguard(version_lock);
    void clear()
    {
      std::lock_guard<SpinLock> mguard(maps_lock);

      // This deletes the entire content of all maps in the store.
      for (auto& map : maps)
        map.second->lock();

      for (auto& map : maps)
        map.second->clear();

      for (auto& map : maps)
        map.second->unlock();

<<<<<<<<<<<<<<<<< missing version_lock >>>>>>>>>>>>>>
      version = 0;
      compacted = 0;
      last_replicated = 0;
      last_committable = 0;
      rollback_count = 0;
      pending_txs.clear();
    }

@douglasism douglasism added the bug label Feb 18, 2020
@achamayou achamayou mentioned this issue Feb 28, 2020
@achamayou achamayou self-assigned this Feb 28, 2020
@achamayou
Copy link
Member

@douglasism this call is only used in tests, but you're absolutely right!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants