diff --git a/src/sync/src/syncMain.c b/src/sync/src/syncMain.c index db4bc08327c6fc9e6dc9372a391772d7b1723a72..d8803f46c4fab691cebdc3c3401cdbca7a844e70 100644 --- a/src/sync/src/syncMain.c +++ b/src/sync/src/syncMain.c @@ -715,8 +715,12 @@ static SSyncPeer *syncCheckMaster(SSyncNode *pNode) { if (onlineNum <= replica * 0.5) { if (nodeRole != TAOS_SYNC_ROLE_UNSYNCED) { - nodeRole = TAOS_SYNC_ROLE_UNSYNCED; - sInfo("vgId:%d, self change to unsynced state, online:%d replica:%d", pNode->vgId, onlineNum, replica); + if (nodeRole == TAOS_SYNC_ROLE_MASTER && onlineNum == replica * 0.5) { + sInfo("vgId:%d, self keep work as master, online:%d replica:%d", pNode->vgId, onlineNum, replica); + } else { + nodeRole = TAOS_SYNC_ROLE_UNSYNCED; + sInfo("vgId:%d, self change to unsynced state, online:%d replica:%d", pNode->vgId, onlineNum, replica); + } (*pNode->notifyRole)(pNode->vgId, nodeRole); } } else { diff --git a/tests/script/unique/dnode/offline3.sim b/tests/script/unique/dnode/offline3.sim index 3d84eb19e7e39346e758ae4f6b611aed75083369..93c75e3b13333d55aea7cb2417413a14a1c13e62 100644 --- a/tests/script/unique/dnode/offline3.sim +++ b/tests/script/unique/dnode/offline3.sim @@ -84,15 +84,15 @@ step2: return -1 endi +sql show vgroups; +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 + sql show dnodes print dnode1 $data4_1 print dnode2 $data4_2 print dnode3 $data4_3 print dnode4 $data4_4 -sql show vgroups; -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 - if $data4_1 != ready then goto step2 endi