Skip to content

Refactor db mutex#278

Merged
ShooterIT merged 3 commits intoapache:unstablefrom
ShooterIT:db-mutex
May 28, 2021
Merged

Refactor db mutex#278
ShooterIT merged 3 commits intoapache:unstablefrom
ShooterIT:db-mutex

Conversation

@ShooterIT
Copy link
Member

  1. In SubKeyFilter, remove lock to access db, because we call CancelAllBackgroundWork(wait=true) when closing db.
  2. Use read write lock to replace incr/decr refs for db, and in IncrDBRefs, we also check closing flag, that doesn't its name.
    now, i think, it is much easy to understand:
    • acquire db read lock firstly and check flag when reading db
    • acquire db write lock, then close db and set closing flag when writing db

I think all accesses of db are protected when closing db.

@bitleak/kvrocks-core-team I know this PR is dangerous, even i don't test for that :). You(@git-hulk and @karelrooted ) already costed much energy to find many bugs before, but I still open that, we should push this project forward, so it is much important to keep code easy to understand and modify, actually i have plan to refactor ReclaimOldPtr . So ask you to help me review, maybe you can reproduce old bugs conditions to check it.

from a saboteur

@ShooterIT ShooterIT requested review from git-hulk and karelrooted May 26, 2021 13:40
@ShooterIT ShooterIT added the major decision Requires project management committee consensus label May 26, 2021
@ShooterIT ShooterIT marked this pull request as draft May 27, 2021 02:29
@ShooterIT ShooterIT marked this pull request as ready for review May 27, 2021 06:01
karelrooted
karelrooted previously approved these changes May 27, 2021
@ShooterIT ShooterIT merged commit cdb0cce into apache:unstable May 28, 2021
@ShooterIT ShooterIT deleted the db-mutex branch May 28, 2021 07:01
ShooterIT added a commit to ShooterIT/kvrocks that referenced this pull request Jul 15, 2021
- Refactor db mutex using rwlock
- A implementation of RAII write-first read-write lock using C++11
- Add some tests for rwlock
ShooterIT added a commit that referenced this pull request Jul 19, 2021
- Refactor db mutex using rwlock
- A implementation of RAII write-first read-write lock using C++11
- Add some tests for rwlock
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

major decision Requires project management committee consensus

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants