HBASE-6318 SplitLogWorker exited due to ConcurrentModificationException

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1358330 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
jxiang 2012-07-06 18:18:38 +00:00
parent edfbb77dc5
commit 2c48f28239
1 changed files with 29 additions and 16 deletions

View File

@ -1293,7 +1293,7 @@ public class HLogSplitter {
boolean progress_failed = false; boolean progress_failed = false;
try { try {
for (int i = 0; i < logWriters.size(); i++) { for (int i = 0, n = logWriters.size(); i < n; i++) {
Future<Void> future = completionService.take(); Future<Void> future = completionService.take();
future.get(); future.get();
if (!progress_failed && !reportProgressIfIsDistributedLogSplitting()) { if (!progress_failed && !reportProgressIfIsDistributedLogSplitting()) {
@ -1327,18 +1327,36 @@ public class HLogSplitter {
if (thrown == null) { if (thrown == null) {
thrown = Lists.newArrayList(); thrown = Lists.newArrayList();
} }
for (WriterAndPath wap : logWriters.values()) { try {
try { for (WriterThread t : writerThreads) {
wap.w.close(); while (t.isAlive()) {
} catch (IOException ioe) { t.shouldStop = true;
LOG.error("Couldn't close log at " + wap.p, ioe); t.interrupt();
thrown.add(ioe); try {
continue; t.join(10);
} catch (InterruptedException e) {
IOException iie = new InterruptedIOException();
iie.initCause(e);
throw iie;
}
}
} }
LOG.info("Closed path " + wap.p + " (wrote " + wap.editsWritten } finally {
+ " edits in " + (wap.nanosSpent / 1000 / 1000) + "ms)"); synchronized (logWriters) {
for (WriterAndPath wap : logWriters.values()) {
try {
wap.w.close();
} catch (IOException ioe) {
LOG.error("Couldn't close log at " + wap.p, ioe);
thrown.add(ioe);
continue;
}
LOG.info("Closed path " + wap.p + " (wrote " + wap.editsWritten
+ " edits in " + (wap.nanosSpent / 1000 / 1000) + "ms)");
}
}
logWritersClosed = true;
} }
logWritersClosed = true;
} }
return thrown; return thrown;
} }
@ -1423,11 +1441,6 @@ public class HLogSplitter {
long editsWritten = 0; long editsWritten = 0;
/* Number of nanos spent writing to this log */ /* Number of nanos spent writing to this log */
long nanosSpent = 0; long nanosSpent = 0;
/* To check whether a close has already been tried on the
* writer
*/
boolean writerClosed = false;
WriterAndPath(final Path p, final Writer w) { WriterAndPath(final Path p, final Writer w) {
this.p = p; this.p = p;