-
Notifications
You must be signed in to change notification settings - Fork 504
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
Fix queryByRaft readIndex failed #1121
Conversation
ReadIndex request rejected because leader has not committed any log entry at its term Change-Id: I6f5c6fd3770da732caf0c6acd41f0441aa4acb55
Codecov Report
@@ Coverage Diff @@
## master #1121 +/- ##
============================================
+ Coverage 58.20% 65.86% +7.66%
- Complexity 4801 5652 +851
============================================
Files 354 354
Lines 28748 28836 +88
Branches 4056 4062 +6
============================================
+ Hits 16732 18994 +2262
+ Misses 10190 7964 -2226
- Partials 1826 1878 +52
Continue to review full report at Codecov.
|
this.node().node().readIndex(BytesUtil.EMPTY_BYTES, | ||
readIndexClosure); | ||
try { | ||
return closure.waitFinished(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename StoreClosure closure to future
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
other place used closure
query); | ||
closure.failure(status, new RaftException( | ||
"Failed to execute query '%s' because of leader " + | ||
"has not committed any log entry at its term", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move to "status.getRaftError() == RaftError.EAGAIN" block to line 247, just throw exception in else block
} | ||
throw new BackendException("Failed to query in the case of %s " + | ||
"retries times"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
collect last error message like "retries times with error: %s"
Change-Id: Ic39d81623efa89b3f35b794f7d183201348ab871
Change-Id: Ied4194a6e20c3365dede4df922d4eade9b4f7477
try { | ||
return closure.waitFinished(); | ||
} catch (Throwable t) { | ||
throw new BackendException("Failed to query", t); | ||
throw new BackendException("Failed to execute query", t); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move LOG.warn at line 231 here
@Override | ||
public void onHeartbeated(PeerId peer) { | ||
LOG.info("The node {} replicator has heartbeated", peer); | ||
started = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RaftNode.this.started
@@ -266,6 +300,7 @@ private boolean isWriteBufferOverflow(Status status) { | |||
@Override | |||
public void onDestroyed(PeerId peer) { | |||
LOG.warn("The node {} prepare to offline", peer); | |||
started = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
@@ -165,6 +175,24 @@ protected void waitLeaderElected() { | |||
this.group(), WAIT_LEADER_TIMEOUT); | |||
} | |||
|
|||
protected boolean waitHeartbeated() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename waitStarted
} | ||
try { | ||
Thread.sleep(heartbeatInterval); | ||
} catch (InterruptedException ex) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename ex to e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
address
try { | ||
Thread.sleep(heartbeatInterval); | ||
} catch (InterruptedException ex) { | ||
throw new BackendException("Waiting heartbeated is interrupted"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add cause param
StoreCommand command = new StoreCommand(StoreAction.QUERY); | ||
StoreClosure closure = new StoreClosure(command); | ||
RaftNode raftNode = this.node(); | ||
raftNode.node().readIndex(BytesUtil.EMPTY_BYTES, new ReadIndexClosure() { | ||
ReadIndexClosure readIndexClosure = new ReadIndexClosure() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename StoreClosure closure to future
RaftNode node = this.node(); | ||
node.waitLeaderElected(); | ||
if (node.node().isLeader()) { | ||
if (!node.waitHeartbeated()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a common waitFor(future, timeout) method
node.waitLeaderElected(); | ||
if (node.node().isLeader()) { | ||
if (!node.waitHeartbeated()) { | ||
throw new BackendException("Wait raft node heartbeat failed"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Failed to wait raft node heartbeat
e55434b
to
b42e21e
Compare
Change-Id: I689149d598ad902cc1ff5175d76557fd7b1491a0
|
||
@Override | ||
public void onStopFollowing(LeaderChangeContext ctx) { | ||
LOG.info("The node {} become to follower", this.node.nodeId()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
abdicated from follower
@@ -337,7 +335,7 @@ private HugeServerInfo serverInfo(Id server) { | |||
} | |||
|
|||
private HugeServerInfo removeSelfServerInfo() { | |||
if (this.initialized()) { | |||
if (this.graph.initialized()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should use this.call() if graph.initlalized() will open tx (ensure graph tx closed when graph close)
if (!node.waitHeartbeated()) { | ||
throw new BackendException("Wait raft node heartbeat failed"); | ||
} | ||
node.waitHeartbeated(-1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also define NO_TIMEOUT
@@ -105,6 +105,13 @@ public void open(String name) { | |||
this.provider.open(name); | |||
} | |||
|
|||
@Override | |||
public void waitStoreStarted() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check not null
Change-Id: I1218ec628755434be909f520fe9655ff2b01af85
Change-Id: I2a2e0cc6f0a2e65e23a1b9b2192dd50d8b28224c
return; | ||
} else { | ||
long beginTime = System.currentTimeMillis(); | ||
int internalTimeout = 3000; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
define const interval
} | ||
}; | ||
long beginTime = System.currentTimeMillis(); | ||
int internalTimeout = 3000; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
define
} | ||
try { | ||
Thread.sleep(heartbeatInterval); | ||
} catch (InterruptedException ex) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
address
Change-Id: I1f191a261979a9ffe232827d0c639642547ba5b7
ReadIndex request rejected because leader has not committed any log entry at its term
Change-Id: I6f5c6fd3770da732caf0c6acd41f0441aa4acb55