HBASE-900 Regionserver memory leak causing OOME during relatively modest bulk importing; part 3

git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@727154 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2008-12-16 21:11:54 +00:00
parent 369300f015
commit 053635c1fa
2 changed files with 11 additions and 10 deletions

View File

@ -839,13 +839,14 @@ public class HRegion implements HConstants {
long sequenceId = -1L;
long completeSequenceId = -1L;
this.updatesLock.writeLock().lock();
// Get current size of memcaches.
final long currentMemcacheSize = this.memcacheSize.get();
try {
for (HStore s: stores.values()) {
s.snapshot();
}
sequenceId = log.startCacheFlush();
completeSequenceId = this.getCompleteCacheFlushSequenceId(sequenceId);
this.memcacheSize.set(0);
} finally {
this.updatesLock.writeLock().unlock();
}
@ -865,6 +866,8 @@ public class HRegion implements HConstants {
compactionRequested = true;
}
}
// Set down the memcache size by amount of flush.
this.memcacheSize.addAndGet(-currentMemcacheSize);
} catch (Throwable t) {
// An exception here means that the snapshot was not persisted.
// The hlog needs to be replayed so its content is restored to memcache.
@ -896,12 +899,12 @@ public class HRegion implements HConstants {
}
if (LOG.isDebugEnabled()) {
String timeTaken = StringUtils.formatTimeDiff(System.currentTimeMillis(),
startTime);
LOG.debug("Finished memcache flush for region " + this +
" in " +
(System.currentTimeMillis() - startTime) + "ms, sequence id=" +
sequenceId + ", compaction requested=" + compactionRequested);
long now = System.currentTimeMillis();
String timeTaken = StringUtils.formatTimeDiff(now, startTime);
LOG.debug("Finished memcache flush of ~" +
StringUtils.humanReadableInt(currentMemcacheSize) + " for region " +
this + " in " + (now - startTime) + "ms, sequence id=" + sequenceId +
", compaction requested=" + compactionRequested);
if (!regionInfo.isMetaRegion()) {
this.historian.addRegionFlush(regionInfo, timeTaken);
}
@ -1274,8 +1277,6 @@ public class HRegion implements HConstants {
/*
* Check if resources to support an update.
*
* For now, just checks memcache saturation.
*
* Here we synchronize on HRegion, a broad scoped lock. Its appropriate
* given we're figuring in here whether this region is able to take on
* writes. This is only method with a synchronize (at time of writing),

View File

@ -847,7 +847,7 @@ public class HRegionServer implements HConstants, HRegionInterface, Runnable {
for (Map.Entry<Integer, HRegion> e: this.onlineRegions.entrySet()) {
HRegion r = e.getValue();
memcacheSize += r.memcacheSize.get();
synchronized(r.stores) {
synchronized (r.stores) {
stores += r.stores.size();
for(Map.Entry<Integer, HStore> ee: r.stores.entrySet()) {
HStore store = ee.getValue();