frostruan commented on code in PR #4859:
URL: https://github.com/apache/hbase/pull/4859#discussion_r1011250021
##########
hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RegionScannerImpl.java:
##########
@@ -130,19 +130,34 @@ private static boolean hasNonce(HRegion region, long
nonce) {
long mvccReadPoint = PackagePrivateFieldAccessor.getMvccReadPoint(scan);
this.scannerReadPoints = region.scannerReadPoints;
this.rsServices = region.getRegionServerServices();
- synchronized (scannerReadPoints) {
- if (mvccReadPoint > 0) {
- this.readPt = mvccReadPoint;
- } else if (hasNonce(region, nonce)) {
- this.readPt =
rsServices.getNonceManager().getMvccFromOperationContext(nonceGroup, nonce);
- } else {
- this.readPt = region.getReadPoint(isolationLevel);
+ if (region.useReadWriteLockForReadPoints) {
+ region.scannerReadPointsLock.readLock().lock();
+ try {
+ this.readPt = calculateReadPoint(isolationLevel, mvccReadPoint,
nonceGroup, nonce);
+ scannerReadPoints.put(this, this.readPt);
Review Comment:
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.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]