[fix](heartbeat) fix update BE last start time (#18962)
Sometimes the LastStartTime info in show backends result is unchanged even if BE restart. This PR fix it
This commit is contained in:
@ -26,6 +26,7 @@ import org.apache.doris.common.FeConstants;
|
||||
import org.apache.doris.common.io.Text;
|
||||
import org.apache.doris.common.io.Writable;
|
||||
import org.apache.doris.common.util.PrintableMap;
|
||||
import org.apache.doris.common.util.TimeUtils;
|
||||
import org.apache.doris.persist.gson.GsonUtils;
|
||||
import org.apache.doris.resource.Tag;
|
||||
import org.apache.doris.system.HeartbeatResponse.HbStatus;
|
||||
@ -622,6 +623,7 @@ public class Backend implements Writable {
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Backend [id=" + id + ", host=" + ip + ", heartbeatPort=" + heartbeatPort + ", alive=" + isAlive.get()
|
||||
+ ", lastStartTime=" + TimeUtils.longToTimeString(lastStartTime)
|
||||
+ ", tags: " + tagMap + "]";
|
||||
}
|
||||
|
||||
@ -696,12 +698,15 @@ public class Backend implements Writable {
|
||||
if (!isAlive.get()) {
|
||||
isChanged = true;
|
||||
this.lastStartTime = hbResponse.getBeStartTime();
|
||||
LOG.info("{} is alive, last start time: {}", this.toString(), hbResponse.getBeStartTime());
|
||||
LOG.info("{} is back to alive", this.toString());
|
||||
this.isAlive.set(true);
|
||||
} else if (this.lastStartTime <= 0) {
|
||||
this.lastStartTime = hbResponse.getBeStartTime();
|
||||
}
|
||||
|
||||
if (this.lastStartTime != hbResponse.getBeStartTime() && hbResponse.getBeStartTime() > 0) {
|
||||
LOG.info("{} update last start time to {}", this.toString(), hbResponse.getBeStartTime());
|
||||
this.lastStartTime = hbResponse.getBeStartTime();
|
||||
isChanged = true;
|
||||
}
|
||||
heartbeatErrMsg = "";
|
||||
this.heartbeatFailureCounter = 0;
|
||||
} else {
|
||||
|
||||
@ -41,19 +41,6 @@ public class BackendHbResponse extends HeartbeatResponse implements Writable {
|
||||
super(HeartbeatResponse.Type.BACKEND);
|
||||
}
|
||||
|
||||
public BackendHbResponse(long beId, int bePort, int httpPort, int brpcPort,
|
||||
long hbTime, long beStartTime, String version) {
|
||||
super(HeartbeatResponse.Type.BACKEND);
|
||||
this.beId = beId;
|
||||
this.status = HbStatus.OK;
|
||||
this.bePort = bePort;
|
||||
this.httpPort = httpPort;
|
||||
this.brpcPort = brpcPort;
|
||||
this.hbTime = hbTime;
|
||||
this.beStartTime = beStartTime;
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public BackendHbResponse(long beId, int bePort, int httpPort, int brpcPort,
|
||||
long hbTime, long beStartTime, String version, String nodeRole) {
|
||||
super(HeartbeatResponse.Type.BACKEND);
|
||||
|
||||
@ -250,9 +250,7 @@ public class HeartbeatMgr extends MasterDaemon {
|
||||
if (tBackendInfo.isSetVersion()) {
|
||||
version = tBackendInfo.getVersion();
|
||||
}
|
||||
long beStartTime = tBackendInfo.isSetBeStartTime()
|
||||
? tBackendInfo.getBeStartTime() : System.currentTimeMillis();
|
||||
// backend.updateOnce(bePort, httpPort, beRpcPort, brpcPort);
|
||||
long beStartTime = tBackendInfo.getBeStartTime();
|
||||
String nodeRole = Tag.VALUE_MIX;
|
||||
if (tBackendInfo.isSetBeNodeRole()) {
|
||||
nodeRole = tBackendInfo.getBeNodeRole();
|
||||
|
||||
Reference in New Issue
Block a user