Apache9 commented on code in PR #4859:
URL: https://github.com/apache/hbase/pull/4859#discussion_r1011738398
##########
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:
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.
--
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]