vldpyatkov commented on code in PR #1815:
URL: https://github.com/apache/ignite-3/pull/1815#discussion_r1149221212
##########
modules/raft/src/main/java/org/apache/ignite/raft/jraft/core/NodeImpl.java:
##########
@@ -1116,38 +1106,53 @@ public void onApplied( long lastAppliedLogIndex) {
return false;
}
- // set state to follower
- this.state = State.STATE_FOLLOWER;
+ logApplyComplition.whenComplete((committedIdx, err) -> {
+ if (err != null) {
+ LOG.error("Fail to apply committed updates.", err);
+ }
- if (LOG.isInfoEnabled()) {
- LOG.info("Node {} init, term={}, lastLogId={}, conf={},
oldConf={}.", getNodeId(), this.currTerm,
- this.logManager.getLastLogId(false), this.conf.getConf(),
this.conf.getOldConf());
- }
+ // set state to follower
+ this.state = State.STATE_FOLLOWER;
- if (this.snapshotExecutor != null &&
this.options.getSnapshotIntervalSecs() > 0) {
- LOG.debug("Node {} start snapshot timer, term={}.", getNodeId(),
this.currTerm);
- this.snapshotTimer.start();
- }
+ if (LOG.isInfoEnabled()) {
+ LOG.info("Node {} init, term={}, lastLogId={}, conf={},
oldConf={}.", getNodeId(), this.currTerm,
+ this.logManager.getLastLogId(false), this.conf.getConf(),
this.conf.getOldConf());
+ }
- if (!this.conf.isEmpty()) {
- stepDown(this.currTerm, false, new Status());
- }
+ if (this.snapshotExecutor != null &&
this.options.getSnapshotIntervalSecs() > 0) {
+ LOG.debug("Node {} start snapshot timer, term={}.",
getNodeId(), this.currTerm);
+ this.snapshotTimer.start();
+ }
- // Now the raft node is started , have to acquire the writeLock to
avoid race
- // conditions
- this.writeLock.lock();
- if (this.conf.isStable() && this.conf.getConf().size() == 1 &&
this.conf.getConf().contains(this.serverId)) {
- // The group contains only this server which must be the LEADER,
trigger
- // the timer immediately.
- electSelf();
- }
- else {
- this.writeLock.unlock();
- }
+ if (!this.conf.isEmpty()) {
+ stepDown(this.currTerm, false, new Status());
+ }
+
+ // Now the raft node is started , have to acquire the writeLock to
avoid race
+ // conditions
+ this.writeLock.lock();
+ if (this.conf.isStable() && this.conf.getConf().size() == 1 &&
this.conf.getConf().contains(this.serverId)) {
+ // The group contains only this server which must be the
LEADER, trigger
+ // the timer immediately.
+ electSelf();
+ }
+ else {
+ this.writeLock.unlock();
+ }
+
+ applyCommittedFuture.complete(commitIdx);
Review Comment:
Currently, we complete the future (without exception) event if an exception
happens during applying and log error.
Hence, we cannot get stuck on waiting it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]