From a5d0e01ab445b3e3e83f3e7a7f181c41086b6c76 Mon Sep 17 00:00:00 2001 From: slguan Date: Wed, 15 Apr 2020 20:18:15 +0800 Subject: [PATCH] fix error in sdb --- src/dnode/src/dnodeMClient.c | 21 ++++++++++++--------- src/dnode/src/dnodeMain.c | 2 +- src/inc/mpeer.h | 1 + src/mnode/src/mgmtDnode.c | 1 + src/mnode/src/mgmtMnode.c | 1 + src/mnode/src/mgmtSdb.c | 8 ++++++++ src/mnode/src/mgmtUser.c | 12 +++++++----- src/plugins/http/src/httpSystem.c | 2 +- 8 files changed, 32 insertions(+), 16 deletions(-) diff --git a/src/dnode/src/dnodeMClient.c b/src/dnode/src/dnodeMClient.c index 42eca2152b..d791ad0f01 100644 --- a/src/dnode/src/dnodeMClient.c +++ b/src/dnode/src/dnodeMClient.c @@ -28,6 +28,7 @@ #include "dnodeModule.h" #include "dnodeMgmt.h" #include "vnode.h" +#include "mpeer.h" #define MPEER_CONTENT_LEN 2000 @@ -148,6 +149,15 @@ static void dnodeProcessStatusRsp(SRpcMsg *pMsg) { return; } + SDnodeState *pState = &pStatusRsp->dnodeState; + pState->numOfVnodes = htonl(pState->numOfVnodes); + pState->moduleStatus = htonl(pState->moduleStatus); + pState->createdTime = htonl(pState->createdTime); + pState->dnodeId = htonl(pState->dnodeId); + + dnodeProcessModuleStatus(pState->moduleStatus); + dnodeUpdateDnodeInfo(pState->dnodeId); + SRpcIpSet mgmtIpSet = {0}; mgmtIpSet.inUse = mpeers->inUse; mgmtIpSet.numOfIps = mpeers->nodeNum; @@ -167,20 +177,13 @@ static void dnodeProcessStatusRsp(SRpcMsg *pMsg) { tsMnodeInfos.nodeInfos[i].nodePort = htons(mpeers->nodeInfos[i].nodePort); strcpy(tsMnodeInfos.nodeInfos[i].nodeName, mpeers->nodeInfos[i].nodeName); dPrint("mnode:%d, ip:%s:%u name:%s", tsMnodeInfos.nodeInfos[i].nodeId, - taosIpStr(tsMnodeInfos.nodeInfos[i].nodeId), tsMnodeInfos.nodeInfos[i].nodePort, + taosIpStr(tsMnodeInfos.nodeInfos[i].nodeIp), tsMnodeInfos.nodeInfos[i].nodePort, tsMnodeInfos.nodeInfos[i].nodeName); } dnodeSaveMnodeIpList(); + mpeerUpdateSync(); } - SDnodeState *pState = &pStatusRsp->dnodeState; - pState->numOfVnodes = htonl(pState->numOfVnodes); - pState->moduleStatus = htonl(pState->moduleStatus); - pState->createdTime = htonl(pState->createdTime); - pState->dnodeId = htonl(pState->dnodeId); - - dnodeProcessModuleStatus(pState->moduleStatus); - dnodeUpdateDnodeInfo(pState->dnodeId); taosTmrReset(dnodeSendStatusMsg, tsStatusInterval * 1000, NULL, tsDnodeTmr, &tsStatusTimer); } diff --git a/src/dnode/src/dnodeMain.c b/src/dnode/src/dnodeMain.c index 01e2c4dfcc..64d1ad4048 100644 --- a/src/dnode/src/dnodeMain.c +++ b/src/dnode/src/dnodeMain.c @@ -159,10 +159,10 @@ static int32_t dnodeInitSystem() { dPrint("starting to initialize TDengine ..."); if (dnodeInitStorage() != 0) return -1; - if (dnodeInitModules() != 0) return -1; if (dnodeInitRead() != 0) return -1; if (dnodeInitWrite() != 0) return -1; if (dnodeInitMClient() != 0) return -1; + if (dnodeInitModules() != 0) return -1; if (dnodeInitMnode() != 0) return -1; if (dnodeInitMgmt() != 0) return -1; if (dnodeInitShell() != 0) return -1; diff --git a/src/inc/mpeer.h b/src/inc/mpeer.h index e7abf09321..ba1b7d32cf 100644 --- a/src/inc/mpeer.h +++ b/src/inc/mpeer.h @@ -50,6 +50,7 @@ void mpeerGetPublicIpList(SRpcIpSet *ipSet); void mpeerGetMpeerInfos(void *mpeers); int32_t mpeerForwardReqToPeer(void *pHead); +void mpeerUpdateSync(); #ifdef __cplusplus } diff --git a/src/mnode/src/mgmtDnode.c b/src/mnode/src/mgmtDnode.c index 196b8c1026..d13d37586a 100644 --- a/src/mnode/src/mgmtDnode.c +++ b/src/mnode/src/mgmtDnode.c @@ -77,6 +77,7 @@ void * clusterGetDnode(int32_t dnodeId) { return dnodeId == 1 ? &tsDnodeObj : N void * clusterGetDnodeByIp(uint32_t ip) { return &tsDnodeObj; } void clusterReleaseDnode(struct _dnode_obj *pDnode) {} void clusterUpdateDnode(struct _dnode_obj *pDnode) {} +void clusterMonitorDnodeModule() {} #endif diff --git a/src/mnode/src/mgmtMnode.c b/src/mnode/src/mgmtMnode.c index ca18d6bdba..e2edb201b9 100644 --- a/src/mnode/src/mgmtMnode.c +++ b/src/mnode/src/mgmtMnode.c @@ -48,6 +48,7 @@ void * mpeerGetMnode(int32_t mnodeId) { return &tsMnodeObj; } int32_t mpeerGetMnodesNum() { return 1; } void mpeerReleaseMnode(struct _mnode_obj *pMnode) {} bool mpeerIsMaster() { return tsMnodeObj.role == TAOS_SYNC_ROLE_MASTER; } +void mpeerUpdateSync() {} void *mpeerGetNextMnode(void *pNode, SMnodeObj **pMnode) { if (*pMnode == NULL) { diff --git a/src/mnode/src/mgmtSdb.c b/src/mnode/src/mgmtSdb.c index 2cec20c653..6bc3c20d18 100644 --- a/src/mnode/src/mgmtSdb.c +++ b/src/mnode/src/mgmtSdb.c @@ -130,6 +130,9 @@ int32_t sdbInit() { } sdbTrace("sdb is initialized, version:%d totalRows:%d numOfTables:%d", tsSdbObj->version, totalRows, numOfTables); + + mpeerUpdateSync(); + return TSDB_CODE_SUCCESS; } @@ -215,6 +218,11 @@ static int32_t sdbInsertLocal(SSdbTable *pTable, SSdbOperDesc *pOper) { (*sdbAddIndexFp[pTable->keyType])(pTable->iHandle, pOper->pObj, &rowMeta); sdbIncRef(pTable, pOper->pObj); pTable->numOfRows++; + + if (pTable->keyType == SDB_KEY_AUTO) { + pTable->autoIndex = MAX(pTable->autoIndex, *((uint32_t *)pOper->pObj)); + } + pthread_mutex_unlock(&pTable->mutex); sdbTrace("table:%s, insert record:%s, numOfRows:%d", pTable->tableName, sdbGetkeyStr(pTable, pOper->pObj), diff --git a/src/mnode/src/mgmtUser.c b/src/mnode/src/mgmtUser.c index ef01faf6ba..7fa1a13bfd 100644 --- a/src/mnode/src/mgmtUser.c +++ b/src/mnode/src/mgmtUser.c @@ -85,11 +85,13 @@ static int32_t mgmtUserActionDecode(SSdbOperDesc *pOper) { } static int32_t mgmtUserActionRestored() { - SAcctObj *pAcct = acctGetAcct("root"); - mgmtCreateUser(pAcct, "root", "taosdata"); - mgmtCreateUser(pAcct, "monitor", tsInternalPass); - mgmtCreateUser(pAcct, "_root", tsInternalPass); - acctReleaseAcct(pAcct); + if (strcmp(tsMasterIp, tsPrivateIp) == 0) { + SAcctObj *pAcct = acctGetAcct("root"); + mgmtCreateUser(pAcct, "root", "taosdata"); + mgmtCreateUser(pAcct, "monitor", tsInternalPass); + mgmtCreateUser(pAcct, "_root", tsInternalPass); + acctReleaseAcct(pAcct); + } return 0; } diff --git a/src/plugins/http/src/httpSystem.c b/src/plugins/http/src/httpSystem.c index 46f31a12d6..deb0d877c7 100644 --- a/src/plugins/http/src/httpSystem.c +++ b/src/plugins/http/src/httpSystem.c @@ -129,7 +129,7 @@ void httpCleanUpSystem() { httpPrint("http service cleanup"); httpStopSystem(); -#if 1 +#if 0 if (httpServer == NULL) { return; } -- GitLab