fix(sync): use fqdn instead of raftId
This commit is contained in:
parent
34c906a1e1
commit
b1093b4a79
|
@ -35,7 +35,7 @@
|
||||||
#include "syncVoteMgr.h"
|
#include "syncVoteMgr.h"
|
||||||
#include "tref.h"
|
#include "tref.h"
|
||||||
|
|
||||||
bool gRaftDetailLog = false;
|
bool gRaftDetailLog = true;
|
||||||
|
|
||||||
static int32_t tsNodeRefId = -1;
|
static int32_t tsNodeRefId = -1;
|
||||||
|
|
||||||
|
@ -216,25 +216,30 @@ int32_t syncReconfig(int64_t rid, const SSyncCfg* pNewCfg) {
|
||||||
|
|
||||||
bool IamInNew = false;
|
bool IamInNew = false;
|
||||||
for (int i = 0; i < pNewCfg->replicaNum; ++i) {
|
for (int i = 0; i < pNewCfg->replicaNum; ++i) {
|
||||||
SRaftId newId;
|
if (strcmp((pNewCfg->nodeInfo)[i].nodeFqdn, pSyncNode->myNodeInfo.nodeFqdn) == 0 &&
|
||||||
newId.addr = syncUtilAddr2U64((pNewCfg->nodeInfo)[i].nodeFqdn, (pNewCfg->nodeInfo)[i].nodePort);
|
(pNewCfg->nodeInfo)[i].nodePort == pSyncNode->myNodeInfo.nodePort) {
|
||||||
newId.vgId = pSyncNode->vgId;
|
|
||||||
|
|
||||||
sTrace("new[%d]: %lu, %d, my: %lu, %d", i, newId.addr, newId.vgId, pSyncNode->myRaftId.addr, pSyncNode->myRaftId.vgId);
|
|
||||||
|
|
||||||
if (syncUtilSameId(&(pSyncNode->myRaftId), &newId)) {
|
|
||||||
IamInNew = true;
|
IamInNew = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
// some problem in inet_addr
|
||||||
|
|
||||||
|
SRaftId newId = EMPTY_RAFT_ID;
|
||||||
|
newId.addr = syncUtilAddr2U64((pNewCfg->nodeInfo)[i].nodeFqdn, (pNewCfg->nodeInfo)[i].nodePort);
|
||||||
|
newId.vgId = pSyncNode->vgId;
|
||||||
|
|
||||||
|
if (syncUtilSameId(&(pSyncNode->myRaftId), &newId)) {
|
||||||
|
IamInNew = true;
|
||||||
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!IamInNew) {
|
if (!IamInNew) {
|
||||||
sError("sync reconfig error, not in new config");
|
sError("sync reconfig error, not in new config");
|
||||||
taosReleaseRef(tsNodeRefId, pSyncNode->rid);
|
taosReleaseRef(tsNodeRefId, pSyncNode->rid);
|
||||||
return TAOS_SYNC_NOT_IN_NEW_CONFIG;
|
return TAOS_SYNC_NOT_IN_NEW_CONFIG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char* newconfig = syncCfg2Str((SSyncCfg*)pNewCfg);
|
char* newconfig = syncCfg2Str((SSyncCfg*)pNewCfg);
|
||||||
if (gRaftDetailLog) {
|
if (gRaftDetailLog) {
|
||||||
sInfo("==syncReconfig== newconfig:%s", newconfig);
|
sInfo("==syncReconfig== newconfig:%s", newconfig);
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
add_executable(syncTest "")
|
add_executable(syncTest "")
|
||||||
|
add_executable(syncRaftIdCheck "")
|
||||||
add_executable(syncEnvTest "")
|
add_executable(syncEnvTest "")
|
||||||
add_executable(syncPingTimerTest "")
|
add_executable(syncPingTimerTest "")
|
||||||
add_executable(syncIOTickQTest "")
|
add_executable(syncIOTickQTest "")
|
||||||
|
@ -54,6 +55,10 @@ target_sources(syncTest
|
||||||
PRIVATE
|
PRIVATE
|
||||||
"syncTest.cpp"
|
"syncTest.cpp"
|
||||||
)
|
)
|
||||||
|
target_sources(syncRaftIdCheck
|
||||||
|
PRIVATE
|
||||||
|
"syncRaftIdCheck.cpp"
|
||||||
|
)
|
||||||
target_sources(syncEnvTest
|
target_sources(syncEnvTest
|
||||||
PRIVATE
|
PRIVATE
|
||||||
"syncEnvTest.cpp"
|
"syncEnvTest.cpp"
|
||||||
|
@ -257,6 +262,11 @@ target_include_directories(syncTest
|
||||||
"${TD_SOURCE_DIR}/include/libs/sync"
|
"${TD_SOURCE_DIR}/include/libs/sync"
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/../inc"
|
"${CMAKE_CURRENT_SOURCE_DIR}/../inc"
|
||||||
)
|
)
|
||||||
|
target_include_directories(syncRaftIdCheck
|
||||||
|
PUBLIC
|
||||||
|
"${TD_SOURCE_DIR}/include/libs/sync"
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/../inc"
|
||||||
|
)
|
||||||
target_include_directories(syncEnvTest
|
target_include_directories(syncEnvTest
|
||||||
PUBLIC
|
PUBLIC
|
||||||
"${TD_SOURCE_DIR}/include/libs/sync"
|
"${TD_SOURCE_DIR}/include/libs/sync"
|
||||||
|
@ -508,6 +518,10 @@ target_link_libraries(syncTest
|
||||||
sync
|
sync
|
||||||
gtest_main
|
gtest_main
|
||||||
)
|
)
|
||||||
|
target_link_libraries(syncRaftIdCheck
|
||||||
|
sync
|
||||||
|
gtest_main
|
||||||
|
)
|
||||||
target_link_libraries(syncEnvTest
|
target_link_libraries(syncEnvTest
|
||||||
sync
|
sync
|
||||||
gtest_main
|
gtest_main
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "syncIO.h"
|
||||||
|
#include "syncInt.h"
|
||||||
|
#include "syncUtil.h"
|
||||||
|
|
||||||
|
void usage(char* exe) {
|
||||||
|
printf("Usage: %s host port \n", exe);
|
||||||
|
printf("Usage: %s u64 \n", exe);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char** argv) {
|
||||||
|
if (argc == 2) {
|
||||||
|
uint64_t u64 = atoll(argv[1]);
|
||||||
|
char host[128];
|
||||||
|
uint16_t port;
|
||||||
|
syncUtilU642Addr(u64, host, sizeof(host), &port);
|
||||||
|
printf("%s:%d \n", host, port);
|
||||||
|
|
||||||
|
} else if (argc == 3) {
|
||||||
|
uint64_t u64;
|
||||||
|
char* host = argv[1];
|
||||||
|
uint16_t port = atoi(argv[2]);
|
||||||
|
syncUtilAddr2U64(host, port);
|
||||||
|
printf("%lu \n", u64);
|
||||||
|
} else {
|
||||||
|
usage(argv[0]);
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in New Issue