HBASE-10679 Both clients get wrong scan results if the first scanner expires and the second scanner is created with the same scannerId on the same region
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1576928 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3c8cc0b799
commit
d8ce8d0506
|
@ -43,6 +43,7 @@ import java.util.Set;
|
|||
import java.util.SortedMap;
|
||||
import java.util.TreeMap;
|
||||
import java.util.TreeSet;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.concurrent.ConcurrentSkipListMap;
|
||||
|
@ -256,6 +257,8 @@ public class HRegionServer implements ClientProtos.ClientService.BlockingInterfa
|
|||
|
||||
private final Random rand;
|
||||
|
||||
private final AtomicLong scannerIdGen = new AtomicLong(0L);
|
||||
|
||||
/*
|
||||
* Strings to be used in forming the exception message for
|
||||
* RegionsAlreadyInTransitionException.
|
||||
|
@ -2801,18 +2804,16 @@ public class HRegionServer implements ClientProtos.ClientService.BlockingInterfa
|
|||
}
|
||||
|
||||
protected long addScanner(RegionScanner s, HRegion r) throws LeaseStillHeldException {
|
||||
long scannerId = -1;
|
||||
while (true) {
|
||||
scannerId = Math.abs(rand.nextLong() << 24) ^ startcode;
|
||||
String scannerName = String.valueOf(scannerId);
|
||||
RegionScannerHolder existing =
|
||||
scanners.putIfAbsent(scannerName, new RegionScannerHolder(s, r));
|
||||
if (existing == null) {
|
||||
this.leases.createLease(scannerName, this.scannerLeaseTimeoutPeriod,
|
||||
new ScannerListener(scannerName));
|
||||
break;
|
||||
}
|
||||
}
|
||||
long scannerId = this.scannerIdGen.incrementAndGet();
|
||||
String scannerName = String.valueOf(scannerId);
|
||||
|
||||
RegionScannerHolder existing =
|
||||
scanners.putIfAbsent(scannerName, new RegionScannerHolder(s, r));
|
||||
assert existing == null : "scannerId must be unique within regionserver's whole lifecycle!";
|
||||
|
||||
this.leases.createLease(scannerName, this.scannerLeaseTimeoutPeriod,
|
||||
new ScannerListener(scannerName));
|
||||
|
||||
return scannerId;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue