-
Couldn't load subscription status.
- Fork 3.4k
HBASE-27458 Use ReadWriteLock for region scanner readpoint map #4859
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
Conversation
|
💔 -1 overall
This message was automatically generated. |
|
🎊 +1 overall
This message was automatically generated. |
|
💔 -1 overall
This message was automatically generated. |
| region.scannerReadPointsLock.readLock().lock(); | ||
| try { | ||
| this.readPt = calculateReadPoint(isolationLevel, mvccReadPoint, nonceGroup, nonce); | ||
| scannerReadPoints.put(this, this.readPt); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we also modified the scannerReadPoints? Why just use read lock here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review Duo
The scannerReadPoints is ConcurrentHashMap, which is thread-safe. So we can modified it concurrently. Shared lock is enough. But when getSmallestReadPoint, we need to ensure that scannerReadPoints can not be modified, we need exclusive lock.
So when modify it, we need to acquire shared lock and when read it, we need to acquire exclusive lock.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then I think what we want to protect here is not scannerReadPoints itself, but a special operation? So I prefer we change the name of the lock, maybe call it smallestReadPointsCalcLock?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, let me rename it and fix the UT problems, Thanks Duo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And why do we need to introduce a new flag here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When we do delta operation like increment/append, we will need to get the smallest read point.
If we both have heavy delta operation load and heavy read load, the write lock may reduce the write performance. so let's introduce a flag to make this decided by the user.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then I suggest we implement a class called ReadPointCalcuationLock, and introduce two types of lock, one is lockForCalculation, the other is lockForRecording. And we put the flag in this class, when it is enabled, we use a read write lock, and use write lock for calculation, and use read lock for recording. when it is disabled, we just use a lock.
I think this could make the code cleaner. WDYT?
Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. let me address it.
Thanks for your suggestion. Duo.
Signed-off-by: huiruan <[email protected]>
Signed-off-by: huiruan <[email protected]>
Signed-off-by: huiruan <[email protected]>
83c7983 to
80fba10
Compare
|
Hi Duo @Apache9 I added a new commit. Would mind taking a look in your free time and see is this what you expect ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is what I expected.
Just need to add more comments.
Thanks.
|
|
||
| ReadPointCalculationLock(Configuration conf) { | ||
| this.useReadWriteLockForReadPoints = | ||
| conf.getBoolean("hbase.readpoints.read.write.lock.enable", false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better name it hbase.region.xxx, as the lock is per region.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok.
| import org.apache.yetus.audience.InterfaceAudience; | ||
|
|
||
| /** | ||
| * Lock to manage concurrency between RegionScanner and getSmallestReadPoint. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add more comments here to explain why we have this class and why we have a flag to control whether to use read write lock or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok.
|
Thanks for reviewing Duo.Let's wait for the unit test results. |
|
🎊 +1 overall
This message was automatically generated. |
|
🎊 +1 overall
This message was automatically generated. |
|
🎊 +1 overall
This message was automatically generated. |
|
🎊 +1 overall
This message was automatically generated. |
|
💔 -1 overall
This message was automatically generated. |
|
💔 -1 overall
This message was automatically generated. |
…e#4859) Co-authored-by: huiruan <[email protected]> Signed-off-by: Duo Zhang <[email protected]>
#5073) Signed-off-by: Duo Zhang <[email protected]>
No description provided.