Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ISSUE #278] Fix the bug because of enqueueing an unchecked commit task #279

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ private void checkResponseFuturesElapsed(final long endIndex) {

private void updateCommittedIndex(final long term, final long committedIndex) {
dLedgerStore.updateCommittedIndex(term, committedIndex);
this.fsmCaller.ifPresent(caller -> caller.onCommitted(committedIndex));
this.fsmCaller.ifPresent(caller -> caller.onCommitted(dLedgerStore.getCommittedIndex()));
}

/**
Expand Down Expand Up @@ -901,7 +901,7 @@ private void handleDoAppend(long writeIndex, PushEntryRequest request,
future.complete(buildResponse(request, DLedgerResponseCode.SUCCESS.getCode()));
updateCommittedIndex(request.getTerm(), request.getCommitIndex());
} catch (Throwable t) {
logger.error("[HandleDoWrite] writeIndex={}", writeIndex, t);
logger.error("[HandleDoAppend] writeIndex={}", writeIndex, t);
future.complete(buildResponse(request, DLedgerResponseCode.INCONSISTENT_STATE.getCode()));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ public StateMachine getStateMachine() {
}

public boolean onCommitted(final long committedIndex) {
if (committedIndex <= this.lastAppliedIndex.get()) return false;
final ApplyTask task = new ApplyTask();
task.type = TaskType.COMMITTED;
task.committedIndex = committedIndex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ public DLedgerEntry get(Long index) {
}
}

public Pair<Long, Integer> getEntryPosAndSize(Long index) {
private Pair<Long, Integer> getEntryPosAndSize(Long index) {
indexCheck(index);
SelectMmapBufferResult indexSbr = null;
try {
Expand All @@ -574,7 +574,7 @@ public Pair<Long, Integer> getEntryPosAndSize(Long index) {
}
}

public void indexCheck(Long index) {
private void indexCheck(Long index) {
PreConditions.check(index >= 0, DLedgerResponseCode.INDEX_OUT_OF_RANGE, "%d should gt 0", index);
PreConditions.check(index >= ledgerBeginIndex, DLedgerResponseCode.INDEX_LESS_THAN_LOCAL_BEGIN, "%d should be gt %d, ledgerBeginIndex may be revised", index, ledgerBeginIndex);
PreConditions.check(index <= ledgerEndIndex, DLedgerResponseCode.INDEX_OUT_OF_RANGE, "%d should between %d-%d", index, ledgerBeginIndex, ledgerEndIndex);
Expand Down