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:
Michael Stack 2011-11-19 18:27:51 +00:00
parent 1a83d9528b
commit 39d7828814
3 changed files with 23 additions and 16 deletions

View File

@ -1302,7 +1302,7 @@ public class HRegion implements HeapSize { // , Writable{
this.updatesLock.writeLock().unlock();
}
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
// we can start the flush. This prevents

View File

@ -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;
HRegion r = this.services.getFromOnlineRegions(Bytes.toString(region));
HRegion r = this.services.getFromOnlineRegions(Bytes.toString(encodedRegionName));
FlushRequester requester = null;
if (r != null) {
requester = this.services.getFlushRequester();
@ -130,7 +130,8 @@ class LogRoller extends HasThread implements WALActionsListener {
}
if (!scheduled) {
LOG.warn("Failed to schedule flush of " +
Bytes.toString(region) + "r=" + r + ", requester=" + requester);
Bytes.toString(encodedRegionName) + ", region=" + r + ", requester=" +
requester);
}
}

View File

@ -187,8 +187,8 @@ public class HLog implements Syncable {
Collections.synchronizedSortedMap(new TreeMap<Long, Path>());
/*
* Map of regions to most recent sequence/edit id in their memstore.
* Key is encoded region name.
* Map of encoded region names to their most recent sequence/edit id in their
* memstore.
*/
private final ConcurrentSkipListMap<byte [], Long> lastSeqWritten =
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.
// Array is an array of encoded region names.
byte [][] regions = null;
int logCount = this.outputfiles.size();
if (logCount > this.maxLogs && this.outputfiles != null &&
this.outputfiles.size() > 0) {
int logCount = this.outputfiles == null? 0: this.outputfiles.size();
if (logCount > this.maxLogs && logCount > 0) {
// This is an array of encoded region names.
regions = findMemstoresWithEditsEqualOrOlderThan(this.outputfiles.firstKey(),
this.lastSeqWritten);
@ -769,7 +768,7 @@ public class HLog implements Syncable {
* Return regions (memstores) that have edits that are equal or less than
* the passed <code>oldestWALseqid</code>.
* @param oldestWALseqid
* @param regionsToSeqids
* @param regionsToSeqids Encoded region names to sequence ids
* @return All regions whose seqid is < than <code>oldestWALseqid</code> (Not
* 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()) {
if (e.getValue().longValue() <= oldestWALseqid) {
if (regions == null) regions = new ArrayList<byte []>();
// Key is encoded region name.
regions.add(e.getKey());
}
}
@ -802,6 +802,7 @@ public class HLog implements Syncable {
byte [] oldestRegion = null;
for (Map.Entry<byte [], Long> e: this.lastSeqWritten.entrySet()) {
if (e.getValue().longValue() == oldestOutstandingSeqNum.longValue()) {
// Key is encoded region name.
oldestRegion = e.getKey();
break;
}
@ -1092,9 +1093,9 @@ public class HLog implements Syncable {
// is greater than or equal to the value in lastSeqWritten.
// Use encoded name. Its shorter, guaranteed unique and a subset of
// actual name.
byte [] hriKey = info.getEncodedNameAsBytes();
this.lastSeqWritten.putIfAbsent(hriKey, seqNum);
HLogKey logKey = makeKey(hriKey, tableName, seqNum, now, clusterId);
byte [] encodedRegionName = info.getEncodedNameAsBytes();
this.lastSeqWritten.putIfAbsent(encodedRegionName, seqNum);
HLogKey logKey = makeKey(encodedRegionName, tableName, seqNum, now, clusterId);
doWrite(info, logKey, edits, htd);
this.numEntries.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
// don't want to confuse getOldestOutstandingSeqNum()
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();
}
}