From f7d725e34afdc3c8ca98630c559676c44e6eef3c Mon Sep 17 00:00:00 2001 From: Minglei Jin Date: Tue, 1 Jun 2021 20:48:09 +0800 Subject: [PATCH] [TD-3078]: fix arbitrator create time --- src/common/inc/tglobal.h | 1 + src/common/src/tglobal.c | 1 + src/inc/taosdef.h | 2 ++ src/mnode/src/mnodeDnode.c | 2 +- src/sync/src/syncMain.c | 7 ++++++- 5 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/common/inc/tglobal.h b/src/common/inc/tglobal.h index 1e66ce3f0c..07d614d5ef 100644 --- a/src/common/inc/tglobal.h +++ b/src/common/inc/tglobal.h @@ -39,6 +39,7 @@ extern int8_t tsEnableTelemetryReporting; extern char tsEmail[]; extern char tsArbitrator[]; extern int8_t tsArbOnline; +extern int64_t tsArbOnlineTimestamp; extern int32_t tsDnodeId; // common diff --git a/src/common/src/tglobal.c b/src/common/src/tglobal.c index e2237bbee6..ed91695569 100644 --- a/src/common/src/tglobal.c +++ b/src/common/src/tglobal.c @@ -42,6 +42,7 @@ int32_t tsNumOfMnodes = 3; int8_t tsEnableVnodeBak = 1; int8_t tsEnableTelemetryReporting = 1; int8_t tsArbOnline = 0; +int64_t tsArbOnlineTimestamp = TSDB_ARB_DUMMY_TIME; char tsEmail[TSDB_FQDN_LEN] = {0}; int32_t tsDnodeId = 0; diff --git a/src/inc/taosdef.h b/src/inc/taosdef.h index 024bc198df..672d460f2c 100644 --- a/src/inc/taosdef.h +++ b/src/inc/taosdef.h @@ -373,6 +373,8 @@ do { \ #define TSDB_MAX_WAL_SIZE (1024*1024*3) +#define TSDB_ARB_DUMMY_TIME 4765104000000 // 2121-01-01 00:00:00.000, :P + typedef enum { TAOS_QTYPE_RPC = 0, TAOS_QTYPE_FWD = 1, diff --git a/src/mnode/src/mnodeDnode.c b/src/mnode/src/mnodeDnode.c index b513da29f4..1acb91beab 100644 --- a/src/mnode/src/mnodeDnode.c +++ b/src/mnode/src/mnodeDnode.c @@ -941,7 +941,7 @@ static int32_t mnodeRetrieveDnodes(SShowObj *pShow, char *data, int32_t rows, vo cols++; pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; - *(int64_t *)pWrite = 0; + *(int64_t *)pWrite = tsArbOnlineTimestamp; cols++; pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; diff --git a/src/sync/src/syncMain.c b/src/sync/src/syncMain.c index e44b76d9b0..8ce37cbf78 100644 --- a/src/sync/src/syncMain.c +++ b/src/sync/src/syncMain.c @@ -1150,7 +1150,12 @@ static void syncSetupPeerConnection(SSyncPeer *pPeer) { pPeer->peerFd = connFd; pPeer->role = TAOS_SYNC_ROLE_UNSYNCED; pPeer->pConn = syncAllocateTcpConn(tsTcpPool, pPeer->rid, connFd); - if (pPeer->isArb) tsArbOnline = 1; + if (pPeer->isArb) { + tsArbOnline = 1; + if (tsArbOnlineTimestamp == TSDB_ARB_DUMMY_TIME) { + tsArbOnlineTimestamp = taosGetTimestampMs(); + } + } } else { sDebug("%s, failed to setup peer connection to server since %s, try later", pPeer->id, strerror(errno)); taosCloseSocket(connFd); -- GitLab