提交 31273a89 编写于 作者: S Shengliang Guan

taosd may crash while run m2.sim

上级 871e24dc
......@@ -741,11 +741,14 @@ static SSyncPeer *syncCheckMaster(SSyncNode *pNode) {
if (pTemp->role != TAOS_SYNC_ROLE_MASTER) continue;
if (masterIndex < 0) {
masterIndex = index;
sDebug("vgId:%d, peer:%s is master, index:%d", pNode->vgId, pTemp->id, index);
} else { // multiple masters, it shall not happen
if (masterIndex == pNode->selfIndex) {
sError("%s, peer is master, work as slave instead", pTemp->id);
nodeRole = TAOS_SYNC_ROLE_SLAVE;
(*pNode->notifyRoleFp)(pNode->vgId, nodeRole);
} else {
sError("vgId:%d, peer:%s is master too, masterIndex:%d index:%d", pNode->vgId, pTemp->id, masterIndex, index);
}
}
}
......@@ -833,7 +836,7 @@ static void syncCheckRole(SSyncPeer *pPeer, SPeerStatus* peersStatus, int8_t new
}
if (oldPeerRole != newPeerRole || nodeRole != oldSelfRole) {
sDebug("vgId:%d, roles changed, broadcast status", pNode->vgId);
sDebug("vgId:%d, roles changed, broadcast status, replica:%d", pNode->vgId, pNode->replica);
syncBroadcastStatus(pNode);
}
......@@ -860,8 +863,12 @@ static void syncRestartPeer(SSyncPeer *pPeer) {
void syncRestartConnection(SSyncPeer *pPeer) {
if (pPeer->ip == 0) return;
if (syncAcquirePeer(pPeer->rid) == NULL) return;
syncRestartPeer(pPeer);
syncCheckRole(pPeer, NULL, TAOS_SYNC_ROLE_OFFLINE);
syncReleasePeer(pPeer);
}
static void syncProcessSyncRequest(char *msg, SSyncPeer *pPeer) {
......
......@@ -131,6 +131,11 @@ static int32_t syncProcessBufferedFwd(SSyncPeer *pPeer) {
SRecvBuffer *pRecv = pNode->pRecv;
int32_t forwards = 0;
if (pRecv == NULL) {
sError("%s, recv buffer is null, restart connect", pPeer->id);
return -1;
}
sDebug("%s, number of buffered forwards:%d", pPeer->id, pRecv->forwards);
char *offset = pRecv->buffer;
......@@ -179,6 +184,7 @@ int32_t syncSaveIntoBuffer(SSyncPeer *pPeer, SWalHead *pHead) {
static void syncCloseRecvBuffer(SSyncNode *pNode) {
if (pNode->pRecv) {
sDebug("vgId:%d, recv buffer:%p is freed", pNode->vgId, pNode->pRecv);
tfree(pNode->pRecv->buffer);
}
......@@ -203,6 +209,7 @@ static int32_t syncOpenRecvBuffer(SSyncNode *pNode) {
pNode->pRecv = pRecv;
sDebug("vgId:%d, recv buffer:%p is created", pNode->vgId, pNode->pRecv);
return 0;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册