HBASE-4789 On split, parent region is sticking around in oldest sequenceid to region map though not online; we don't cleanup WALs
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1204034 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1a83d9528b
commit
39d7828814
|
@ -1286,7 +1286,7 @@ public class HRegion implements HeapSize { // , Writable{
|
||||||
w = mvcc.beginMemstoreInsert();
|
w = mvcc.beginMemstoreInsert();
|
||||||
mvcc.advanceMemstore(w);
|
mvcc.advanceMemstore(w);
|
||||||
|
|
||||||
sequenceId = (wal == null)? myseqid :
|
sequenceId = (wal == null)? myseqid:
|
||||||
wal.startCacheFlush(this.regionInfo.getEncodedNameAsBytes());
|
wal.startCacheFlush(this.regionInfo.getEncodedNameAsBytes());
|
||||||
completeSequenceId = this.getCompleteCacheFlushSequenceId(sequenceId);
|
completeSequenceId = this.getCompleteCacheFlushSequenceId(sequenceId);
|
||||||
|
|
||||||
|
@ -1302,7 +1302,7 @@ public class HRegion implements HeapSize { // , Writable{
|
||||||
this.updatesLock.writeLock().unlock();
|
this.updatesLock.writeLock().unlock();
|
||||||
}
|
}
|
||||||
status.setStatus("Waiting for mvcc");
|
status.setStatus("Waiting for mvcc");
|
||||||
LOG.debug("Finished snapshotting, commencing waiting for mvcc");
|
LOG.debug("Finished snapshotting " + this + ", commencing wait for mvcc");
|
||||||
|
|
||||||
// wait for all in-progress transactions to commit to HLog before
|
// wait for all in-progress transactions to commit to HLog before
|
||||||
// we can start the flush. This prevents
|
// we can start the flush. This prevents
|
||||||
|
|
|
@ -115,11 +115,11 @@ class LogRoller extends HasThread implements WALActionsListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param region Encoded name of region to flush.
|
* @param encodedRegionName Encoded name of region to flush.
|
||||||
*/
|
*/
|
||||||
private void scheduleFlush(final byte [] region) {
|
private void scheduleFlush(final byte [] encodedRegionName) {
|
||||||
boolean scheduled = false;
|
boolean scheduled = false;
|
||||||
HRegion r = this.services.getFromOnlineRegions(Bytes.toString(region));
|
HRegion r = this.services.getFromOnlineRegions(Bytes.toString(encodedRegionName));
|
||||||
FlushRequester requester = null;
|
FlushRequester requester = null;
|
||||||
if (r != null) {
|
if (r != null) {
|
||||||
requester = this.services.getFlushRequester();
|
requester = this.services.getFlushRequester();
|
||||||
|
@ -130,7 +130,8 @@ class LogRoller extends HasThread implements WALActionsListener {
|
||||||
}
|
}
|
||||||
if (!scheduled) {
|
if (!scheduled) {
|
||||||
LOG.warn("Failed to schedule flush of " +
|
LOG.warn("Failed to schedule flush of " +
|
||||||
Bytes.toString(region) + "r=" + r + ", requester=" + requester);
|
Bytes.toString(encodedRegionName) + ", region=" + r + ", requester=" +
|
||||||
|
requester);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -187,8 +187,8 @@ public class HLog implements Syncable {
|
||||||
Collections.synchronizedSortedMap(new TreeMap<Long, Path>());
|
Collections.synchronizedSortedMap(new TreeMap<Long, Path>());
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Map of regions to most recent sequence/edit id in their memstore.
|
* Map of encoded region names to their most recent sequence/edit id in their
|
||||||
* Key is encoded region name.
|
* memstore.
|
||||||
*/
|
*/
|
||||||
private final ConcurrentSkipListMap<byte [], Long> lastSeqWritten =
|
private final ConcurrentSkipListMap<byte [], Long> lastSeqWritten =
|
||||||
new ConcurrentSkipListMap<byte [], Long>(Bytes.BYTES_COMPARATOR);
|
new ConcurrentSkipListMap<byte [], Long>(Bytes.BYTES_COMPARATOR);
|
||||||
|
@ -745,9 +745,8 @@ public class HLog implements Syncable {
|
||||||
// If too many log files, figure which regions we need to flush.
|
// If too many log files, figure which regions we need to flush.
|
||||||
// Array is an array of encoded region names.
|
// Array is an array of encoded region names.
|
||||||
byte [][] regions = null;
|
byte [][] regions = null;
|
||||||
int logCount = this.outputfiles.size();
|
int logCount = this.outputfiles == null? 0: this.outputfiles.size();
|
||||||
if (logCount > this.maxLogs && this.outputfiles != null &&
|
if (logCount > this.maxLogs && logCount > 0) {
|
||||||
this.outputfiles.size() > 0) {
|
|
||||||
// This is an array of encoded region names.
|
// This is an array of encoded region names.
|
||||||
regions = findMemstoresWithEditsEqualOrOlderThan(this.outputfiles.firstKey(),
|
regions = findMemstoresWithEditsEqualOrOlderThan(this.outputfiles.firstKey(),
|
||||||
this.lastSeqWritten);
|
this.lastSeqWritten);
|
||||||
|
@ -769,7 +768,7 @@ public class HLog implements Syncable {
|
||||||
* Return regions (memstores) that have edits that are equal or less than
|
* Return regions (memstores) that have edits that are equal or less than
|
||||||
* the passed <code>oldestWALseqid</code>.
|
* the passed <code>oldestWALseqid</code>.
|
||||||
* @param oldestWALseqid
|
* @param oldestWALseqid
|
||||||
* @param regionsToSeqids
|
* @param regionsToSeqids Encoded region names to sequence ids
|
||||||
* @return All regions whose seqid is < than <code>oldestWALseqid</code> (Not
|
* @return All regions whose seqid is < than <code>oldestWALseqid</code> (Not
|
||||||
* necessarily in order). Null if no regions found.
|
* necessarily in order). Null if no regions found.
|
||||||
*/
|
*/
|
||||||
|
@ -780,6 +779,7 @@ public class HLog implements Syncable {
|
||||||
for (Map.Entry<byte [], Long> e: regionsToSeqids.entrySet()) {
|
for (Map.Entry<byte [], Long> e: regionsToSeqids.entrySet()) {
|
||||||
if (e.getValue().longValue() <= oldestWALseqid) {
|
if (e.getValue().longValue() <= oldestWALseqid) {
|
||||||
if (regions == null) regions = new ArrayList<byte []>();
|
if (regions == null) regions = new ArrayList<byte []>();
|
||||||
|
// Key is encoded region name.
|
||||||
regions.add(e.getKey());
|
regions.add(e.getKey());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -802,6 +802,7 @@ public class HLog implements Syncable {
|
||||||
byte [] oldestRegion = null;
|
byte [] oldestRegion = null;
|
||||||
for (Map.Entry<byte [], Long> e: this.lastSeqWritten.entrySet()) {
|
for (Map.Entry<byte [], Long> e: this.lastSeqWritten.entrySet()) {
|
||||||
if (e.getValue().longValue() == oldestOutstandingSeqNum.longValue()) {
|
if (e.getValue().longValue() == oldestOutstandingSeqNum.longValue()) {
|
||||||
|
// Key is encoded region name.
|
||||||
oldestRegion = e.getKey();
|
oldestRegion = e.getKey();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1092,9 +1093,9 @@ public class HLog implements Syncable {
|
||||||
// is greater than or equal to the value in lastSeqWritten.
|
// is greater than or equal to the value in lastSeqWritten.
|
||||||
// Use encoded name. Its shorter, guaranteed unique and a subset of
|
// Use encoded name. Its shorter, guaranteed unique and a subset of
|
||||||
// actual name.
|
// actual name.
|
||||||
byte [] hriKey = info.getEncodedNameAsBytes();
|
byte [] encodedRegionName = info.getEncodedNameAsBytes();
|
||||||
this.lastSeqWritten.putIfAbsent(hriKey, seqNum);
|
this.lastSeqWritten.putIfAbsent(encodedRegionName, seqNum);
|
||||||
HLogKey logKey = makeKey(hriKey, tableName, seqNum, now, clusterId);
|
HLogKey logKey = makeKey(encodedRegionName, tableName, seqNum, now, clusterId);
|
||||||
doWrite(info, logKey, edits, htd);
|
doWrite(info, logKey, edits, htd);
|
||||||
this.numEntries.incrementAndGet();
|
this.numEntries.incrementAndGet();
|
||||||
txid = this.unflushedEntries.incrementAndGet();
|
txid = this.unflushedEntries.incrementAndGet();
|
||||||
|
@ -1537,6 +1538,11 @@ public class HLog implements Syncable {
|
||||||
// Cleaning up of lastSeqWritten is in the finally clause because we
|
// Cleaning up of lastSeqWritten is in the finally clause because we
|
||||||
// don't want to confuse getOldestOutstandingSeqNum()
|
// don't want to confuse getOldestOutstandingSeqNum()
|
||||||
this.lastSeqWritten.remove(getSnapshotName(encodedRegionName));
|
this.lastSeqWritten.remove(getSnapshotName(encodedRegionName));
|
||||||
|
Long l = this.lastSeqWritten.remove(encodedRegionName);
|
||||||
|
if (l != null) {
|
||||||
|
LOG.warn("Why is there a raw encodedRegionName in lastSeqWritten? name=" +
|
||||||
|
Bytes.toString(encodedRegionName) + ", seqid=" + l);
|
||||||
|
}
|
||||||
this.cacheFlushLock.unlock();
|
this.cacheFlushLock.unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue