HBASE-17049 Do not issue sync request when there are still entries in ringbuffer

This commit is contained in:
zhangduo 2017-11-24 21:26:30 +08:00
parent e946d9d841
commit 8688da9e9c
1 changed files with 10 additions and 6 deletions

View File

@ -463,12 +463,10 @@ public class AsyncFSWAL extends AbstractFSWAL<AsyncWriter> {
} }
return; return;
} }
// we have some unsynced data but haven't reached the batch size yet // reach here means that we have some unsynced data but haven't reached the batch size yet
if (!syncFutures.isEmpty() // but we will not issue a sync directly here even if there are sync requests because we may
&& syncFutures.last().getTxid() > highestProcessedAppendTxidAtLastSync) { // have some new data in the ringbuffer, so let's just return here and delay the decision of
// we have at least one sync request // whether to issue a sync in the caller method.
sync(writer);
}
} }
private void consume() { private void consume() {
@ -526,6 +524,12 @@ public class AsyncFSWAL extends AbstractFSWAL<AsyncWriter> {
// give up scheduling the consumer task. // give up scheduling the consumer task.
// 3. we set consumerScheduled to false and also give up scheduling consumer task. // 3. we set consumerScheduled to false and also give up scheduling consumer task.
if (waitingConsumePayloadsGatingSequence.get() == waitingConsumePayloads.getCursor()) { if (waitingConsumePayloadsGatingSequence.get() == waitingConsumePayloads.getCursor()) {
// we will give up consuming so if there are some unsynced data we need to issue a sync.
if (writer.getLength() > fileLengthAtLastSync && !syncFutures.isEmpty() &&
syncFutures.last().getTxid() > highestProcessedAppendTxidAtLastSync) {
// no new data in the ringbuffer and we have at least one sync request
sync(writer);
}
return; return;
} else { } else {
// maybe someone has grabbed this before us // maybe someone has grabbed this before us