HBASE-26435 The log rolling request maybe canceled immediately in LogRoller due to a race (#3832)
Co-authored-by: Rushabh Shah <shahrs87@apache.org> Signed-off-by: Reid Chan <reidchan@apache.org>
This commit is contained in:
parent
5b26932415
commit
f712a4ceb5
|
@ -143,7 +143,12 @@ public class LogRoller extends HasThread {
|
||||||
while (!server.isStopped()) {
|
while (!server.isStopped()) {
|
||||||
long now = EnvironmentEdgeManager.currentTime();
|
long now = EnvironmentEdgeManager.currentTime();
|
||||||
checkLowReplication(now);
|
checkLowReplication(now);
|
||||||
if (!rollLog.get()) {
|
boolean rollLogLocal;
|
||||||
|
synchronized (rollLog) {
|
||||||
|
rollLogLocal = rollLog.get();
|
||||||
|
rollLog.set(false);
|
||||||
|
}
|
||||||
|
if (!rollLogLocal) {
|
||||||
boolean periodic = false;
|
boolean periodic = false;
|
||||||
for (RollController controller : wals.values()) {
|
for (RollController controller : wals.values()) {
|
||||||
if (controller.needsPeriodicRoll(now)) {
|
if (controller.needsPeriodicRoll(now)) {
|
||||||
|
@ -154,11 +159,10 @@ public class LogRoller extends HasThread {
|
||||||
if (!periodic) {
|
if (!periodic) {
|
||||||
synchronized (rollLog) {
|
synchronized (rollLog) {
|
||||||
try {
|
try {
|
||||||
if (!rollLog.get()) {
|
rollLog.wait(this.threadWakeFrequency);
|
||||||
rollLog.wait(this.threadWakeFrequency);
|
|
||||||
}
|
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
// Fall through
|
// Fall through
|
||||||
|
LOG.info("LogRoller interrupted ", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
@ -199,11 +203,7 @@ public class LogRoller extends HasThread {
|
||||||
LOG.error(msg, ex);
|
LOG.error(msg, ex);
|
||||||
server.abort(msg, ex);
|
server.abort(msg, ex);
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
rollLock.unlock();
|
||||||
rollLog.set(false);
|
|
||||||
} finally {
|
|
||||||
rollLock.unlock();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LOG.info("LogRoller exiting.");
|
LOG.info("LogRoller exiting.");
|
||||||
|
@ -266,8 +266,9 @@ public class LogRoller extends HasThread {
|
||||||
|
|
||||||
public byte[][] rollWal(long now) throws IOException {
|
public byte[][] rollWal(long now) throws IOException {
|
||||||
this.lastRollTime = now;
|
this.lastRollTime = now;
|
||||||
byte[][] regionsToFlush = wal.rollWriter(true);
|
// reset the flag in front to avoid missing roll request before we return from rollWriter.
|
||||||
this.rollRequest.set(false);
|
this.rollRequest.set(false);
|
||||||
|
byte[][] regionsToFlush = wal.rollWriter(true);
|
||||||
return regionsToFlush;
|
return regionsToFlush;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue