HBASE-1013 Add debugging around commit log cleanup
git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@719444 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
400e183da5
commit
05a11e7fcc
|
@ -133,6 +133,7 @@ Release 0.19.0 - Unreleased
|
|||
HBASE-675 Report correct server hosting a table split for assignment to
|
||||
for MR Jobs
|
||||
HBASE-927 We don't recover if HRS hosting -ROOT-/.META. goes down
|
||||
HBASE-1013 Add debugging around commit log cleanup
|
||||
|
||||
NEW FEATURES
|
||||
HBASE-875 Use MurmurHash instead of JenkinsHash [in bloomfilters]
|
||||
|
|
|
@ -244,35 +244,17 @@ public class HLog implements HConstants, Syncable {
|
|||
return;
|
||||
}
|
||||
synchronized (updateLock) {
|
||||
if (this.writer != null) {
|
||||
// Close the current writer, get a new one.
|
||||
try {
|
||||
this.writer.close();
|
||||
} catch (IOException e) {
|
||||
// Failed close of log file. Means we're losing edits. For now,
|
||||
// shut ourselves down to minimize loss. Alternative is to try and
|
||||
// keep going. See HBASE-930.
|
||||
FailedLogCloseException flce =
|
||||
new FailedLogCloseException("#" + this.filenum);
|
||||
flce.initCause(e);
|
||||
throw e;
|
||||
}
|
||||
Path p = computeFilename(old_filenum);
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("Closing current log writer " + FSUtils.getPath(p));
|
||||
}
|
||||
if (filenum > 0) {
|
||||
synchronized (this.sequenceLock) {
|
||||
this.outputfiles.put(Long.valueOf(this.logSeqNum - 1), p);
|
||||
}
|
||||
}
|
||||
}
|
||||
old_filenum = filenum;
|
||||
filenum = System.currentTimeMillis();
|
||||
Path newPath = computeFilename(filenum);
|
||||
// Clean up current writer.
|
||||
Path oldFile = cleanupCurrentWriter();
|
||||
// Create a new one.
|
||||
this.old_filenum = this.filenum;
|
||||
this.filenum = System.currentTimeMillis();
|
||||
Path newPath = computeFilename(this.filenum);
|
||||
this.writer = SequenceFile.createWriter(this.fs, this.conf, newPath,
|
||||
HLogKey.class, HLogEdit.class, getCompressionType(this.conf));
|
||||
LOG.info("New log writer created at " + FSUtils.getPath(newPath));
|
||||
LOG.info((oldFile != null?
|
||||
"Closed " + oldFile + ", entries=" + this.numEntries + ". ": "") +
|
||||
"New log writer: " + FSUtils.getPath(newPath));
|
||||
|
||||
// Can we delete any of the old log files?
|
||||
if (this.outputfiles.size() > 0) {
|
||||
|
@ -286,6 +268,22 @@ public class HLog implements HConstants, Syncable {
|
|||
}
|
||||
this.outputfiles.clear();
|
||||
} else {
|
||||
cleanOldLogs();
|
||||
}
|
||||
}
|
||||
this.numEntries = 0;
|
||||
updateLock.notifyAll();
|
||||
}
|
||||
} finally {
|
||||
this.cacheFlushLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Clean up old commit logs.
|
||||
* @throws IOException
|
||||
*/
|
||||
private void cleanOldLogs() throws IOException {
|
||||
// Get oldest edit/sequence id. If logs are older than this id,
|
||||
// then safe to remove.
|
||||
Long oldestOutstandingSeqNum =
|
||||
|
@ -305,13 +303,10 @@ public class HLog implements HConstants, Syncable {
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (LOG.isDebugEnabled() && sequenceNumbers.size() > 0) {
|
||||
LOG.debug("Found " + sequenceNumbers.size() +
|
||||
" logs to remove " +
|
||||
"using oldest outstanding seqnum of " +
|
||||
oldestOutstandingSeqNum + " from region " +
|
||||
Bytes.toString(oldestRegion));
|
||||
}
|
||||
LOG.debug("Found " + sequenceNumbers.size() + " logs to remove " +
|
||||
" out of total " + this.outputfiles.size() + "; " +
|
||||
"oldest outstanding seqnum is " + oldestOutstandingSeqNum +
|
||||
" from region " + Bytes.toString(oldestRegion));
|
||||
}
|
||||
if (sequenceNumbers.size() > 0) {
|
||||
for (Long seq : sequenceNumbers) {
|
||||
|
@ -319,14 +314,37 @@ public class HLog implements HConstants, Syncable {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Cleans up current writer closing and adding to outputfiles.
|
||||
* Presumes we're operating inside an updateLock scope.
|
||||
* @return Path to current writer or null if none.
|
||||
* @throws IOException
|
||||
*/
|
||||
private Path cleanupCurrentWriter() throws IOException {
|
||||
Path oldFile = null;
|
||||
if (this.writer != null) {
|
||||
// Close the current writer, get a new one.
|
||||
try {
|
||||
this.writer.close();
|
||||
} catch (IOException e) {
|
||||
// Failed close of log file. Means we're losing edits. For now,
|
||||
// shut ourselves down to minimize loss. Alternative is to try and
|
||||
// keep going. See HBASE-930.
|
||||
FailedLogCloseException flce =
|
||||
new FailedLogCloseException("#" + this.filenum);
|
||||
flce.initCause(e);
|
||||
throw e;
|
||||
}
|
||||
this.numEntries = 0;
|
||||
updateLock.notifyAll();
|
||||
oldFile = computeFilename(old_filenum);
|
||||
if (filenum > 0) {
|
||||
synchronized (this.sequenceLock) {
|
||||
this.outputfiles.put(Long.valueOf(this.logSeqNum - 1), oldFile);
|
||||
}
|
||||
} finally {
|
||||
this.cacheFlushLock.unlock();
|
||||
}
|
||||
}
|
||||
return oldFile;
|
||||
}
|
||||
|
||||
private void deleteLogFile(final Path p, final Long seqno) throws IOException {
|
||||
LOG.info("removing old log file " + FSUtils.getPath(p) +
|
||||
|
@ -626,8 +644,9 @@ public class HLog implements HConstants, Syncable {
|
|||
}
|
||||
|
||||
/**
|
||||
* Split up a bunch of log files, that are no longer being written to, into
|
||||
* new files, one per region. Delete the old log files when finished.
|
||||
* Split up a bunch of regionserver commit log files that are no longer
|
||||
* being written to, into new files, one per region for region to replay on
|
||||
* startup. Delete the old log files when finished.
|
||||
*
|
||||
* @param rootDir qualified root directory of the HBase instance
|
||||
* @param srcDir Directory of log files to split: e.g.
|
||||
|
@ -636,19 +655,42 @@ public class HLog implements HConstants, Syncable {
|
|||
* @param conf HBaseConfiguration
|
||||
* @throws IOException
|
||||
*/
|
||||
public static void splitLog(Path rootDir, Path srcDir, FileSystem fs,
|
||||
Configuration conf) throws IOException {
|
||||
public static void splitLog(final Path rootDir, final Path srcDir,
|
||||
final FileSystem fs, final Configuration conf)
|
||||
throws IOException {
|
||||
if (!fs.exists(srcDir)) {
|
||||
// Nothing to do
|
||||
return;
|
||||
}
|
||||
FileStatus logfiles[] = fs.listStatus(srcDir);
|
||||
FileStatus [] logfiles = fs.listStatus(srcDir);
|
||||
if (logfiles == null || logfiles.length == 0) {
|
||||
// Nothing to do
|
||||
return;
|
||||
}
|
||||
LOG.info("splitting " + logfiles.length + " log(s) in " +
|
||||
LOG.info("Splitting " + logfiles.length + " log(s) in " +
|
||||
srcDir.toString());
|
||||
splitLog(rootDir, logfiles, fs, conf);
|
||||
try {
|
||||
fs.delete(srcDir, true);
|
||||
} catch (IOException e) {
|
||||
e = RemoteExceptionHandler.checkIOException(e);
|
||||
IOException io = new IOException("Cannot delete: " + srcDir);
|
||||
io.initCause(e);
|
||||
throw io;
|
||||
}
|
||||
LOG.info("log file splitting completed for " + srcDir.toString());
|
||||
}
|
||||
|
||||
/*
|
||||
* @param rootDir
|
||||
* @param logfiles
|
||||
* @param fs
|
||||
* @param conf
|
||||
* @throws IOException
|
||||
*/
|
||||
private static void splitLog(final Path rootDir, final FileStatus [] logfiles,
|
||||
final FileSystem fs, final Configuration conf)
|
||||
throws IOException {
|
||||
Map<byte [], SequenceFile.Writer> logWriters =
|
||||
new TreeMap<byte [], SequenceFile.Writer>(Bytes.BYTES_COMPARATOR);
|
||||
try {
|
||||
|
@ -743,16 +785,6 @@ public class HLog implements HConstants, Syncable {
|
|||
w.close();
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
fs.delete(srcDir, true);
|
||||
} catch (IOException e) {
|
||||
e = RemoteExceptionHandler.checkIOException(e);
|
||||
IOException io = new IOException("Cannot delete: " + srcDir);
|
||||
io.initCause(e);
|
||||
throw io;
|
||||
}
|
||||
LOG.info("log file splitting completed for " + srcDir.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -908,7 +908,7 @@ public class HStore implements HConstants {
|
|||
this.compactionDir, this.info, family.getName(), -1L, null);
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("Started compaction of " + rdrs.size() + " file(s)" +
|
||||
(references? "(hasReferences=true)": " ") + " into " +
|
||||
(references? ", hasReferences=true,": " ") + " into " +
|
||||
FSUtils.getPath(compactedOutputFile.getMapFilePath()));
|
||||
}
|
||||
MapFile.Writer writer = compactedOutputFile.getWriter(this.fs,
|
||||
|
|
|
@ -61,8 +61,6 @@ class LogRoller extends Thread implements LogRollListener {
|
|||
}
|
||||
rollLock.lock(); // Don't interrupt us. We're working
|
||||
try {
|
||||
LOG.info("Rolling hlog. Number of entries: " +
|
||||
server.getLog().getNumEntries());
|
||||
server.getLog().rollWriter();
|
||||
} catch (FailedLogCloseException e) {
|
||||
LOG.fatal("Forcing server shutdown", e);
|
||||
|
|
Loading…
Reference in New Issue