提交 5029e7da 编写于 作者: S Shengliang Guan

TD-2153

上级 a82d594a
...@@ -172,7 +172,7 @@ void syncCleanUp() { ...@@ -172,7 +172,7 @@ void syncCleanUp() {
int64_t syncStart(const SSyncInfo *pInfo) { int64_t syncStart(const SSyncInfo *pInfo) {
const SSyncCfg *pCfg = &pInfo->syncCfg; const SSyncCfg *pCfg = &pInfo->syncCfg;
SSyncNode *pNode = (SSyncNode *)calloc(sizeof(SSyncNode), 1); SSyncNode *pNode = calloc(sizeof(SSyncNode), 1);
if (pNode == NULL) { if (pNode == NULL) {
sError("no memory to allocate syncNode"); sError("no memory to allocate syncNode");
terrno = TAOS_SYSTEM_ERROR(errno); terrno = TAOS_SYSTEM_ERROR(errno);
...@@ -207,8 +207,8 @@ int64_t syncStart(const SSyncInfo *pInfo) { ...@@ -207,8 +207,8 @@ int64_t syncStart(const SSyncInfo *pInfo) {
const SNodeInfo *pNodeInfo = pCfg->nodeInfo + i; const SNodeInfo *pNodeInfo = pCfg->nodeInfo + i;
pNode->peerInfo[i] = syncAddPeer(pNode, pNodeInfo); pNode->peerInfo[i] = syncAddPeer(pNode, pNodeInfo);
if (pNode->peerInfo[i] == NULL) { if (pNode->peerInfo[i] == NULL) {
sError("vgId:%d, node:%d fqdn:%s port:%u is not configured, stop taosd", pNode->vgId, pNodeInfo->nodeId, pNodeInfo->nodeFqdn, sError("vgId:%d, node:%d fqdn:%s port:%u is not configured, stop taosd", pNode->vgId, pNodeInfo->nodeId,
pNodeInfo->nodePort); pNodeInfo->nodeFqdn, pNodeInfo->nodePort);
syncStop(pNode->rid); syncStop(pNode->rid);
exit(1); exit(1);
} }
...@@ -419,7 +419,7 @@ void syncRecover(int64_t rid) { ...@@ -419,7 +419,7 @@ void syncRecover(int64_t rid) {
pthread_mutex_lock(&(pNode->mutex)); pthread_mutex_lock(&(pNode->mutex));
for (int32_t i = 0; i < pNode->replica; ++i) { for (int32_t i = 0; i < pNode->replica; ++i) {
pPeer = (SSyncPeer *)pNode->peerInfo[i]; pPeer = pNode->peerInfo[i];
if (pPeer->peerFd >= 0) { if (pPeer->peerFd >= 0) {
syncRestartConnection(pPeer); syncRestartConnection(pPeer);
} }
......
...@@ -140,6 +140,7 @@ static int32_t syncRestoreWal(SSyncPeer *pPeer) { ...@@ -140,6 +140,7 @@ static int32_t syncRestoreWal(SSyncPeer *pPeer) {
if (buffer == NULL) return -1; if (buffer == NULL) return -1;
SWalHead *pHead = (SWalHead *)buffer; SWalHead *pHead = (SWalHead *)buffer;
uint64_t lastVer = 0;
while (1) { while (1) {
ret = taosReadMsg(pPeer->syncFd, pHead, sizeof(SWalHead)); ret = taosReadMsg(pPeer->syncFd, pHead, sizeof(SWalHead));
...@@ -153,7 +154,14 @@ static int32_t syncRestoreWal(SSyncPeer *pPeer) { ...@@ -153,7 +154,14 @@ static int32_t syncRestoreWal(SSyncPeer *pPeer) {
ret = taosReadMsg(pPeer->syncFd, pHead->cont, pHead->len); ret = taosReadMsg(pPeer->syncFd, pHead->cont, pHead->len);
if (ret < 0) break; if (ret < 0) break;
sDebug("%s, restore a record, qtype:wal hver:%" PRIu64, pPeer->id, pHead->version); sDebug("%s, restore a record, qtype:wal len:%d hver:%" PRIu64, pPeer->id, pHead->len, pHead->version);
if (lastVer != 0 && lastVer == pHead->version) {
sError("%s, failed to restore record, same hver:%" PRIu64 ", wal sync failed" PRIu64, pPeer->id, lastVer);
break;
}
lastVer = pHead->version;
(*pNode->writeToCache)(pNode->ahandle, pHead, TAOS_QTYPE_WAL, NULL); (*pNode->writeToCache)(pNode->ahandle, pHead, TAOS_QTYPE_WAL, NULL);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册