HBASE-18487 Minor fixes in row lock implementation
Signed-off-by: Andrew Purtell <apurtell@apache.org>
This commit is contained in:
parent
7bdabed275
commit
f67dae90f9
|
@ -5404,6 +5404,7 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
|
||||||
traceScope.getSpan().addTimelineAnnotation("Getting a " + (readLock?"readLock":"writeLock"));
|
traceScope.getSpan().addTimelineAnnotation("Getting a " + (readLock?"readLock":"writeLock"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean success = false;
|
||||||
try {
|
try {
|
||||||
// Keep trying until we have a lock or error out.
|
// Keep trying until we have a lock or error out.
|
||||||
// TODO: do we need to add a time component here?
|
// TODO: do we need to add a time component here?
|
||||||
|
@ -5434,8 +5435,6 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
|
||||||
traceScope.getSpan().addTimelineAnnotation("Failed to get row lock");
|
traceScope.getSpan().addTimelineAnnotation("Failed to get row lock");
|
||||||
}
|
}
|
||||||
result = null;
|
result = null;
|
||||||
// Clean up the counts just in case this was the thing keeping the context alive.
|
|
||||||
rowLockContext.cleanUp();
|
|
||||||
String message = "Timed out waiting for lock for row: " + rowKey + " in region "
|
String message = "Timed out waiting for lock for row: " + rowKey + " in region "
|
||||||
+ getRegionInfo().getEncodedName();
|
+ getRegionInfo().getEncodedName();
|
||||||
if (reachDeadlineFirst) {
|
if (reachDeadlineFirst) {
|
||||||
|
@ -5446,6 +5445,7 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rowLockContext.setThreadName(Thread.currentThread().getName());
|
rowLockContext.setThreadName(Thread.currentThread().getName());
|
||||||
|
success = true;
|
||||||
return result;
|
return result;
|
||||||
} catch (InterruptedException ie) {
|
} catch (InterruptedException ie) {
|
||||||
LOG.warn("Thread interrupted waiting for lock on row: " + rowKey);
|
LOG.warn("Thread interrupted waiting for lock on row: " + rowKey);
|
||||||
|
@ -5457,6 +5457,10 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
|
||||||
Thread.currentThread().interrupt();
|
Thread.currentThread().interrupt();
|
||||||
throw iie;
|
throw iie;
|
||||||
} finally {
|
} finally {
|
||||||
|
// Clean up the counts just in case this was the thing keeping the context alive.
|
||||||
|
if (!success && rowLockContext != null) {
|
||||||
|
rowLockContext.cleanUp();
|
||||||
|
}
|
||||||
if (traceScope != null) {
|
if (traceScope != null) {
|
||||||
traceScope.close();
|
traceScope.close();
|
||||||
}
|
}
|
||||||
|
@ -5519,7 +5523,7 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
|
||||||
long c = count.decrementAndGet();
|
long c = count.decrementAndGet();
|
||||||
if (c <= 0) {
|
if (c <= 0) {
|
||||||
synchronized (lock) {
|
synchronized (lock) {
|
||||||
if (count.get() <= 0){
|
if (count.get() <= 0 && usable.get()){ // Don't attempt to remove row if already removed
|
||||||
usable.set(false);
|
usable.set(false);
|
||||||
RowLockContext removed = lockedRows.remove(row);
|
RowLockContext removed = lockedRows.remove(row);
|
||||||
assert removed == this: "we should never remove a different context";
|
assert removed == this: "we should never remove a different context";
|
||||||
|
|
Loading…
Reference in New Issue