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

[BugFix] When the status of HeartBeat is not ok, it also need to be synced to follower #8265

Merged
merged 4 commits into from Jul 21, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -82,10 +82,15 @@ public boolean handleHbResponse(BrokerHbResponse hbResponse) {
} else {
if (isAlive) {
isAlive = false;
isChanged = true;
}
heartbeatErrMsg = hbResponse.getMsg() == null ? "Unknown error" : hbResponse.getMsg();
}
// When the master receives an error heartbeat info which status not ok,
// this heartbeat info also need to be synced to follower.
// Since the failed heartbeat info also modifies fe's memory, (this.heartbeatRetryTimes++;)
// if this heartbeat is not synchronized to the follower,
// that will cause the Follower and master’s memory to be inconsistent
isChanged = true;
gengjun-git marked this conversation as resolved.
Show resolved Hide resolved
}

return isChanged;
Expand Down
Expand Up @@ -401,13 +401,17 @@ public boolean handleHbResponse(BackendHbResponse hbResponse) {
this.heartbeatRetryTimes++;
} else {
if (isAlive.compareAndSet(true, false)) {
isChanged = true;
LOG.info("{} is dead,", this.toString());
}

heartbeatErrMsg = hbResponse.getMsg() == null ? "Unknown error" : hbResponse.getMsg();
lastMissingHeartbeatTime = System.currentTimeMillis();
}
// When the master receives an error heartbeat info which status not ok,
// this heartbeat info also need to be synced to follower.
// Since the failed heartbeat info also modifies fe's memory, (this.heartbeatRetryTimes++;)
// if this heartbeat is not synchronized to the follower,
// that will cause the Follower and master’s memory to be inconsistent
isChanged = true;
}

return isChanged;
Expand Down
Expand Up @@ -147,10 +147,15 @@ public boolean handleHbResponse(FrontendHbResponse hbResponse, boolean isReplay)
} else {
if (isAlive) {
isAlive = false;
isChanged = true;
}
heartbeatErrMsg = hbResponse.getMsg() == null ? "Unknown error" : hbResponse.getMsg();
}
// When the master receives an error heartbeat info which status not ok,
// this heartbeat info also need to be synced to follower.
// Since the failed heartbeat info also modifies fe's memory, (this.heartbeatRetryTimes++;)
// if this heartbeat is not synchronized to the follower,
// that will cause the Follower and master’s memory to be inconsistent
isChanged = true;
}
return isChanged;
}
Expand Down
21 changes: 21 additions & 0 deletions fe/fe-core/src/test/java/com/starrocks/system/ComputeNodeTest.java
@@ -0,0 +1,21 @@
// This file is licensed under the Elastic License 2.0. Copyright 2021-present, StarRocks Limited.
package com.starrocks.system;

import org.junit.Assert;
import org.junit.Test;

import com.starrocks.system.HeartbeatResponse.HbStatus;

public class ComputeNodeTest {

@Test
public void testHbStatusBadNeedSync() {

BackendHbResponse hbResponse = new BackendHbResponse();
hbResponse.status = HbStatus.BAD;

ComputeNode node = new ComputeNode();
boolean needSync = node.handleHbResponse(hbResponse);
Assert.assertTrue(needSync);
}
}
Expand Up @@ -16,4 +16,13 @@ public void testFeUpdate() {
Assert.assertEquals("modifiedHost", fe.getHost());
Assert.assertTrue(fe.getEditLogPort() == 2110);
}

@Test
public void testHbStatusBadNeedSync() {
FrontendHbResponse hbResponse = new FrontendHbResponse("BAD", "");

Frontend fe = new Frontend(FrontendNodeType.FOLLOWER, "name", "testHost", 1110);
boolean needSync = fe.handleHbResponse(hbResponse, true);
Assert.assertTrue(needSync);
}
}