HBASE-24311 Add more details in MultiVersionConcurrencyControl STUCK log message (#1654)

This commit is contained in:
Anoop Sam John 2020-05-05 16:25:40 +05:30 committed by Andrew Purtell
parent 5cd2aa8913
commit e4dbfe9bed
No known key found for this signature in database
GPG Key ID: 8597754DD5365CCD
2 changed files with 20 additions and 7 deletions

View File

@ -669,7 +669,7 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
private boolean splitRequest;
private byte[] explicitSplitPoint = null;
private final MultiVersionConcurrencyControl mvcc = new MultiVersionConcurrencyControl();
private final MultiVersionConcurrencyControl mvcc;
// Coprocessor host
private RegionCoprocessorHost coprocessorHost;
@ -744,6 +744,7 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
this.comparator = fs.getRegionInfo().getComparator();
this.wal = wal;
this.fs = fs;
this.mvcc = new MultiVersionConcurrencyControl(getRegionInfo().getShortNameToLog());
// 'conf' renamed to 'confParam' b/c we use this.conf in the constructor
this.baseConf = confParam;

View File

@ -20,6 +20,7 @@ package org.apache.hadoop.hbase.regionserver;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper;
import java.util.LinkedList;
import java.util.concurrent.atomic.AtomicLong;
@ -40,7 +41,9 @@ import org.apache.hadoop.hbase.util.ClassSize;
public class MultiVersionConcurrencyControl {
private static final Log LOG = LogFactory.getLog(MultiVersionConcurrencyControl.class);
static final long NO_WRITE_NUMBER = 0;
private static final long READPOINT_ADVANCE_WAIT_TIME = 10L;
final String regionName;
final AtomicLong readPoint = new AtomicLong(0);
final AtomicLong writePoint = new AtomicLong(0);
private final Object readWaiters = new Object();
@ -58,13 +61,18 @@ public class MultiVersionConcurrencyControl {
private final LinkedList<WriteEntry> writeQueue = new LinkedList<WriteEntry>();
public MultiVersionConcurrencyControl() {
super();
this(null);
}
public MultiVersionConcurrencyControl(String regionName) {
this.regionName = regionName;
}
/**
* Construct and set read point. Write point is uninitialized.
*/
public MultiVersionConcurrencyControl(long startPoint) {
this(null);
tryAdvanceTo(startPoint, NONE);
}
@ -227,11 +235,12 @@ public class MultiVersionConcurrencyControl {
synchronized (readWaiters) {
while (readPoint.get() < e.getWriteNumber()) {
if (count % 100 == 0 && count > 0) {
LOG.warn("STUCK: " + this);
long totalWaitTillNow = READPOINT_ADVANCE_WAIT_TIME * count;
LOG.warn("STUCK for : " + totalWaitTillNow + " millis. " + this);
}
count++;
try {
readWaiters.wait(10);
readWaiters.wait(READPOINT_ADVANCE_WAIT_TIME);
} catch (InterruptedException ie) {
// We were interrupted... finish the loop -- i.e. cleanup --and then
// on our way out, reset the interrupt flag.
@ -247,9 +256,12 @@ public class MultiVersionConcurrencyControl {
@VisibleForTesting
@Override
public String toString() {
return Objects.toStringHelper(this)
.add("readPoint", readPoint)
.add("writePoint", writePoint).toString();
ToStringHelper helper = Objects.toStringHelper(this).add("readPoint", readPoint)
.add("writePoint", writePoint);
if (this.regionName != null) {
helper.add("regionName", this.regionName);
}
return helper.toString();
}
public long getReadPoint() {