KVStore: Reduce lock contention in RegionPersister::doPersist
(#8584)
#8595
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is an automated cherry-pick of #8584
What problem does this PR solve?
Issue Number: close #8583
Problem Summary:
tiflash/dbms/src/Storages/KVStore/MultiRaft/RegionPersister.cpp
Lines 99 to 125 in 5980908
RegionPersister::doPersist
acquires a lock and callsPageStorage::write
with the lock. This means when we're persisting Region meta, all other threads can not do the persistence for other Region meta. Which is not reasonable.What is changed and how it works?
There is a
region_task_lock
to ensure that only one thread could callRegionPersister::doPersist
at the same time. AndPageStorage
support multi-thread reading and writing for different page_id. There is no need to acquire another lock inRegionPersister::doPersist
that could slowdown the raft apply processAnd also remove calling
KVStore::persistRegion
with a nullregion_task_lock
. So we can simplify codes and remove the memberRegionPersister:: RegionManager
Check List
Tests
Side effects
Documentation
Release note