TD-2046
This commit is contained in:
parent
97e41cdf8d
commit
98ec34b40d
|
@ -57,7 +57,7 @@ typedef struct SSWriteMsg {
|
|||
void * rowData;
|
||||
int32_t (*fpReq)(SMnodeMsg *pMsg);
|
||||
int32_t (*fpWrite)(SMnodeMsg *pMsg, int32_t code);
|
||||
void * pObj;
|
||||
void * pRow;
|
||||
SMnodeMsg *pMsg;
|
||||
struct SSdbTable *pTable;
|
||||
} SSWriteMsg;
|
||||
|
@ -75,7 +75,7 @@ typedef struct {
|
|||
int32_t (*fpEncode)(SSWriteMsg *pWrite);
|
||||
int32_t (*fpDecode)(SSWriteMsg *pWrite);
|
||||
int32_t (*fpDestroy)(SSWriteMsg *pWrite);
|
||||
int32_t (*fpDestored)();
|
||||
int32_t (*fpRestored)();
|
||||
} SSdbTableDesc;
|
||||
|
||||
int32_t sdbInit();
|
||||
|
|
|
@ -32,14 +32,14 @@ static int32_t tsAcctUpdateSize;
|
|||
static int32_t mnodeCreateRootAcct();
|
||||
|
||||
static int32_t mnodeAcctActionDestroy(SSWriteMsg *pWMsg) {
|
||||
SAcctObj *pAcct = pWMsg->pObj;
|
||||
SAcctObj *pAcct = pWMsg->pRow;
|
||||
pthread_mutex_destroy(&pAcct->mutex);
|
||||
tfree(pWMsg->pObj);
|
||||
tfree(pWMsg->pRow);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t mnodeAcctActionInsert(SSWriteMsg *pWMsg) {
|
||||
SAcctObj *pAcct = pWMsg->pObj;
|
||||
SAcctObj *pAcct = pWMsg->pRow;
|
||||
memset(&pAcct->acctInfo, 0, sizeof(SAcctInfo));
|
||||
pAcct->acctInfo.accessState = TSDB_VN_ALL_ACCCESS;
|
||||
pthread_mutex_init(&pAcct->mutex, NULL);
|
||||
|
@ -47,14 +47,14 @@ static int32_t mnodeAcctActionInsert(SSWriteMsg *pWMsg) {
|
|||
}
|
||||
|
||||
static int32_t mnodeAcctActionDelete(SSWriteMsg *pWMsg) {
|
||||
SAcctObj *pAcct = pWMsg->pObj;
|
||||
SAcctObj *pAcct = pWMsg->pRow;
|
||||
mnodeDropAllUsers(pAcct);
|
||||
mnodeDropAllDbs(pAcct);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t mnodeAcctActionUpdate(SSWriteMsg *pWMsg) {
|
||||
SAcctObj *pAcct = pWMsg->pObj;
|
||||
SAcctObj *pAcct = pWMsg->pRow;
|
||||
SAcctObj *pSaved = mnodeGetAcct(pAcct->user);
|
||||
if (pAcct != pSaved) {
|
||||
memcpy(pSaved, pAcct, tsAcctUpdateSize);
|
||||
|
@ -65,7 +65,7 @@ static int32_t mnodeAcctActionUpdate(SSWriteMsg *pWMsg) {
|
|||
}
|
||||
|
||||
static int32_t mnodeAcctActionEncode(SSWriteMsg *pWMsg) {
|
||||
SAcctObj *pAcct = pWMsg->pObj;
|
||||
SAcctObj *pAcct = pWMsg->pRow;
|
||||
memcpy(pWMsg->rowData, pAcct, tsAcctUpdateSize);
|
||||
pWMsg->rowSize = tsAcctUpdateSize;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -76,7 +76,7 @@ static int32_t mnodeAcctActionDecode(SSWriteMsg *pWMsg) {
|
|||
if (pAcct == NULL) return TSDB_CODE_MND_OUT_OF_MEMORY;
|
||||
|
||||
memcpy(pAcct, pWMsg->rowData, tsAcctUpdateSize);
|
||||
pWMsg->pObj = pAcct;
|
||||
pWMsg->pRow = pAcct;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -112,7 +112,7 @@ int32_t mnodeInitAccts() {
|
|||
.fpEncode = mnodeAcctActionEncode,
|
||||
.fpDecode = mnodeAcctActionDecode,
|
||||
.fpDestroy = mnodeAcctActionDestroy,
|
||||
.fpDestored = mnodeAcctActionRestored
|
||||
.fpRestored = mnodeAcctActionRestored
|
||||
};
|
||||
|
||||
tsAcctSdb = sdbOpenTable(&tableDesc);
|
||||
|
@ -229,7 +229,7 @@ static int32_t mnodeCreateRootAcct() {
|
|||
SSWriteMsg wmsg = {
|
||||
.type = SDB_OPER_GLOBAL,
|
||||
.pTable = tsAcctSdb,
|
||||
.pObj = pAcct,
|
||||
.pRow = pAcct,
|
||||
};
|
||||
|
||||
return sdbInsertRow(&wmsg);
|
||||
|
|
|
@ -33,7 +33,7 @@ static int32_t mnodeGetClusterMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *
|
|||
static int32_t mnodeRetrieveClusters(SShowObj *pShow, char *data, int32_t rows, void *pConn);
|
||||
|
||||
static int32_t mnodeClusterActionDestroy(SSWriteMsg *pWMsg) {
|
||||
tfree(pWMsg->pObj);
|
||||
tfree(pWMsg->pRow);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ static int32_t mnodeClusterActionUpdate(SSWriteMsg *pWMsg) {
|
|||
}
|
||||
|
||||
static int32_t mnodeClusterActionEncode(SSWriteMsg *pWMsg) {
|
||||
SClusterObj *pCluster = pWMsg->pObj;
|
||||
SClusterObj *pCluster = pWMsg->pRow;
|
||||
memcpy(pWMsg->rowData, pCluster, tsClusterUpdateSize);
|
||||
pWMsg->rowSize = tsClusterUpdateSize;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -61,7 +61,7 @@ static int32_t mnodeClusterActionDecode(SSWriteMsg *pWMsg) {
|
|||
if (pCluster == NULL) return TSDB_CODE_MND_OUT_OF_MEMORY;
|
||||
|
||||
memcpy(pCluster, pWMsg->rowData, tsClusterUpdateSize);
|
||||
pWMsg->pObj = pCluster;
|
||||
pWMsg->pRow = pCluster;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -97,7 +97,7 @@ int32_t mnodeInitCluster() {
|
|||
.fpEncode = mnodeClusterActionEncode,
|
||||
.fpDecode = mnodeClusterActionDecode,
|
||||
.fpDestroy = mnodeClusterActionDestroy,
|
||||
.fpDestored = mnodeClusterActionRestored
|
||||
.fpRestored = mnodeClusterActionRestored
|
||||
};
|
||||
|
||||
tsClusterSdb = sdbOpenTable(&tableDesc);
|
||||
|
@ -148,7 +148,7 @@ static int32_t mnodeCreateCluster() {
|
|||
SSWriteMsg wmsg = {
|
||||
.type = SDB_OPER_GLOBAL,
|
||||
.pTable = tsClusterSdb,
|
||||
.pObj = pCluster,
|
||||
.pRow = pCluster,
|
||||
};
|
||||
|
||||
return sdbInsertRow(&wmsg);
|
||||
|
|
|
@ -57,7 +57,7 @@ static void mnodeDestroyDb(SDbObj *pDb) {
|
|||
}
|
||||
|
||||
static int32_t mnodeDbActionDestroy(SSWriteMsg *pWMsg) {
|
||||
mnodeDestroyDb(pWMsg->pObj);
|
||||
mnodeDestroyDb(pWMsg->pRow);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ int64_t mnodeGetDbNum() {
|
|||
}
|
||||
|
||||
static int32_t mnodeDbActionInsert(SSWriteMsg *pWMsg) {
|
||||
SDbObj *pDb = pWMsg->pObj;
|
||||
SDbObj *pDb = pWMsg->pRow;
|
||||
SAcctObj *pAcct = mnodeGetAcct(pDb->acct);
|
||||
|
||||
pthread_mutex_init(&pDb->mutex, NULL);
|
||||
|
@ -92,7 +92,7 @@ static int32_t mnodeDbActionInsert(SSWriteMsg *pWMsg) {
|
|||
}
|
||||
|
||||
static int32_t mnodeDbActionDelete(SSWriteMsg *pWMsg) {
|
||||
SDbObj *pDb = pWMsg->pObj;
|
||||
SDbObj *pDb = pWMsg->pRow;
|
||||
SAcctObj *pAcct = mnodeGetAcct(pDb->acct);
|
||||
|
||||
mnodeDropAllChildTables(pDb);
|
||||
|
@ -108,7 +108,7 @@ static int32_t mnodeDbActionDelete(SSWriteMsg *pWMsg) {
|
|||
}
|
||||
|
||||
static int32_t mnodeDbActionUpdate(SSWriteMsg *pWMsg) {
|
||||
SDbObj *pNew = pWMsg->pObj;
|
||||
SDbObj *pNew = pWMsg->pRow;
|
||||
SDbObj *pDb = mnodeGetDb(pNew->name);
|
||||
if (pDb != NULL && pNew != pDb) {
|
||||
memcpy(pDb, pNew, pWMsg->rowSize);
|
||||
|
@ -121,7 +121,7 @@ static int32_t mnodeDbActionUpdate(SSWriteMsg *pWMsg) {
|
|||
}
|
||||
|
||||
static int32_t mnodeDbActionEncode(SSWriteMsg *pWMsg) {
|
||||
SDbObj *pDb = pWMsg->pObj;
|
||||
SDbObj *pDb = pWMsg->pRow;
|
||||
memcpy(pWMsg->rowData, pDb, tsDbUpdateSize);
|
||||
pWMsg->rowSize = tsDbUpdateSize;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -132,7 +132,7 @@ static int32_t mnodeDbActionDecode(SSWriteMsg *pWMsg) {
|
|||
if (pDb == NULL) return TSDB_CODE_MND_OUT_OF_MEMORY;
|
||||
|
||||
memcpy(pDb, pWMsg->rowData, tsDbUpdateSize);
|
||||
pWMsg->pObj = pDb;
|
||||
pWMsg->pRow = pDb;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -157,7 +157,7 @@ int32_t mnodeInitDbs() {
|
|||
.fpEncode = mnodeDbActionEncode,
|
||||
.fpDecode = mnodeDbActionDecode,
|
||||
.fpDestroy = mnodeDbActionDestroy,
|
||||
.fpDestored = mnodeDbActionRestored
|
||||
.fpRestored = mnodeDbActionRestored
|
||||
};
|
||||
|
||||
tsDbSdb = sdbOpenTable(&tableDesc);
|
||||
|
@ -415,7 +415,7 @@ static int32_t mnodeCreateDb(SAcctObj *pAcct, SCreateDbMsg *pCreate, SMnodeMsg *
|
|||
SSWriteMsg wmsg = {
|
||||
.type = SDB_OPER_GLOBAL,
|
||||
.pTable = tsDbSdb,
|
||||
.pObj = pDb,
|
||||
.pRow = pDb,
|
||||
.rowSize = sizeof(SDbObj),
|
||||
.pMsg = pMsg,
|
||||
.fpWrite = mnodeCreateDbCb
|
||||
|
@ -810,7 +810,7 @@ static int32_t mnodeSetDbDropping(SDbObj *pDb) {
|
|||
SSWriteMsg wmsg = {
|
||||
.type = SDB_OPER_GLOBAL,
|
||||
.pTable = tsDbSdb,
|
||||
.pObj = pDb
|
||||
.pRow = pDb
|
||||
};
|
||||
|
||||
int32_t code = sdbUpdateRow(&wmsg);
|
||||
|
@ -1022,7 +1022,7 @@ static int32_t mnodeAlterDb(SDbObj *pDb, SAlterDbMsg *pAlter, void *pMsg) {
|
|||
SSWriteMsg wmsg = {
|
||||
.type = SDB_OPER_GLOBAL,
|
||||
.pTable = tsDbSdb,
|
||||
.pObj = pDb,
|
||||
.pRow = pDb,
|
||||
.pMsg = pMsg,
|
||||
.fpWrite = mnodeAlterDbCb
|
||||
};
|
||||
|
@ -1074,7 +1074,7 @@ static int32_t mnodeDropDb(SMnodeMsg *pMsg) {
|
|||
SSWriteMsg wmsg = {
|
||||
.type = SDB_OPER_GLOBAL,
|
||||
.pTable = tsDbSdb,
|
||||
.pObj = pDb,
|
||||
.pRow = pDb,
|
||||
.pMsg = pMsg,
|
||||
.fpWrite = mnodeDropDbCb
|
||||
};
|
||||
|
@ -1137,7 +1137,7 @@ void mnodeDropAllDbs(SAcctObj *pAcct) {
|
|||
SSWriteMsg wmsg = {
|
||||
.type = SDB_OPER_LOCAL,
|
||||
.pTable = tsDbSdb,
|
||||
.pObj = pDb
|
||||
.pRow = pDb
|
||||
};
|
||||
|
||||
sdbDeleteRow(&wmsg);
|
||||
|
|
|
@ -88,12 +88,12 @@ static char* offlineReason[] = {
|
|||
};
|
||||
|
||||
static int32_t mnodeDnodeActionDestroy(SSWriteMsg *pWMsg) {
|
||||
tfree(pWMsg->pObj);
|
||||
tfree(pWMsg->pRow);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t mnodeDnodeActionInsert(SSWriteMsg *pWMsg) {
|
||||
SDnodeObj *pDnode = pWMsg->pObj;
|
||||
SDnodeObj *pDnode = pWMsg->pRow;
|
||||
if (pDnode->status != TAOS_DN_STATUS_DROPPING) {
|
||||
pDnode->status = TAOS_DN_STATUS_OFFLINE;
|
||||
pDnode->lastAccess = tsAccessSquence;
|
||||
|
@ -108,7 +108,7 @@ static int32_t mnodeDnodeActionInsert(SSWriteMsg *pWMsg) {
|
|||
}
|
||||
|
||||
static int32_t mnodeDnodeActionDelete(SSWriteMsg *pWMsg) {
|
||||
SDnodeObj *pDnode = pWMsg->pObj;
|
||||
SDnodeObj *pDnode = pWMsg->pRow;
|
||||
|
||||
#ifndef _SYNC
|
||||
mnodeDropAllDnodeVgroups(pDnode);
|
||||
|
@ -122,7 +122,7 @@ static int32_t mnodeDnodeActionDelete(SSWriteMsg *pWMsg) {
|
|||
}
|
||||
|
||||
static int32_t mnodeDnodeActionUpdate(SSWriteMsg *pWMsg) {
|
||||
SDnodeObj *pNew = pWMsg->pObj;
|
||||
SDnodeObj *pNew = pWMsg->pRow;
|
||||
SDnodeObj *pDnode = mnodeGetDnode(pNew->dnodeId);
|
||||
if (pDnode != NULL && pNew != pDnode) {
|
||||
memcpy(pDnode, pNew, pWMsg->rowSize);
|
||||
|
@ -135,7 +135,7 @@ static int32_t mnodeDnodeActionUpdate(SSWriteMsg *pWMsg) {
|
|||
}
|
||||
|
||||
static int32_t mnodeDnodeActionEncode(SSWriteMsg *pWMsg) {
|
||||
SDnodeObj *pDnode = pWMsg->pObj;
|
||||
SDnodeObj *pDnode = pWMsg->pRow;
|
||||
memcpy(pWMsg->rowData, pDnode, tsDnodeUpdateSize);
|
||||
pWMsg->rowSize = tsDnodeUpdateSize;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -146,7 +146,7 @@ static int32_t mnodeDnodeActionDecode(SSWriteMsg *pWMsg) {
|
|||
if (pDnode == NULL) return TSDB_CODE_MND_OUT_OF_MEMORY;
|
||||
|
||||
memcpy(pDnode, pWMsg->rowData, tsDnodeUpdateSize);
|
||||
pWMsg->pObj = pDnode;
|
||||
pWMsg->pRow = pDnode;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -184,7 +184,7 @@ int32_t mnodeInitDnodes() {
|
|||
.fpEncode = mnodeDnodeActionEncode,
|
||||
.fpDecode = mnodeDnodeActionDecode,
|
||||
.fpDestroy = mnodeDnodeActionDestroy,
|
||||
.fpDestored = mnodeDnodeActionRestored
|
||||
.fpRestored = mnodeDnodeActionRestored
|
||||
};
|
||||
|
||||
tsDnodeSdb = sdbOpenTable(&tableDesc);
|
||||
|
@ -299,7 +299,7 @@ void mnodeUpdateDnode(SDnodeObj *pDnode) {
|
|||
SSWriteMsg wmsg = {
|
||||
.type = SDB_OPER_GLOBAL,
|
||||
.pTable = tsDnodeSdb,
|
||||
.pObj = pDnode
|
||||
.pRow = pDnode
|
||||
};
|
||||
|
||||
int32_t code = sdbUpdateRow(&wmsg);
|
||||
|
@ -647,7 +647,7 @@ static int32_t mnodeCreateDnode(char *ep, SMnodeMsg *pMsg) {
|
|||
SSWriteMsg wmsg = {
|
||||
.type = SDB_OPER_GLOBAL,
|
||||
.pTable = tsDnodeSdb,
|
||||
.pObj = pDnode,
|
||||
.pRow = pDnode,
|
||||
.rowSize = sizeof(SDnodeObj),
|
||||
.pMsg = pMsg
|
||||
};
|
||||
|
@ -668,7 +668,7 @@ int32_t mnodeDropDnode(SDnodeObj *pDnode, void *pMsg) {
|
|||
SSWriteMsg wmsg = {
|
||||
.type = SDB_OPER_GLOBAL,
|
||||
.pTable = tsDnodeSdb,
|
||||
.pObj = pDnode,
|
||||
.pRow = pDnode,
|
||||
.pMsg = pMsg
|
||||
};
|
||||
|
||||
|
@ -1141,7 +1141,7 @@ static int32_t mnodeRetrieveVnodes(SShowObj *pShow, char *data, int32_t rows, vo
|
|||
cols++;
|
||||
|
||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||
strcpy(pWrite, mnodeGetMnodeRoleStr(pVgid->role));
|
||||
strcpy(pWrite, syncRole[pVgid->role]);
|
||||
cols++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,12 +59,12 @@ static int32_t mnodeRetrieveMnodes(SShowObj *pShow, char *data, int32_t rows, vo
|
|||
#endif
|
||||
|
||||
static int32_t mnodeMnodeActionDestroy(SSWriteMsg *pWMsg) {
|
||||
tfree(pWMsg->pObj);
|
||||
tfree(pWMsg->pRow);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t mnodeMnodeActionInsert(SSWriteMsg *pWMsg) {
|
||||
SMnodeObj *pMnode = pWMsg->pObj;
|
||||
SMnodeObj *pMnode = pWMsg->pRow;
|
||||
SDnodeObj *pDnode = mnodeGetDnode(pMnode->mnodeId);
|
||||
if (pDnode == NULL) return TSDB_CODE_MND_DNODE_NOT_EXIST;
|
||||
|
||||
|
@ -77,7 +77,7 @@ static int32_t mnodeMnodeActionInsert(SSWriteMsg *pWMsg) {
|
|||
}
|
||||
|
||||
static int32_t mnodeMnodeActionDelete(SSWriteMsg *pWMsg) {
|
||||
SMnodeObj *pMnode = pWMsg->pObj;
|
||||
SMnodeObj *pMnode = pWMsg->pRow;
|
||||
|
||||
SDnodeObj *pDnode = mnodeGetDnode(pMnode->mnodeId);
|
||||
if (pDnode == NULL) return TSDB_CODE_MND_DNODE_NOT_EXIST;
|
||||
|
@ -89,7 +89,7 @@ static int32_t mnodeMnodeActionDelete(SSWriteMsg *pWMsg) {
|
|||
}
|
||||
|
||||
static int32_t mnodeMnodeActionUpdate(SSWriteMsg *pWMsg) {
|
||||
SMnodeObj *pMnode = pWMsg->pObj;
|
||||
SMnodeObj *pMnode = pWMsg->pRow;
|
||||
SMnodeObj *pSaved = mnodeGetMnode(pMnode->mnodeId);
|
||||
if (pMnode != pSaved) {
|
||||
memcpy(pSaved, pMnode, pWMsg->rowSize);
|
||||
|
@ -100,7 +100,7 @@ static int32_t mnodeMnodeActionUpdate(SSWriteMsg *pWMsg) {
|
|||
}
|
||||
|
||||
static int32_t mnodeMnodeActionEncode(SSWriteMsg *pWMsg) {
|
||||
SMnodeObj *pMnode = pWMsg->pObj;
|
||||
SMnodeObj *pMnode = pWMsg->pRow;
|
||||
memcpy(pWMsg->rowData, pMnode, tsMnodeUpdateSize);
|
||||
pWMsg->rowSize = tsMnodeUpdateSize;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -111,7 +111,7 @@ static int32_t mnodeMnodeActionDecode(SSWriteMsg *pWMsg) {
|
|||
if (pMnode == NULL) return TSDB_CODE_MND_OUT_OF_MEMORY;
|
||||
|
||||
memcpy(pMnode, pWMsg->rowData, tsMnodeUpdateSize);
|
||||
pWMsg->pObj = pMnode;
|
||||
pWMsg->pRow = pMnode;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -150,7 +150,7 @@ int32_t mnodeInitMnodes() {
|
|||
.fpEncode = mnodeMnodeActionEncode,
|
||||
.fpDecode = mnodeMnodeActionDecode,
|
||||
.fpDestroy = mnodeMnodeActionDestroy,
|
||||
.fpDestored = mnodeMnodeActionRestored
|
||||
.fpRestored = mnodeMnodeActionRestored
|
||||
};
|
||||
|
||||
tsMnodeSdb = sdbOpenTable(&tableDesc);
|
||||
|
@ -192,10 +192,6 @@ void *mnodeGetNextMnode(void *pIter, SMnodeObj **pMnode) {
|
|||
return sdbFetchRow(tsMnodeSdb, pIter, (void **)pMnode);
|
||||
}
|
||||
|
||||
char *mnodeGetMnodeRoleStr(int32_t role) {
|
||||
return syncRole[role];
|
||||
}
|
||||
|
||||
void mnodeUpdateMnodeEpSet() {
|
||||
mInfo("update mnodes epSet, numOfEps:%d ", mnodeGetMnodesNum());
|
||||
|
||||
|
@ -332,7 +328,7 @@ void mnodeCreateMnode(int32_t dnodeId, char *dnodeEp, bool needConfirm) {
|
|||
SSWriteMsg wmsg = {
|
||||
.type = SDB_OPER_GLOBAL,
|
||||
.pTable = tsMnodeSdb,
|
||||
.pObj = pMnode,
|
||||
.pRow = pMnode,
|
||||
.fpWrite = mnodeCreateMnodeCb
|
||||
};
|
||||
|
||||
|
@ -356,7 +352,7 @@ void mnodeCreateMnode(int32_t dnodeId, char *dnodeEp, bool needConfirm) {
|
|||
void mnodeDropMnodeLocal(int32_t dnodeId) {
|
||||
SMnodeObj *pMnode = mnodeGetMnode(dnodeId);
|
||||
if (pMnode != NULL) {
|
||||
SSWriteMsg wmsg = {.type = SDB_OPER_LOCAL, .pTable = tsMnodeSdb, .pObj = pMnode};
|
||||
SSWriteMsg wmsg = {.type = SDB_OPER_LOCAL, .pTable = tsMnodeSdb, .pRow = pMnode};
|
||||
sdbDeleteRow(&wmsg);
|
||||
mnodeDecMnodeRef(pMnode);
|
||||
}
|
||||
|
@ -374,7 +370,7 @@ int32_t mnodeDropMnode(int32_t dnodeId) {
|
|||
SSWriteMsg wmsg = {
|
||||
.type = SDB_OPER_GLOBAL,
|
||||
.pTable = tsMnodeSdb,
|
||||
.pObj = pMnode
|
||||
.pRow = pMnode
|
||||
};
|
||||
|
||||
int32_t code = sdbDeleteRow(&wmsg);
|
||||
|
@ -469,7 +465,7 @@ static int32_t mnodeRetrieveMnodes(SShowObj *pShow, char *data, int32_t rows, vo
|
|||
cols++;
|
||||
|
||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||
char* roles = mnodeGetMnodeRoleStr(pMnode->role);
|
||||
char* roles = syncRole[pMnode->role];
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, roles, pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
|
|
|
@ -37,15 +37,15 @@
|
|||
#define SDB_SYNC_HACK 16
|
||||
|
||||
typedef enum {
|
||||
SDB_ACTION_INSERT,
|
||||
SDB_ACTION_DELETE,
|
||||
SDB_ACTION_UPDATE
|
||||
SDB_ACTION_INSERT = 0,
|
||||
SDB_ACTION_DELETE = 1,
|
||||
SDB_ACTION_UPDATE = 2
|
||||
} ESdbAction;
|
||||
|
||||
typedef enum {
|
||||
SDB_STATUS_OFFLINE,
|
||||
SDB_STATUS_SERVING,
|
||||
SDB_STATUS_CLOSING
|
||||
SDB_STATUS_OFFLINE = 0,
|
||||
SDB_STATUS_SERVING = 1,
|
||||
SDB_STATUS_CLOSING = 2
|
||||
} ESdbStatus;
|
||||
|
||||
typedef struct SSdbTable {
|
||||
|
@ -64,7 +64,7 @@ typedef struct SSdbTable {
|
|||
int32_t (*fpDecode)(SSWriteMsg *pWrite);
|
||||
int32_t (*fpEncode)(SSWriteMsg *pWrite);
|
||||
int32_t (*fpDestroy)(SSWriteMsg *pWrite);
|
||||
int32_t (*fpDestored)();
|
||||
int32_t (*fpRestored)();
|
||||
pthread_mutex_t mutex;
|
||||
} SSdbTable;
|
||||
|
||||
|
@ -78,7 +78,7 @@ typedef struct {
|
|||
int32_t numOfTables;
|
||||
SSdbTable *tableList[SDB_TABLE_MAX];
|
||||
pthread_mutex_t mutex;
|
||||
} SSdbObject;
|
||||
} SSdbMgmt;
|
||||
|
||||
typedef struct {
|
||||
pthread_t thread;
|
||||
|
@ -92,7 +92,7 @@ typedef struct {
|
|||
|
||||
extern void * tsMnodeTmr;
|
||||
static void * tsSdbTmr;
|
||||
static SSdbObject tsSdbObj = {0};
|
||||
static SSdbMgmt tsSdbMgmt = {0};
|
||||
static taos_qset tsSdbWQset;
|
||||
static taos_qall tsSdbWQall;
|
||||
static taos_queue tsSdbWQueue;
|
||||
|
@ -121,15 +121,15 @@ int64_t sdbGetNumOfRows(void *pTable) {
|
|||
}
|
||||
|
||||
uint64_t sdbGetVersion() {
|
||||
return tsSdbObj.version;
|
||||
return tsSdbMgmt.version;
|
||||
}
|
||||
|
||||
bool sdbIsMaster() {
|
||||
return tsSdbObj.role == TAOS_SYNC_ROLE_MASTER;
|
||||
return tsSdbMgmt.role == TAOS_SYNC_ROLE_MASTER;
|
||||
}
|
||||
|
||||
bool sdbIsServing() {
|
||||
return tsSdbObj.status == SDB_STATUS_SERVING;
|
||||
return tsSdbMgmt.status == SDB_STATUS_SERVING;
|
||||
}
|
||||
|
||||
static void *sdbGetObjKey(SSdbTable *pTable, void *key) {
|
||||
|
@ -172,21 +172,21 @@ static char *sdbGetObjStr(SSdbTable *pTable, void *key) {
|
|||
}
|
||||
|
||||
static void *sdbGetTableFromId(int32_t tableId) {
|
||||
return tsSdbObj.tableList[tableId];
|
||||
return tsSdbMgmt.tableList[tableId];
|
||||
}
|
||||
|
||||
static int32_t sdbInitWal() {
|
||||
SWalCfg walCfg = {.vgId = 1, .walLevel = TAOS_WAL_FSYNC, .keep = TAOS_WAL_KEEP, .fsyncPeriod = 0};
|
||||
char temp[TSDB_FILENAME_LEN] = {0};
|
||||
sprintf(temp, "%s/wal", tsMnodeDir);
|
||||
tsSdbObj.wal = walOpen(temp, &walCfg);
|
||||
if (tsSdbObj.wal == NULL) {
|
||||
tsSdbMgmt.wal = walOpen(temp, &walCfg);
|
||||
if (tsSdbMgmt.wal == NULL) {
|
||||
sdbError("vgId:1, failed to open wal in %s", tsMnodeDir);
|
||||
return -1;
|
||||
}
|
||||
|
||||
sdbInfo("vgId:1, open wal for restore");
|
||||
int code = walRestore(tsSdbObj.wal, NULL, sdbWrite);
|
||||
int code = walRestore(tsSdbMgmt.wal, NULL, sdbWrite);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
sdbError("vgId:1, failed to open wal for restore since %s", tstrerror(code));
|
||||
return -1;
|
||||
|
@ -200,8 +200,8 @@ static void sdbRestoreTables() {
|
|||
for (int32_t tableId = 0; tableId < SDB_TABLE_MAX; ++tableId) {
|
||||
SSdbTable *pTable = sdbGetTableFromId(tableId);
|
||||
if (pTable == NULL) continue;
|
||||
if (pTable->fpDestored) {
|
||||
(*pTable->fpDestored)();
|
||||
if (pTable->fpRestored) {
|
||||
(*pTable->fpRestored)();
|
||||
}
|
||||
|
||||
totalRows += pTable->numOfRows;
|
||||
|
@ -209,22 +209,22 @@ static void sdbRestoreTables() {
|
|||
sdbDebug("vgId:1, sdb:%s is restored, rows:%" PRId64, pTable->tableName, pTable->numOfRows);
|
||||
}
|
||||
|
||||
sdbInfo("vgId:1, sdb is restored, mver:%" PRIu64 " rows:%d tables:%d", tsSdbObj.version, totalRows, numOfTables);
|
||||
sdbInfo("vgId:1, sdb is restored, mver:%" PRIu64 " rows:%d tables:%d", tsSdbMgmt.version, totalRows, numOfTables);
|
||||
}
|
||||
|
||||
void sdbUpdateMnodeRoles() {
|
||||
if (tsSdbObj.sync <= 0) return;
|
||||
if (tsSdbMgmt.sync <= 0) return;
|
||||
|
||||
SNodesRole roles = {0};
|
||||
syncGetNodesRole(tsSdbObj.sync, &roles);
|
||||
syncGetNodesRole(tsSdbMgmt.sync, &roles);
|
||||
|
||||
sdbInfo("vgId:1, update mnodes roles, replica:%d", tsSdbObj.cfg.replica);
|
||||
for (int32_t i = 0; i < tsSdbObj.cfg.replica; ++i) {
|
||||
sdbInfo("vgId:1, update mnodes role, replica:%d", tsSdbMgmt.cfg.replica);
|
||||
for (int32_t i = 0; i < tsSdbMgmt.cfg.replica; ++i) {
|
||||
SMnodeObj *pMnode = mnodeGetMnode(roles.nodeId[i]);
|
||||
if (pMnode != NULL) {
|
||||
pMnode->role = roles.role[i];
|
||||
sdbInfo("vgId:1, mnode:%d, role:%s", pMnode->mnodeId, mnodeGetMnodeRoleStr(pMnode->role));
|
||||
if (pMnode->mnodeId == dnodeGetDnodeId()) tsSdbObj.role = pMnode->role;
|
||||
sdbInfo("vgId:1, mnode:%d, role:%s", pMnode->mnodeId, syncRole[pMnode->role]);
|
||||
if (pMnode->mnodeId == dnodeGetDnodeId()) tsSdbMgmt.role = pMnode->role;
|
||||
mnodeDecMnodeRef(pMnode);
|
||||
}
|
||||
}
|
||||
|
@ -239,16 +239,16 @@ static uint32_t sdbGetFileInfo(void *ahandle, char *name, uint32_t *index, uint3
|
|||
}
|
||||
|
||||
static int32_t sdbGetWalInfo(void *ahandle, char *fileName, int64_t *fileId) {
|
||||
return walGetWalFile(tsSdbObj.wal, fileName, fileId);
|
||||
return walGetWalFile(tsSdbMgmt.wal, fileName, fileId);
|
||||
}
|
||||
|
||||
static void sdbNotifyRole(void *ahandle, int8_t role) {
|
||||
sdbInfo("vgId:1, mnode role changed from %s to %s", mnodeGetMnodeRoleStr(tsSdbObj.role), mnodeGetMnodeRoleStr(role));
|
||||
sdbInfo("vgId:1, mnode role changed from %s to %s", syncRole[tsSdbMgmt.role], syncRole[role]);
|
||||
|
||||
if (role == TAOS_SYNC_ROLE_MASTER && tsSdbObj.role != TAOS_SYNC_ROLE_MASTER) {
|
||||
if (role == TAOS_SYNC_ROLE_MASTER && tsSdbMgmt.role != TAOS_SYNC_ROLE_MASTER) {
|
||||
balanceReset();
|
||||
}
|
||||
tsSdbObj.role = role;
|
||||
tsSdbMgmt.role = role;
|
||||
|
||||
sdbUpdateMnodeRoles();
|
||||
}
|
||||
|
@ -276,7 +276,7 @@ static void sdbConfirmForward(void *ahandle, void *param, int32_t code) {
|
|||
if (pWrite->retCode != TSDB_CODE_SUCCESS) {
|
||||
SWalHead *pHead = (void *)pWrite + sizeof(SSWriteMsg) + SDB_SYNC_HACK;
|
||||
int32_t action = pHead->msgType % 10;
|
||||
sdbError("vgId:1, key:%p:%s hver:%" PRIu64 " action:%d, failed to foward since %s", pWrite->pObj,
|
||||
sdbError("vgId:1, key:%p:%s hver:%" PRIu64 " action:%d, failed to foward since %s", pWrite->pRow,
|
||||
sdbGetKeyStr(pWrite->pTable, pHead->cont), pHead->version, action, tstrerror(pWrite->retCode));
|
||||
if (action == SDB_ACTION_INSERT) {
|
||||
// It's better to create a table in two stages, create it first and then set it success
|
||||
|
@ -284,7 +284,7 @@ static void sdbConfirmForward(void *ahandle, void *param, int32_t code) {
|
|||
SSWriteMsg wmsg = {
|
||||
.type = SDB_OPER_GLOBAL,
|
||||
.pTable = pWrite->pTable,
|
||||
.pObj = pWrite->pObj
|
||||
.pRow = pWrite->pRow
|
||||
};
|
||||
sdbDeleteRow(&wmsg);
|
||||
}
|
||||
|
@ -297,7 +297,7 @@ static void sdbConfirmForward(void *ahandle, void *param, int32_t code) {
|
|||
|
||||
// if ahandle, means this func is called by sdb write
|
||||
if (ahandle == NULL) {
|
||||
sdbDecRef(pWrite->pTable, pWrite->pObj);
|
||||
sdbDecRef(pWrite->pTable, pWrite->pRow);
|
||||
}
|
||||
|
||||
taosFreeQitem(pWrite);
|
||||
|
@ -369,7 +369,7 @@ void sdbUpdateSync(void *pMnodes) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (memcmp(&syncCfg, &tsSdbObj.cfg, sizeof(SSyncCfg)) == 0) {
|
||||
if (memcmp(&syncCfg, &tsSdbMgmt.cfg, sizeof(SSyncCfg)) == 0) {
|
||||
sdbDebug("vgId:1, update sync config, info not changed");
|
||||
return;
|
||||
}
|
||||
|
@ -391,18 +391,18 @@ void sdbUpdateSync(void *pMnodes) {
|
|||
syncInfo.writeToCache = sdbWriteToQueue;
|
||||
syncInfo.confirmForward = sdbConfirmForward;
|
||||
syncInfo.notifyRole = sdbNotifyRole;
|
||||
tsSdbObj.cfg = syncCfg;
|
||||
tsSdbMgmt.cfg = syncCfg;
|
||||
|
||||
if (tsSdbObj.sync) {
|
||||
syncReconfig(tsSdbObj.sync, &syncCfg);
|
||||
if (tsSdbMgmt.sync) {
|
||||
syncReconfig(tsSdbMgmt.sync, &syncCfg);
|
||||
} else {
|
||||
tsSdbObj.sync = syncStart(&syncInfo);
|
||||
tsSdbMgmt.sync = syncStart(&syncInfo);
|
||||
}
|
||||
sdbUpdateMnodeRoles();
|
||||
}
|
||||
|
||||
int32_t sdbInit() {
|
||||
pthread_mutex_init(&tsSdbObj.mutex, NULL);
|
||||
pthread_mutex_init(&tsSdbMgmt.mutex, NULL);
|
||||
|
||||
if (sdbInitWorker() != 0) {
|
||||
return -1;
|
||||
|
@ -415,55 +415,55 @@ int32_t sdbInit() {
|
|||
sdbRestoreTables();
|
||||
|
||||
if (mnodeGetMnodesNum() == 1) {
|
||||
tsSdbObj.role = TAOS_SYNC_ROLE_MASTER;
|
||||
tsSdbMgmt.role = TAOS_SYNC_ROLE_MASTER;
|
||||
}
|
||||
|
||||
tsSdbObj.status = SDB_STATUS_SERVING;
|
||||
tsSdbMgmt.status = SDB_STATUS_SERVING;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
void sdbCleanUp() {
|
||||
if (tsSdbObj.status != SDB_STATUS_SERVING) return;
|
||||
if (tsSdbMgmt.status != SDB_STATUS_SERVING) return;
|
||||
|
||||
tsSdbObj.status = SDB_STATUS_CLOSING;
|
||||
tsSdbMgmt.status = SDB_STATUS_CLOSING;
|
||||
|
||||
sdbCleanupWorker();
|
||||
sdbDebug("vgId:1, sdb will be closed, mver:%" PRIu64, tsSdbObj.version);
|
||||
sdbDebug("vgId:1, sdb will be closed, mver:%" PRIu64, tsSdbMgmt.version);
|
||||
|
||||
if (tsSdbObj.sync) {
|
||||
syncStop(tsSdbObj.sync);
|
||||
tsSdbObj.sync = -1;
|
||||
if (tsSdbMgmt.sync) {
|
||||
syncStop(tsSdbMgmt.sync);
|
||||
tsSdbMgmt.sync = -1;
|
||||
}
|
||||
|
||||
if (tsSdbObj.wal) {
|
||||
walClose(tsSdbObj.wal);
|
||||
tsSdbObj.wal = NULL;
|
||||
if (tsSdbMgmt.wal) {
|
||||
walClose(tsSdbMgmt.wal);
|
||||
tsSdbMgmt.wal = NULL;
|
||||
}
|
||||
|
||||
pthread_mutex_destroy(&tsSdbObj.mutex);
|
||||
pthread_mutex_destroy(&tsSdbMgmt.mutex);
|
||||
}
|
||||
|
||||
void sdbIncRef(void *tparam, void *pObj) {
|
||||
if (pObj == NULL || tparam == NULL) return;
|
||||
void sdbIncRef(void *tparam, void *pRow) {
|
||||
if (pRow == NULL || tparam == NULL) return;
|
||||
|
||||
SSdbTable *pTable = tparam;
|
||||
int32_t * pRefCount = (int32_t *)(pObj + pTable->refCountPos);
|
||||
int32_t * pRefCount = (int32_t *)(pRow + pTable->refCountPos);
|
||||
int32_t refCount = atomic_add_fetch_32(pRefCount, 1);
|
||||
sdbTrace("vgId:1, sdb:%s, inc ref to key:%p:%s:%d", pTable->tableName, pObj, sdbGetObjStr(pTable, pObj), refCount);
|
||||
sdbTrace("vgId:1, sdb:%s, inc ref to key:%p:%s:%d", pTable->tableName, pRow, sdbGetObjStr(pTable, pRow), refCount);
|
||||
}
|
||||
|
||||
void sdbDecRef(void *tparam, void *pObj) {
|
||||
if (pObj == NULL || tparam == NULL) return;
|
||||
void sdbDecRef(void *tparam, void *pRow) {
|
||||
if (pRow == NULL || tparam == NULL) return;
|
||||
|
||||
SSdbTable *pTable = tparam;
|
||||
int32_t * pRefCount = (int32_t *)(pObj + pTable->refCountPos);
|
||||
int32_t * pRefCount = (int32_t *)(pRow + pTable->refCountPos);
|
||||
int32_t refCount = atomic_sub_fetch_32(pRefCount, 1);
|
||||
sdbTrace("vgId:1, sdb:%s, dec ref to key:%p:%s:%d", pTable->tableName, pObj, sdbGetObjStr(pTable, pObj), refCount);
|
||||
sdbTrace("vgId:1, sdb:%s, dec ref to key:%p:%s:%d", pTable->tableName, pRow, sdbGetObjStr(pTable, pRow), refCount);
|
||||
|
||||
int32_t *updateEnd = pObj + pTable->refCountPos - 4;
|
||||
int32_t *updateEnd = pRow + pTable->refCountPos - 4;
|
||||
if (refCount <= 0 && *updateEnd) {
|
||||
sdbTrace("vgId:1, sdb:%s, key:%p:%s:%d destroyed", pTable->tableName, pObj, sdbGetObjStr(pTable, pObj), refCount);
|
||||
SSWriteMsg wmsg = {.pObj = pObj};
|
||||
sdbTrace("vgId:1, sdb:%s, key:%p:%s:%d destroyed", pTable->tableName, pRow, sdbGetObjStr(pTable, pRow), refCount);
|
||||
SSWriteMsg wmsg = {.pRow = pRow};
|
||||
(*pTable->fpDestroy)(&wmsg);
|
||||
}
|
||||
}
|
||||
|
@ -502,7 +502,7 @@ static void *sdbGetRowFromObj(SSdbTable *pTable, void *key) {
|
|||
}
|
||||
|
||||
static int32_t sdbInsertHash(SSdbTable *pTable, SSWriteMsg *pWrite) {
|
||||
void * key = sdbGetObjKey(pTable, pWrite->pObj);
|
||||
void * key = sdbGetObjKey(pTable, pWrite->pRow);
|
||||
int32_t keySize = sizeof(int32_t);
|
||||
|
||||
if (pTable->keyType == SDB_KEY_STRING || pTable->keyType == SDB_KEY_VAR_STRING) {
|
||||
|
@ -510,25 +510,25 @@ static int32_t sdbInsertHash(SSdbTable *pTable, SSWriteMsg *pWrite) {
|
|||
}
|
||||
|
||||
pthread_mutex_lock(&pTable->mutex);
|
||||
taosHashPut(pTable->iHandle, key, keySize, &pWrite->pObj, sizeof(int64_t));
|
||||
taosHashPut(pTable->iHandle, key, keySize, &pWrite->pRow, sizeof(int64_t));
|
||||
pthread_mutex_unlock(&pTable->mutex);
|
||||
|
||||
sdbIncRef(pTable, pWrite->pObj);
|
||||
sdbIncRef(pTable, pWrite->pRow);
|
||||
atomic_add_fetch_32(&pTable->numOfRows, 1);
|
||||
|
||||
if (pTable->keyType == SDB_KEY_AUTO) {
|
||||
pTable->autoIndex = MAX(pTable->autoIndex, *((uint32_t *)pWrite->pObj));
|
||||
pTable->autoIndex = MAX(pTable->autoIndex, *((uint32_t *)pWrite->pRow));
|
||||
} else {
|
||||
atomic_add_fetch_32(&pTable->autoIndex, 1);
|
||||
}
|
||||
|
||||
sdbDebug("vgId:1, sdb:%s, insert key:%s to hash, rowSize:%d rows:%" PRId64 ", msg:%p", pTable->tableName,
|
||||
sdbGetObjStr(pTable, pWrite->pObj), pWrite->rowSize, pTable->numOfRows, pWrite->pMsg);
|
||||
sdbGetObjStr(pTable, pWrite->pRow), pWrite->rowSize, pTable->numOfRows, pWrite->pMsg);
|
||||
|
||||
int32_t code = (*pTable->fpInsert)(pWrite);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
sdbError("vgId:1, sdb:%s, failed to insert key:%s to hash, remove it", pTable->tableName,
|
||||
sdbGetObjStr(pTable, pWrite->pObj));
|
||||
sdbGetObjStr(pTable, pWrite->pRow));
|
||||
sdbDeleteHash(pTable, pWrite);
|
||||
}
|
||||
|
||||
|
@ -536,17 +536,17 @@ static int32_t sdbInsertHash(SSdbTable *pTable, SSWriteMsg *pWrite) {
|
|||
}
|
||||
|
||||
static int32_t sdbDeleteHash(SSdbTable *pTable, SSWriteMsg *pWrite) {
|
||||
int32_t *updateEnd = pWrite->pObj + pTable->refCountPos - 4;
|
||||
int32_t *updateEnd = pWrite->pRow + pTable->refCountPos - 4;
|
||||
bool set = atomic_val_compare_exchange_32(updateEnd, 0, 1) == 0;
|
||||
if (!set) {
|
||||
sdbError("vgId:1, sdb:%s, failed to delete key:%s from hash, for it already removed", pTable->tableName,
|
||||
sdbGetObjStr(pTable, pWrite->pObj));
|
||||
sdbGetObjStr(pTable, pWrite->pRow));
|
||||
return TSDB_CODE_MND_SDB_OBJ_NOT_THERE;
|
||||
}
|
||||
|
||||
(*pTable->fpDelete)(pWrite);
|
||||
|
||||
void * key = sdbGetObjKey(pTable, pWrite->pObj);
|
||||
void * key = sdbGetObjKey(pTable, pWrite->pRow);
|
||||
int32_t keySize = sizeof(int32_t);
|
||||
if (pTable->keyType == SDB_KEY_STRING || pTable->keyType == SDB_KEY_VAR_STRING) {
|
||||
keySize = strlen((char *)key);
|
||||
|
@ -559,16 +559,16 @@ static int32_t sdbDeleteHash(SSdbTable *pTable, SSWriteMsg *pWrite) {
|
|||
atomic_sub_fetch_32(&pTable->numOfRows, 1);
|
||||
|
||||
sdbDebug("vgId:1, sdb:%s, delete key:%s from hash, numOfRows:%" PRId64 ", msg:%p", pTable->tableName,
|
||||
sdbGetObjStr(pTable, pWrite->pObj), pTable->numOfRows, pWrite->pMsg);
|
||||
sdbGetObjStr(pTable, pWrite->pRow), pTable->numOfRows, pWrite->pMsg);
|
||||
|
||||
sdbDecRef(pTable, pWrite->pObj);
|
||||
sdbDecRef(pTable, pWrite->pRow);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t sdbUpdateHash(SSdbTable *pTable, SSWriteMsg *pWrite) {
|
||||
sdbDebug("vgId:1, sdb:%s, update key:%s in hash, numOfRows:%" PRId64 ", msg:%p", pTable->tableName,
|
||||
sdbGetObjStr(pTable, pWrite->pObj), pTable->numOfRows, pWrite->pMsg);
|
||||
sdbGetObjStr(pTable, pWrite->pRow), pTable->numOfRows, pWrite->pMsg);
|
||||
|
||||
(*pTable->fpUpdate)(pWrite);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -583,42 +583,42 @@ static int sdbWrite(void *wparam, void *hparam, int32_t qtype, void *unused) {
|
|||
SSdbTable *pTable = sdbGetTableFromId(tableId);
|
||||
assert(pTable != NULL);
|
||||
|
||||
pthread_mutex_lock(&tsSdbObj.mutex);
|
||||
pthread_mutex_lock(&tsSdbMgmt.mutex);
|
||||
|
||||
if (pHead->version == 0) {
|
||||
// assign version
|
||||
tsSdbObj.version++;
|
||||
pHead->version = tsSdbObj.version;
|
||||
tsSdbMgmt.version++;
|
||||
pHead->version = tsSdbMgmt.version;
|
||||
} else {
|
||||
// for data from WAL or forward, version may be smaller
|
||||
if (pHead->version <= tsSdbObj.version) {
|
||||
pthread_mutex_unlock(&tsSdbObj.mutex);
|
||||
if (pHead->version <= tsSdbMgmt.version) {
|
||||
pthread_mutex_unlock(&tsSdbMgmt.mutex);
|
||||
sdbDebug("vgId:1, sdb:%s, failed to restore %s key:%s from source(%d), hver:%" PRIu64 " too large, mver:%" PRIu64,
|
||||
pTable->tableName, sdbGetActionStr(action), sdbGetKeyStr(pTable, pHead->cont), qtype, pHead->version, tsSdbObj.version);
|
||||
pTable->tableName, sdbGetActionStr(action), sdbGetKeyStr(pTable, pHead->cont), qtype, pHead->version, tsSdbMgmt.version);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
} else if (pHead->version != tsSdbObj.version + 1) {
|
||||
pthread_mutex_unlock(&tsSdbObj.mutex);
|
||||
} else if (pHead->version != tsSdbMgmt.version + 1) {
|
||||
pthread_mutex_unlock(&tsSdbMgmt.mutex);
|
||||
sdbError("vgId:1, sdb:%s, failed to restore %s key:%s from source(%d), hver:%" PRIu64 " too large, mver:%" PRIu64,
|
||||
pTable->tableName, sdbGetActionStr(action), sdbGetKeyStr(pTable, pHead->cont), qtype, pHead->version, tsSdbObj.version);
|
||||
pTable->tableName, sdbGetActionStr(action), sdbGetKeyStr(pTable, pHead->cont), qtype, pHead->version, tsSdbMgmt.version);
|
||||
return TSDB_CODE_SYN_INVALID_VERSION;
|
||||
} else {
|
||||
tsSdbObj.version = pHead->version;
|
||||
tsSdbMgmt.version = pHead->version;
|
||||
}
|
||||
}
|
||||
|
||||
int32_t code = walWrite(tsSdbObj.wal, pHead);
|
||||
int32_t code = walWrite(tsSdbMgmt.wal, pHead);
|
||||
if (code < 0) {
|
||||
pthread_mutex_unlock(&tsSdbObj.mutex);
|
||||
pthread_mutex_unlock(&tsSdbMgmt.mutex);
|
||||
return code;
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&tsSdbObj.mutex);
|
||||
pthread_mutex_unlock(&tsSdbMgmt.mutex);
|
||||
|
||||
// from app, wmsg is created
|
||||
if (pWrite != NULL) {
|
||||
// forward to peers
|
||||
pWrite->processedCount = 0;
|
||||
int32_t syncCode = syncForwardToPeer(tsSdbObj.sync, pHead, pWrite, TAOS_QTYPE_RPC);
|
||||
int32_t syncCode = syncForwardToPeer(tsSdbMgmt.sync, pHead, pWrite, TAOS_QTYPE_RPC);
|
||||
if (syncCode <= 0) pWrite->processedCount = 1;
|
||||
|
||||
if (syncCode < 0) {
|
||||
|
@ -638,7 +638,7 @@ static int sdbWrite(void *wparam, void *hparam, int32_t qtype, void *unused) {
|
|||
sdbGetActionStr(action), sdbGetKeyStr(pTable, pHead->cont), pHead->version);
|
||||
|
||||
// even it is WAL/FWD, it shall be called to update version in sync
|
||||
syncForwardToPeer(tsSdbObj.sync, pHead, pWrite, TAOS_QTYPE_RPC);
|
||||
syncForwardToPeer(tsSdbMgmt.sync, pHead, pWrite, TAOS_QTYPE_RPC);
|
||||
|
||||
// from wal or forward msg, wmsg not created, should add into hash
|
||||
if (action == SDB_ACTION_INSERT) {
|
||||
|
@ -652,7 +652,7 @@ static int sdbWrite(void *wparam, void *hparam, int32_t qtype, void *unused) {
|
|||
sdbGetKeyStr(pTable, pHead->cont));
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
SSWriteMsg wmsg = {.pTable = pTable, .pObj = pRow};
|
||||
SSWriteMsg wmsg = {.pTable = pTable, .pRow = pRow};
|
||||
return sdbDeleteHash(pTable, &wmsg);
|
||||
} else if (action == SDB_ACTION_UPDATE) {
|
||||
void *pRow = sdbGetRowMeta(pTable, pHead->cont);
|
||||
|
@ -673,19 +673,19 @@ int32_t sdbInsertRow(SSWriteMsg *pWrite) {
|
|||
SSdbTable *pTable = pWrite->pTable;
|
||||
if (pTable == NULL) return TSDB_CODE_MND_SDB_INVALID_TABLE_TYPE;
|
||||
|
||||
if (sdbGetRowFromObj(pTable, pWrite->pObj)) {
|
||||
if (sdbGetRowFromObj(pTable, pWrite->pRow)) {
|
||||
sdbError("vgId:1, sdb:%s, failed to insert key:%s, already exist", pTable->tableName,
|
||||
sdbGetObjStr(pTable, pWrite->pObj));
|
||||
sdbDecRef(pTable, pWrite->pObj);
|
||||
sdbGetObjStr(pTable, pWrite->pRow));
|
||||
sdbDecRef(pTable, pWrite->pRow);
|
||||
return TSDB_CODE_MND_SDB_OBJ_ALREADY_THERE;
|
||||
}
|
||||
|
||||
if (pTable->keyType == SDB_KEY_AUTO) {
|
||||
*((uint32_t *)pWrite->pObj) = atomic_add_fetch_32(&pTable->autoIndex, 1);
|
||||
*((uint32_t *)pWrite->pRow) = atomic_add_fetch_32(&pTable->autoIndex, 1);
|
||||
|
||||
// let vgId increase from 2
|
||||
if (pTable->autoIndex == 1 && strcmp(pTable->tableName, "vgroups") == 0) {
|
||||
*((uint32_t *)pWrite->pObj) = atomic_add_fetch_32(&pTable->autoIndex, 1);
|
||||
*((uint32_t *)pWrite->pRow) = atomic_add_fetch_32(&pTable->autoIndex, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -727,10 +727,10 @@ int32_t sdbInsertRowImp(SSWriteMsg *pWrite) {
|
|||
|
||||
if (pNewOper->pMsg != NULL) {
|
||||
sdbDebug("vgId:1, ahandle:%p msg:%p, sdb:%s key:%p:%s, insert action is add to sdb queue", pNewOper->pMsg->rpcMsg.ahandle,
|
||||
pNewOper->pMsg, pTable->tableName, pWrite->pObj, sdbGetObjStr(pTable, pWrite->pObj));
|
||||
pNewOper->pMsg, pTable->tableName, pWrite->pRow, sdbGetObjStr(pTable, pWrite->pRow));
|
||||
}
|
||||
|
||||
sdbIncRef(pNewOper->pTable, pNewOper->pObj);
|
||||
sdbIncRef(pNewOper->pTable, pNewOper->pRow);
|
||||
taosWriteQitem(tsSdbWQueue, TAOS_QTYPE_RPC, pNewOper);
|
||||
|
||||
return TSDB_CODE_MND_ACTION_IN_PROGRESS;
|
||||
|
@ -748,24 +748,24 @@ int32_t sdbDeleteRow(SSWriteMsg *pWrite) {
|
|||
SSdbTable *pTable = pWrite->pTable;
|
||||
if (pTable == NULL) return TSDB_CODE_MND_SDB_INVALID_TABLE_TYPE;
|
||||
|
||||
void *pRow = sdbGetRowMetaFromObj(pTable, pWrite->pObj);
|
||||
void *pRow = sdbGetRowMetaFromObj(pTable, pWrite->pRow);
|
||||
if (pRow == NULL) {
|
||||
sdbDebug("vgId:1, sdb:%s, record is not there, delete failed", pTable->tableName);
|
||||
return TSDB_CODE_MND_SDB_OBJ_NOT_THERE;
|
||||
}
|
||||
|
||||
sdbIncRef(pTable, pWrite->pObj);
|
||||
sdbIncRef(pTable, pWrite->pRow);
|
||||
|
||||
int32_t code = sdbDeleteHash(pTable, pWrite);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
sdbError("vgId:1, sdb:%s, failed to delete from hash", pTable->tableName);
|
||||
sdbDecRef(pTable, pWrite->pObj);
|
||||
sdbDecRef(pTable, pWrite->pRow);
|
||||
return code;
|
||||
}
|
||||
|
||||
// just delete data from memory
|
||||
if (pWrite->type != SDB_OPER_GLOBAL) {
|
||||
sdbDecRef(pTable, pWrite->pObj);
|
||||
sdbDecRef(pTable, pWrite->pRow);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -795,7 +795,7 @@ int32_t sdbDeleteRowImp(SSWriteMsg *pWrite) {
|
|||
|
||||
if (pNewOper->pMsg != NULL) {
|
||||
sdbDebug("vgId:1, ahandle:%p msg:%p, sdb:%s key:%p:%s, delete action is add to sdb queue", pNewOper->pMsg->rpcMsg.ahandle,
|
||||
pNewOper->pMsg, pTable->tableName, pWrite->pObj, sdbGetObjStr(pTable, pWrite->pObj));
|
||||
pNewOper->pMsg, pTable->tableName, pWrite->pRow, sdbGetObjStr(pTable, pWrite->pRow));
|
||||
}
|
||||
|
||||
taosWriteQitem(tsSdbWQueue, TAOS_QTYPE_RPC, pNewOper);
|
||||
|
@ -807,7 +807,7 @@ int32_t sdbUpdateRow(SSWriteMsg *pWrite) {
|
|||
SSdbTable *pTable = pWrite->pTable;
|
||||
if (pTable == NULL) return TSDB_CODE_MND_SDB_INVALID_TABLE_TYPE;
|
||||
|
||||
void *pRow = sdbGetRowMetaFromObj(pTable, pWrite->pObj);
|
||||
void *pRow = sdbGetRowMetaFromObj(pTable, pWrite->pRow);
|
||||
if (pRow == NULL) {
|
||||
sdbDebug("vgId:1, sdb:%s, record is not there, update failed", pTable->tableName);
|
||||
return TSDB_CODE_MND_SDB_OBJ_NOT_THERE;
|
||||
|
@ -850,10 +850,10 @@ int32_t sdbUpdateRowImp(SSWriteMsg *pWrite) {
|
|||
|
||||
if (pNewOper->pMsg != NULL) {
|
||||
sdbDebug("vgId:1, ahandle:%p msg:%p, sdb:%s key:%p:%s, update action is add to sdb queue", pNewOper->pMsg->rpcMsg.ahandle,
|
||||
pNewOper->pMsg, pTable->tableName, pWrite->pObj, sdbGetObjStr(pTable, pWrite->pObj));
|
||||
pNewOper->pMsg, pTable->tableName, pWrite->pRow, sdbGetObjStr(pTable, pWrite->pRow));
|
||||
}
|
||||
|
||||
sdbIncRef(pNewOper->pTable, pNewOper->pObj);
|
||||
sdbIncRef(pNewOper->pTable, pNewOper->pRow);
|
||||
taosWriteQitem(tsSdbWQueue, TAOS_QTYPE_RPC, pNewOper);
|
||||
|
||||
return TSDB_CODE_MND_ACTION_IN_PROGRESS;
|
||||
|
@ -910,7 +910,7 @@ void *sdbOpenTable(SSdbTableDesc *pDesc) {
|
|||
pTable->fpEncode = pDesc->fpEncode;
|
||||
pTable->fpDecode = pDesc->fpDecode;
|
||||
pTable->fpDestroy = pDesc->fpDestroy;
|
||||
pTable->fpDestored = pDesc->fpDestored;
|
||||
pTable->fpRestored = pDesc->fpRestored;
|
||||
|
||||
_hash_fn_t hashFp = taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT);
|
||||
if (pTable->keyType == SDB_KEY_STRING || pTable->keyType == SDB_KEY_VAR_STRING) {
|
||||
|
@ -918,8 +918,8 @@ void *sdbOpenTable(SSdbTableDesc *pDesc) {
|
|||
}
|
||||
pTable->iHandle = taosHashInit(pTable->hashSessions, hashFp, true, true);
|
||||
|
||||
tsSdbObj.numOfTables++;
|
||||
tsSdbObj.tableList[pTable->tableId] = pTable;
|
||||
tsSdbMgmt.numOfTables++;
|
||||
tsSdbMgmt.tableList[pTable->tableId] = pTable;
|
||||
return pTable;
|
||||
}
|
||||
|
||||
|
@ -927,8 +927,8 @@ void sdbCloseTable(void *handle) {
|
|||
SSdbTable *pTable = (SSdbTable *)handle;
|
||||
if (pTable == NULL) return;
|
||||
|
||||
tsSdbObj.numOfTables--;
|
||||
tsSdbObj.tableList[pTable->tableId] = NULL;
|
||||
tsSdbMgmt.numOfTables--;
|
||||
tsSdbMgmt.tableList[pTable->tableId] = NULL;
|
||||
|
||||
SHashMutableIterator *pIter = taosHashCreateIter(pTable->iHandle);
|
||||
while (taosHashIterNext(pIter)) {
|
||||
|
@ -936,7 +936,7 @@ void sdbCloseTable(void *handle) {
|
|||
if (ppRow == NULL) continue;
|
||||
|
||||
SSWriteMsg wmsg = {
|
||||
.pObj = *ppRow,
|
||||
.pRow = *ppRow,
|
||||
.pTable = pTable,
|
||||
};
|
||||
|
||||
|
@ -947,7 +947,7 @@ void sdbCloseTable(void *handle) {
|
|||
taosHashCleanup(pTable->iHandle);
|
||||
pthread_mutex_destroy(&pTable->mutex);
|
||||
|
||||
sdbDebug("vgId:1, sdb:%s, is closed, numOfTables:%d", pTable->tableName, tsSdbObj.numOfTables);
|
||||
sdbDebug("vgId:1, sdb:%s, is closed, numOfTables:%d", pTable->tableName, tsSdbMgmt.numOfTables);
|
||||
free(pTable);
|
||||
}
|
||||
|
||||
|
@ -1072,7 +1072,7 @@ static void *sdbWorkerFp(void *pWorker) {
|
|||
pHead = (void *)pWrite + sizeof(SSWriteMsg) + SDB_SYNC_HACK;
|
||||
if (pWrite->pMsg != NULL) {
|
||||
sdbDebug("vgId:1, ahandle:%p msg:%p, sdb:%s key:%p:%s hver:%" PRIu64 ", will be processed in sdb queue",
|
||||
pWrite->pMsg->rpcMsg.ahandle, pWrite->pMsg, pWrite->pTable->tableName, pWrite->pObj,
|
||||
pWrite->pMsg->rpcMsg.ahandle, pWrite->pMsg, pWrite->pTable->tableName, pWrite->pRow,
|
||||
sdbGetKeyStr(pWrite->pTable, pHead->cont), pHead->version);
|
||||
}
|
||||
} else {
|
||||
|
@ -1089,7 +1089,7 @@ static void *sdbWorkerFp(void *pWorker) {
|
|||
}
|
||||
}
|
||||
|
||||
walFsync(tsSdbObj.wal, true);
|
||||
walFsync(tsSdbMgmt.wal, true);
|
||||
|
||||
// browse all items, and process them one by one
|
||||
taosResetQitems(tsSdbWQall);
|
||||
|
@ -1101,7 +1101,7 @@ static void *sdbWorkerFp(void *pWorker) {
|
|||
sdbConfirmForward(NULL, pWrite, pWrite->retCode);
|
||||
} else if (qtype == TAOS_QTYPE_FWD) {
|
||||
pHead = (SWalHead *)item;
|
||||
syncConfirmForward(tsSdbObj.sync, pHead->version, pHead->len);
|
||||
syncConfirmForward(tsSdbMgmt.sync, pHead->version, pHead->len);
|
||||
taosFreeQitem(item);
|
||||
} else {
|
||||
taosFreeQitem(item);
|
||||
|
|
|
@ -100,12 +100,12 @@ static void mnodeDestroyChildTable(SCTableObj *pTable) {
|
|||
}
|
||||
|
||||
static int32_t mnodeChildTableActionDestroy(SSWriteMsg *pWMsg) {
|
||||
mnodeDestroyChildTable(pWMsg->pObj);
|
||||
mnodeDestroyChildTable(pWMsg->pRow);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t mnodeChildTableActionInsert(SSWriteMsg *pWMsg) {
|
||||
SCTableObj *pTable = pWMsg->pObj;
|
||||
SCTableObj *pTable = pWMsg->pRow;
|
||||
|
||||
SVgObj *pVgroup = mnodeGetVgroup(pTable->vgId);
|
||||
if (pVgroup == NULL) {
|
||||
|
@ -154,7 +154,7 @@ static int32_t mnodeChildTableActionInsert(SSWriteMsg *pWMsg) {
|
|||
}
|
||||
|
||||
static int32_t mnodeChildTableActionDelete(SSWriteMsg *pWMsg) {
|
||||
SCTableObj *pTable = pWMsg->pObj;
|
||||
SCTableObj *pTable = pWMsg->pRow;
|
||||
if (pTable->vgId == 0) {
|
||||
return TSDB_CODE_MND_VGROUP_NOT_EXIST;
|
||||
}
|
||||
|
@ -190,7 +190,7 @@ static int32_t mnodeChildTableActionDelete(SSWriteMsg *pWMsg) {
|
|||
}
|
||||
|
||||
static int32_t mnodeChildTableActionUpdate(SSWriteMsg *pWMsg) {
|
||||
SCTableObj *pNew = pWMsg->pObj;
|
||||
SCTableObj *pNew = pWMsg->pRow;
|
||||
SCTableObj *pTable = mnodeGetChildTable(pNew->info.tableId);
|
||||
if (pTable != pNew) {
|
||||
void *oldTableId = pTable->info.tableId;
|
||||
|
@ -217,7 +217,7 @@ static int32_t mnodeChildTableActionUpdate(SSWriteMsg *pWMsg) {
|
|||
}
|
||||
|
||||
static int32_t mnodeChildTableActionEncode(SSWriteMsg *pWMsg) {
|
||||
SCTableObj *pTable = pWMsg->pObj;
|
||||
SCTableObj *pTable = pWMsg->pRow;
|
||||
assert(pTable != NULL && pWMsg->rowData != NULL);
|
||||
|
||||
int32_t len = strlen(pTable->info.tableId);
|
||||
|
@ -282,7 +282,7 @@ static int32_t mnodeChildTableActionDecode(SSWriteMsg *pWMsg) {
|
|||
}
|
||||
}
|
||||
|
||||
pWMsg->pObj = pTable;
|
||||
pWMsg->pRow = pTable;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -297,7 +297,7 @@ static int32_t mnodeChildTableActionRestored() {
|
|||
SDbObj *pDb = mnodeGetDbByTableId(pTable->info.tableId);
|
||||
if (pDb == NULL || pDb->status != TSDB_DB_STATUS_READY) {
|
||||
mError("ctable:%s, failed to get db or db in dropping, discard it", pTable->info.tableId);
|
||||
SSWriteMsg desc = {.type = SDB_OPER_LOCAL, .pObj = pTable, .pTable = tsChildTableSdb};
|
||||
SSWriteMsg desc = {.type = SDB_OPER_LOCAL, .pRow = pTable, .pTable = tsChildTableSdb};
|
||||
sdbDeleteRow(&desc);
|
||||
mnodeDecTableRef(pTable);
|
||||
mnodeDecDbRef(pDb);
|
||||
|
@ -309,7 +309,7 @@ static int32_t mnodeChildTableActionRestored() {
|
|||
if (pVgroup == NULL) {
|
||||
mError("ctable:%s, failed to get vgId:%d tid:%d, discard it", pTable->info.tableId, pTable->vgId, pTable->tid);
|
||||
pTable->vgId = 0;
|
||||
SSWriteMsg desc = {.type = SDB_OPER_LOCAL, .pObj = pTable, .pTable = tsChildTableSdb};
|
||||
SSWriteMsg desc = {.type = SDB_OPER_LOCAL, .pRow = pTable, .pTable = tsChildTableSdb};
|
||||
sdbDeleteRow(&desc);
|
||||
mnodeDecTableRef(pTable);
|
||||
continue;
|
||||
|
@ -320,7 +320,7 @@ static int32_t mnodeChildTableActionRestored() {
|
|||
mError("ctable:%s, db:%s not match with vgId:%d db:%s sid:%d, discard it",
|
||||
pTable->info.tableId, pDb->name, pTable->vgId, pVgroup->dbName, pTable->tid);
|
||||
pTable->vgId = 0;
|
||||
SSWriteMsg desc = {.type = SDB_OPER_LOCAL, .pObj = pTable, .pTable = tsChildTableSdb};
|
||||
SSWriteMsg desc = {.type = SDB_OPER_LOCAL, .pRow = pTable, .pTable = tsChildTableSdb};
|
||||
sdbDeleteRow(&desc);
|
||||
mnodeDecTableRef(pTable);
|
||||
continue;
|
||||
|
@ -331,7 +331,7 @@ static int32_t mnodeChildTableActionRestored() {
|
|||
if (pSuperTable == NULL) {
|
||||
mError("ctable:%s, stable:%" PRIu64 " not exist", pTable->info.tableId, pTable->suid);
|
||||
pTable->vgId = 0;
|
||||
SSWriteMsg desc = {.type = SDB_OPER_LOCAL, .pObj = pTable, .pTable = tsChildTableSdb};
|
||||
SSWriteMsg desc = {.type = SDB_OPER_LOCAL, .pRow = pTable, .pTable = tsChildTableSdb};
|
||||
sdbDeleteRow(&desc);
|
||||
mnodeDecTableRef(pTable);
|
||||
continue;
|
||||
|
@ -364,7 +364,7 @@ static int32_t mnodeInitChildTables() {
|
|||
.fpEncode = mnodeChildTableActionEncode,
|
||||
.fpDecode = mnodeChildTableActionDecode,
|
||||
.fpDestroy = mnodeChildTableActionDestroy,
|
||||
.fpDestored = mnodeChildTableActionRestored
|
||||
.fpRestored = mnodeChildTableActionRestored
|
||||
};
|
||||
|
||||
tsChildTableSdb = sdbOpenTable(&tableDesc);
|
||||
|
@ -431,12 +431,12 @@ static void mnodeDestroySuperTable(SSTableObj *pStable) {
|
|||
}
|
||||
|
||||
static int32_t mnodeSuperTableActionDestroy(SSWriteMsg *pWMsg) {
|
||||
mnodeDestroySuperTable(pWMsg->pObj);
|
||||
mnodeDestroySuperTable(pWMsg->pRow);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t mnodeSuperTableActionInsert(SSWriteMsg *pWMsg) {
|
||||
SSTableObj *pStable = pWMsg->pObj;
|
||||
SSTableObj *pStable = pWMsg->pRow;
|
||||
SDbObj *pDb = mnodeGetDbByTableId(pStable->info.tableId);
|
||||
if (pDb != NULL && pDb->status == TSDB_DB_STATUS_READY) {
|
||||
mnodeAddSuperTableIntoDb(pDb);
|
||||
|
@ -447,7 +447,7 @@ static int32_t mnodeSuperTableActionInsert(SSWriteMsg *pWMsg) {
|
|||
}
|
||||
|
||||
static int32_t mnodeSuperTableActionDelete(SSWriteMsg *pWMsg) {
|
||||
SSTableObj *pStable = pWMsg->pObj;
|
||||
SSTableObj *pStable = pWMsg->pRow;
|
||||
SDbObj *pDb = mnodeGetDbByTableId(pStable->info.tableId);
|
||||
if (pDb != NULL) {
|
||||
mnodeRemoveSuperTableFromDb(pDb);
|
||||
|
@ -459,7 +459,7 @@ static int32_t mnodeSuperTableActionDelete(SSWriteMsg *pWMsg) {
|
|||
}
|
||||
|
||||
static int32_t mnodeSuperTableActionUpdate(SSWriteMsg *pWMsg) {
|
||||
SSTableObj *pNew = pWMsg->pObj;
|
||||
SSTableObj *pNew = pWMsg->pRow;
|
||||
SSTableObj *pTable = mnodeGetSuperTable(pNew->info.tableId);
|
||||
if (pTable != NULL && pTable != pNew) {
|
||||
void *oldTableId = pTable->info.tableId;
|
||||
|
@ -484,8 +484,8 @@ static int32_t mnodeSuperTableActionUpdate(SSWriteMsg *pWMsg) {
|
|||
}
|
||||
|
||||
static int32_t mnodeSuperTableActionEncode(SSWriteMsg *pWMsg) {
|
||||
SSTableObj *pStable = pWMsg->pObj;
|
||||
assert(pWMsg->pObj != NULL && pWMsg->rowData != NULL);
|
||||
SSTableObj *pStable = pWMsg->pRow;
|
||||
assert(pWMsg->pRow != NULL && pWMsg->rowData != NULL);
|
||||
|
||||
int32_t len = strlen(pStable->info.tableId);
|
||||
if (len >= TSDB_TABLE_FNAME_LEN) len = TSDB_CODE_MND_INVALID_TABLE_ID;
|
||||
|
@ -531,7 +531,7 @@ static int32_t mnodeSuperTableActionDecode(SSWriteMsg *pWMsg) {
|
|||
|
||||
memcpy(pStable->schema, pWMsg->rowData + len, schemaSize);
|
||||
|
||||
pWMsg->pObj = pStable;
|
||||
pWMsg->pRow = pStable;
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -557,7 +557,7 @@ static int32_t mnodeInitSuperTables() {
|
|||
.fpEncode = mnodeSuperTableActionEncode,
|
||||
.fpDecode = mnodeSuperTableActionDecode,
|
||||
.fpDestroy = mnodeSuperTableActionDestroy,
|
||||
.fpDestored = mnodeSuperTableActionRestored
|
||||
.fpRestored = mnodeSuperTableActionRestored
|
||||
};
|
||||
|
||||
tsSuperTableSdb = sdbOpenTable(&tableDesc);
|
||||
|
@ -828,7 +828,7 @@ static int32_t mnodeCreateSuperTableCb(SMnodeMsg *pMsg, int32_t code) {
|
|||
} else {
|
||||
mError("app:%p:%p, stable:%s, failed to create in sdb, reason:%s", pMsg->rpcMsg.ahandle, pMsg, pTable->info.tableId,
|
||||
tstrerror(code));
|
||||
SSWriteMsg desc = {.type = SDB_OPER_GLOBAL, .pObj = pTable, .pTable = tsSuperTableSdb};
|
||||
SSWriteMsg desc = {.type = SDB_OPER_GLOBAL, .pRow = pTable, .pTable = tsSuperTableSdb};
|
||||
sdbDeleteRow(&desc);
|
||||
}
|
||||
|
||||
|
@ -881,7 +881,7 @@ static int32_t mnodeProcessCreateSuperTableMsg(SMnodeMsg *pMsg) {
|
|||
SSWriteMsg wmsg = {
|
||||
.type = SDB_OPER_GLOBAL,
|
||||
.pTable = tsSuperTableSdb,
|
||||
.pObj = pStable,
|
||||
.pRow = pStable,
|
||||
.rowSize = sizeof(SSTableObj) + schemaSize,
|
||||
.pMsg = pMsg,
|
||||
.fpWrite = mnodeCreateSuperTableCb
|
||||
|
@ -940,7 +940,7 @@ static int32_t mnodeProcessDropSuperTableMsg(SMnodeMsg *pMsg) {
|
|||
SSWriteMsg wmsg = {
|
||||
.type = SDB_OPER_GLOBAL,
|
||||
.pTable = tsSuperTableSdb,
|
||||
.pObj = pStable,
|
||||
.pRow = pStable,
|
||||
.pMsg = pMsg,
|
||||
.fpWrite = mnodeDropSuperTableCb
|
||||
};
|
||||
|
@ -1013,7 +1013,7 @@ static int32_t mnodeAddSuperTableTag(SMnodeMsg *pMsg, SSchema schema[], int32_t
|
|||
SSWriteMsg wmsg = {
|
||||
.type = SDB_OPER_GLOBAL,
|
||||
.pTable = tsSuperTableSdb,
|
||||
.pObj = pStable,
|
||||
.pRow = pStable,
|
||||
.pMsg = pMsg,
|
||||
.fpWrite = mnodeAddSuperTableTagCb
|
||||
};
|
||||
|
@ -1047,7 +1047,7 @@ static int32_t mnodeDropSuperTableTag(SMnodeMsg *pMsg, char *tagName) {
|
|||
SSWriteMsg wmsg = {
|
||||
.type = SDB_OPER_GLOBAL,
|
||||
.pTable = tsSuperTableSdb,
|
||||
.pObj = pStable,
|
||||
.pRow = pStable,
|
||||
.pMsg = pMsg,
|
||||
.fpWrite = mnodeDropSuperTableTagCb
|
||||
};
|
||||
|
@ -1091,7 +1091,7 @@ static int32_t mnodeModifySuperTableTagName(SMnodeMsg *pMsg, char *oldTagName, c
|
|||
SSWriteMsg wmsg = {
|
||||
.type = SDB_OPER_GLOBAL,
|
||||
.pTable = tsSuperTableSdb,
|
||||
.pObj = pStable,
|
||||
.pRow = pStable,
|
||||
.pMsg = pMsg,
|
||||
.fpWrite = mnodeModifySuperTableTagNameCb
|
||||
};
|
||||
|
@ -1165,7 +1165,7 @@ static int32_t mnodeAddSuperTableColumn(SMnodeMsg *pMsg, SSchema schema[], int32
|
|||
SSWriteMsg wmsg = {
|
||||
.type = SDB_OPER_GLOBAL,
|
||||
.pTable = tsSuperTableSdb,
|
||||
.pObj = pStable,
|
||||
.pRow = pStable,
|
||||
.pMsg = pMsg,
|
||||
.fpWrite = mnodeAddSuperTableColumnCb
|
||||
};
|
||||
|
@ -1210,7 +1210,7 @@ static int32_t mnodeDropSuperTableColumn(SMnodeMsg *pMsg, char *colName) {
|
|||
SSWriteMsg wmsg = {
|
||||
.type = SDB_OPER_GLOBAL,
|
||||
.pTable = tsSuperTableSdb,
|
||||
.pObj = pStable,
|
||||
.pRow = pStable,
|
||||
.pMsg = pMsg,
|
||||
.fpWrite = mnodeDropSuperTableColumnCb
|
||||
};
|
||||
|
@ -1254,7 +1254,7 @@ static int32_t mnodeChangeSuperTableColumn(SMnodeMsg *pMsg, char *oldName, char
|
|||
SSWriteMsg wmsg = {
|
||||
.type = SDB_OPER_GLOBAL,
|
||||
.pTable = tsSuperTableSdb,
|
||||
.pObj = pStable,
|
||||
.pRow = pStable,
|
||||
.pMsg = pMsg,
|
||||
.fpWrite = mnodeChangeSuperTableColumnCb
|
||||
};
|
||||
|
@ -1420,7 +1420,7 @@ void mnodeDropAllSuperTables(SDbObj *pDropDb) {
|
|||
SSWriteMsg wmsg = {
|
||||
.type = SDB_OPER_LOCAL,
|
||||
.pTable = tsSuperTableSdb,
|
||||
.pObj = pTable,
|
||||
.pRow = pTable,
|
||||
};
|
||||
sdbDeleteRow(&wmsg);
|
||||
numOfTables ++;
|
||||
|
@ -1694,7 +1694,7 @@ static int32_t mnodeDoCreateChildTableCb(SMnodeMsg *pMsg, int32_t code) {
|
|||
} else {
|
||||
mError("app:%p:%p, table:%s, failed to create table sid:%d, uid:%" PRIu64 ", reason:%s", pMsg->rpcMsg.ahandle, pMsg,
|
||||
pTable->info.tableId, pTable->tid, pTable->uid, tstrerror(code));
|
||||
SSWriteMsg desc = {.type = SDB_OPER_GLOBAL, .pObj = pTable, .pTable = tsChildTableSdb};
|
||||
SSWriteMsg desc = {.type = SDB_OPER_GLOBAL, .pRow = pTable, .pTable = tsChildTableSdb};
|
||||
sdbDeleteRow(&desc);
|
||||
return code;
|
||||
}
|
||||
|
@ -1782,7 +1782,7 @@ static int32_t mnodeDoCreateChildTable(SMnodeMsg *pMsg, int32_t tid) {
|
|||
|
||||
SSWriteMsg desc = {
|
||||
.type = SDB_OPER_GLOBAL,
|
||||
.pObj = pTable,
|
||||
.pRow = pTable,
|
||||
.pTable = tsChildTableSdb,
|
||||
.pMsg = pMsg,
|
||||
.fpReq = mnodeDoCreateChildTableFp
|
||||
|
@ -1904,7 +1904,7 @@ static int32_t mnodeProcessDropChildTableMsg(SMnodeMsg *pMsg) {
|
|||
SSWriteMsg wmsg = {
|
||||
.type = SDB_OPER_GLOBAL,
|
||||
.pTable = tsChildTableSdb,
|
||||
.pObj = pTable,
|
||||
.pRow = pTable,
|
||||
.pMsg = pMsg,
|
||||
.fpWrite = mnodeDropChildTableCb
|
||||
};
|
||||
|
@ -2008,7 +2008,7 @@ static int32_t mnodeAddNormalTableColumn(SMnodeMsg *pMsg, SSchema schema[], int3
|
|||
SSWriteMsg wmsg = {
|
||||
.type = SDB_OPER_GLOBAL,
|
||||
.pTable = tsChildTableSdb,
|
||||
.pObj = pTable,
|
||||
.pRow = pTable,
|
||||
.pMsg = pMsg,
|
||||
.fpWrite = mnodeAlterNormalTableColumnCb
|
||||
};
|
||||
|
@ -2041,7 +2041,7 @@ static int32_t mnodeDropNormalTableColumn(SMnodeMsg *pMsg, char *colName) {
|
|||
SSWriteMsg wmsg = {
|
||||
.type = SDB_OPER_GLOBAL,
|
||||
.pTable = tsChildTableSdb,
|
||||
.pObj = pTable,
|
||||
.pRow = pTable,
|
||||
.pMsg = pMsg,
|
||||
.fpWrite = mnodeAlterNormalTableColumnCb
|
||||
};
|
||||
|
@ -2078,7 +2078,7 @@ static int32_t mnodeChangeNormalTableColumn(SMnodeMsg *pMsg, char *oldName, char
|
|||
SSWriteMsg wmsg = {
|
||||
.type = SDB_OPER_GLOBAL,
|
||||
.pTable = tsChildTableSdb,
|
||||
.pObj = pTable,
|
||||
.pRow = pTable,
|
||||
.pMsg = pMsg,
|
||||
.fpWrite = mnodeAlterNormalTableColumnCb
|
||||
};
|
||||
|
@ -2221,7 +2221,7 @@ void mnodeDropAllChildTablesInVgroups(SVgObj *pVgroup) {
|
|||
SSWriteMsg wmsg = {
|
||||
.type = SDB_OPER_LOCAL,
|
||||
.pTable = tsChildTableSdb,
|
||||
.pObj = pTable,
|
||||
.pRow = pTable,
|
||||
};
|
||||
sdbDeleteRow(&wmsg);
|
||||
numOfTables++;
|
||||
|
@ -2254,7 +2254,7 @@ void mnodeDropAllChildTables(SDbObj *pDropDb) {
|
|||
SSWriteMsg wmsg = {
|
||||
.type = SDB_OPER_LOCAL,
|
||||
.pTable = tsChildTableSdb,
|
||||
.pObj = pTable,
|
||||
.pRow = pTable,
|
||||
};
|
||||
sdbDeleteRow(&wmsg);
|
||||
numOfTables++;
|
||||
|
@ -2283,7 +2283,7 @@ static void mnodeDropAllChildTablesInStable(SSTableObj *pStable) {
|
|||
SSWriteMsg wmsg = {
|
||||
.type = SDB_OPER_LOCAL,
|
||||
.pTable = tsChildTableSdb,
|
||||
.pObj = pTable,
|
||||
.pRow = pTable,
|
||||
};
|
||||
sdbDeleteRow(&wmsg);
|
||||
numOfTables++;
|
||||
|
@ -2412,7 +2412,7 @@ static void mnodeProcessCreateChildTableRsp(SRpcMsg *rpcMsg) {
|
|||
if (rpcMsg->code == TSDB_CODE_SUCCESS || rpcMsg->code == TSDB_CODE_TDB_TABLE_ALREADY_EXIST) {
|
||||
SSWriteMsg desc = {
|
||||
.type = SDB_OPER_GLOBAL,
|
||||
.pObj = pTable,
|
||||
.pRow = pTable,
|
||||
.pTable = tsChildTableSdb,
|
||||
.pMsg = mnodeMsg,
|
||||
.fpWrite = mnodeDoCreateChildTableCb
|
||||
|
@ -2440,7 +2440,7 @@ static void mnodeProcessCreateChildTableRsp(SRpcMsg *rpcMsg) {
|
|||
mnodeMsg->rpcMsg.ahandle, mnodeMsg, pTable->info.tableId, pTable->vgId, pTable->tid, pTable->uid,
|
||||
tstrerror(rpcMsg->code), mnodeMsg->rpcMsg.handle, mnodeMsg->incomingTs, sec, mnodeMsg->retry);
|
||||
|
||||
SSWriteMsg wmsg = {.type = SDB_OPER_GLOBAL, .pTable = tsChildTableSdb, .pObj = pTable};
|
||||
SSWriteMsg wmsg = {.type = SDB_OPER_GLOBAL, .pTable = tsChildTableSdb, .pRow = pTable};
|
||||
sdbDeleteRow(&wmsg);
|
||||
|
||||
if (rpcMsg->code == TSDB_CODE_APP_NOT_READY) {
|
||||
|
|
|
@ -43,12 +43,12 @@ static int32_t mnodeProcessDropUserMsg(SMnodeMsg *pMsg);
|
|||
static int32_t mnodeProcessAuthMsg(SMnodeMsg *pMsg);
|
||||
|
||||
static int32_t mnodeUserActionDestroy(SSWriteMsg *pWMsg) {
|
||||
tfree(pWMsg->pObj);
|
||||
tfree(pWMsg->pRow);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t mnodeUserActionInsert(SSWriteMsg *pWMsg) {
|
||||
SUserObj *pUser = pWMsg->pObj;
|
||||
SUserObj *pUser = pWMsg->pRow;
|
||||
SAcctObj *pAcct = mnodeGetAcct(pUser->acct);
|
||||
|
||||
if (pAcct != NULL) {
|
||||
|
@ -63,7 +63,7 @@ static int32_t mnodeUserActionInsert(SSWriteMsg *pWMsg) {
|
|||
}
|
||||
|
||||
static int32_t mnodeUserActionDelete(SSWriteMsg *pWMsg) {
|
||||
SUserObj *pUser = pWMsg->pObj;
|
||||
SUserObj *pUser = pWMsg->pRow;
|
||||
SAcctObj *pAcct = mnodeGetAcct(pUser->acct);
|
||||
|
||||
if (pAcct != NULL) {
|
||||
|
@ -75,7 +75,7 @@ static int32_t mnodeUserActionDelete(SSWriteMsg *pWMsg) {
|
|||
}
|
||||
|
||||
static int32_t mnodeUserActionUpdate(SSWriteMsg *pWMsg) {
|
||||
SUserObj *pUser = pWMsg->pObj;
|
||||
SUserObj *pUser = pWMsg->pRow;
|
||||
SUserObj *pSaved = mnodeGetUser(pUser->user);
|
||||
if (pUser != pSaved) {
|
||||
memcpy(pSaved, pUser, tsUserUpdateSize);
|
||||
|
@ -86,7 +86,7 @@ static int32_t mnodeUserActionUpdate(SSWriteMsg *pWMsg) {
|
|||
}
|
||||
|
||||
static int32_t mnodeUserActionEncode(SSWriteMsg *pWMsg) {
|
||||
SUserObj *pUser = pWMsg->pObj;
|
||||
SUserObj *pUser = pWMsg->pRow;
|
||||
memcpy(pWMsg->rowData, pUser, tsUserUpdateSize);
|
||||
pWMsg->rowSize = tsUserUpdateSize;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -97,7 +97,7 @@ static int32_t mnodeUserActionDecode(SSWriteMsg *pWMsg) {
|
|||
if (pUser == NULL) return TSDB_CODE_MND_OUT_OF_MEMORY;
|
||||
|
||||
memcpy(pUser, pWMsg->rowData, tsUserUpdateSize);
|
||||
pWMsg->pObj = pUser;
|
||||
pWMsg->pRow = pUser;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -163,7 +163,7 @@ int32_t mnodeInitUsers() {
|
|||
.fpEncode = mnodeUserActionEncode,
|
||||
.fpDecode = mnodeUserActionDecode,
|
||||
.fpDestroy = mnodeUserActionDestroy,
|
||||
.fpDestored = mnodeUserActionRestored
|
||||
.fpRestored = mnodeUserActionRestored
|
||||
};
|
||||
|
||||
tsUserSdb = sdbOpenTable(&tableDesc);
|
||||
|
@ -208,7 +208,7 @@ static int32_t mnodeUpdateUser(SUserObj *pUser, void *pMsg) {
|
|||
SSWriteMsg wmsg = {
|
||||
.type = SDB_OPER_GLOBAL,
|
||||
.pTable = tsUserSdb,
|
||||
.pObj = pUser,
|
||||
.pRow = pUser,
|
||||
.pMsg = pMsg
|
||||
};
|
||||
|
||||
|
@ -262,7 +262,7 @@ int32_t mnodeCreateUser(SAcctObj *pAcct, char *name, char *pass, void *pMsg) {
|
|||
SSWriteMsg wmsg = {
|
||||
.type = SDB_OPER_GLOBAL,
|
||||
.pTable = tsUserSdb,
|
||||
.pObj = pUser,
|
||||
.pRow = pUser,
|
||||
.rowSize = sizeof(SUserObj),
|
||||
.pMsg = pMsg
|
||||
};
|
||||
|
@ -282,7 +282,7 @@ static int32_t mnodeDropUser(SUserObj *pUser, void *pMsg) {
|
|||
SSWriteMsg wmsg = {
|
||||
.type = SDB_OPER_GLOBAL,
|
||||
.pTable = tsUserSdb,
|
||||
.pObj = pUser,
|
||||
.pRow = pUser,
|
||||
.pMsg = pMsg
|
||||
};
|
||||
|
||||
|
@ -565,7 +565,7 @@ void mnodeDropAllUsers(SAcctObj *pAcct) {
|
|||
SSWriteMsg wmsg = {
|
||||
.type = SDB_OPER_LOCAL,
|
||||
.pTable = tsUserSdb,
|
||||
.pObj = pUser,
|
||||
.pRow = pUser,
|
||||
};
|
||||
sdbDeleteRow(&wmsg);
|
||||
numOfUsers++;
|
||||
|
|
|
@ -73,12 +73,12 @@ static void mnodeDestroyVgroup(SVgObj *pVgroup) {
|
|||
}
|
||||
|
||||
static int32_t mnodeVgroupActionDestroy(SSWriteMsg *pWMsg) {
|
||||
mnodeDestroyVgroup(pWMsg->pObj);
|
||||
mnodeDestroyVgroup(pWMsg->pRow);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t mnodeVgroupActionInsert(SSWriteMsg *pWMsg) {
|
||||
SVgObj *pVgroup = pWMsg->pObj;
|
||||
SVgObj *pVgroup = pWMsg->pRow;
|
||||
|
||||
// refer to db
|
||||
SDbObj *pDb = mnodeGetDb(pVgroup->dbName);
|
||||
|
@ -116,7 +116,7 @@ static int32_t mnodeVgroupActionInsert(SSWriteMsg *pWMsg) {
|
|||
}
|
||||
|
||||
static int32_t mnodeVgroupActionDelete(SSWriteMsg *pWMsg) {
|
||||
SVgObj *pVgroup = pWMsg->pObj;
|
||||
SVgObj *pVgroup = pWMsg->pRow;
|
||||
|
||||
if (pVgroup->pDb == NULL) {
|
||||
mError("vgId:%d, db:%s is not exist while insert into hash", pVgroup->vgId, pVgroup->dbName);
|
||||
|
@ -138,7 +138,7 @@ static int32_t mnodeVgroupActionDelete(SSWriteMsg *pWMsg) {
|
|||
}
|
||||
|
||||
static int32_t mnodeVgroupActionUpdate(SSWriteMsg *pWMsg) {
|
||||
SVgObj *pNew = pWMsg->pObj;
|
||||
SVgObj *pNew = pWMsg->pRow;
|
||||
SVgObj *pVgroup = mnodeGetVgroup(pNew->vgId);
|
||||
|
||||
if (pVgroup != pNew) {
|
||||
|
@ -177,7 +177,7 @@ static int32_t mnodeVgroupActionUpdate(SSWriteMsg *pWMsg) {
|
|||
}
|
||||
|
||||
static int32_t mnodeVgroupActionEncode(SSWriteMsg *pWMsg) {
|
||||
SVgObj *pVgroup = pWMsg->pObj;
|
||||
SVgObj *pVgroup = pWMsg->pRow;
|
||||
memcpy(pWMsg->rowData, pVgroup, tsVgUpdateSize);
|
||||
SVgObj *pTmpVgroup = pWMsg->rowData;
|
||||
for (int32_t i = 0; i < TSDB_MAX_REPLICA; ++i) {
|
||||
|
@ -194,7 +194,7 @@ static int32_t mnodeVgroupActionDecode(SSWriteMsg *pWMsg) {
|
|||
if (pVgroup == NULL) return TSDB_CODE_MND_OUT_OF_MEMORY;
|
||||
|
||||
memcpy(pVgroup, pWMsg->rowData, tsVgUpdateSize);
|
||||
pWMsg->pObj = pVgroup;
|
||||
pWMsg->pRow = pVgroup;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -219,7 +219,7 @@ int32_t mnodeInitVgroups() {
|
|||
.fpEncode = mnodeVgroupActionEncode,
|
||||
.fpDecode = mnodeVgroupActionDecode,
|
||||
.fpDestroy = mnodeVgroupActionDestroy,
|
||||
.fpDestored = mnodeVgroupActionRestored,
|
||||
.fpRestored = mnodeVgroupActionRestored,
|
||||
};
|
||||
|
||||
tsVgroupSdb = sdbOpenTable(&tableDesc);
|
||||
|
@ -256,7 +256,7 @@ void mnodeUpdateVgroup(SVgObj *pVgroup) {
|
|||
SSWriteMsg wmsg = {
|
||||
.type = SDB_OPER_GLOBAL,
|
||||
.pTable = tsVgroupSdb,
|
||||
.pObj = pVgroup
|
||||
.pRow = pVgroup
|
||||
};
|
||||
|
||||
int32_t code = sdbUpdateRow(&wmsg);
|
||||
|
@ -519,14 +519,14 @@ static int32_t mnodeCreateVgroupCb(SMnodeMsg *pMsg, int32_t code) {
|
|||
if (code != TSDB_CODE_SUCCESS) {
|
||||
mError("app:%p:%p, vgId:%d, failed to create in sdb, reason:%s", pMsg->rpcMsg.ahandle, pMsg, pVgroup->vgId,
|
||||
tstrerror(code));
|
||||
SSWriteMsg desc = {.type = SDB_OPER_GLOBAL, .pObj = pVgroup, .pTable = tsVgroupSdb};
|
||||
SSWriteMsg desc = {.type = SDB_OPER_GLOBAL, .pRow = pVgroup, .pTable = tsVgroupSdb};
|
||||
sdbDeleteRow(&desc);
|
||||
return code;
|
||||
} else {
|
||||
mInfo("app:%p:%p, vgId:%d, is created in sdb, db:%s replica:%d", pMsg->rpcMsg.ahandle, pMsg, pVgroup->vgId,
|
||||
pDb->name, pVgroup->numOfVnodes);
|
||||
pVgroup->status = TAOS_VG_STATUS_READY;
|
||||
SSWriteMsg desc = {.type = SDB_OPER_GLOBAL, .pObj = pVgroup, .pTable = tsVgroupSdb};
|
||||
SSWriteMsg desc = {.type = SDB_OPER_GLOBAL, .pRow = pVgroup, .pTable = tsVgroupSdb};
|
||||
(void)sdbUpdateRow(&desc);
|
||||
|
||||
dnodeReprocessMWriteMsg(pMsg);
|
||||
|
@ -535,7 +535,7 @@ static int32_t mnodeCreateVgroupCb(SMnodeMsg *pMsg, int32_t code) {
|
|||
// mInfo("app:%p:%p, vgId:%d, is created in sdb, db:%s replica:%d", pMsg->rpcMsg.ahandle, pMsg, pVgroup->vgId,
|
||||
// pDb->name, pVgroup->numOfVnodes);
|
||||
// pVgroup->status = TAOS_VG_STATUS_READY;
|
||||
// SSWriteMsg desc = {.type = SDB_OPER_GLOBAL, .pObj = pVgroup, .pTable = tsVgroupSdb};
|
||||
// SSWriteMsg desc = {.type = SDB_OPER_GLOBAL, .pRow = pVgroup, .pTable = tsVgroupSdb};
|
||||
// (void)sdbUpdateRow(&desc);
|
||||
// dnodeReprocessMWriteMsg(pMsg);
|
||||
// return TSDB_CODE_MND_ACTION_IN_PROGRESS;
|
||||
|
@ -574,7 +574,7 @@ int32_t mnodeCreateVgroup(SMnodeMsg *pMsg) {
|
|||
SSWriteMsg wmsg = {
|
||||
.type = SDB_OPER_GLOBAL,
|
||||
.pTable = tsVgroupSdb,
|
||||
.pObj = pVgroup,
|
||||
.pRow = pVgroup,
|
||||
.rowSize = sizeof(SVgObj),
|
||||
.pMsg = pMsg,
|
||||
.fpReq = mnodeCreateVgroupFp
|
||||
|
@ -598,7 +598,7 @@ void mnodeDropVgroup(SVgObj *pVgroup, void *ahandle) {
|
|||
SSWriteMsg wmsg = {
|
||||
.type = SDB_OPER_GLOBAL,
|
||||
.pTable = tsVgroupSdb,
|
||||
.pObj = pVgroup
|
||||
.pRow = pVgroup
|
||||
};
|
||||
sdbDeleteRow(&wmsg);
|
||||
}
|
||||
|
@ -770,7 +770,7 @@ static int32_t mnodeRetrieveVgroups(SShowObj *pShow, char *data, int32_t rows, v
|
|||
SDnodeObj * pDnode = pVgroup->vnodeGid[i].pDnode;
|
||||
const char *role = "NULL";
|
||||
if (pDnode != NULL) {
|
||||
role = mnodeGetMnodeRoleStr(pVgroup->vnodeGid[i].role);
|
||||
role = syncRole[pVgroup->vnodeGid[i].role];
|
||||
}
|
||||
|
||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||
|
@ -960,7 +960,7 @@ static void mnodeProcessCreateVnodeRsp(SRpcMsg *rpcMsg) {
|
|||
SSWriteMsg wmsg = {
|
||||
.type = SDB_OPER_GLOBAL,
|
||||
.pTable = tsVgroupSdb,
|
||||
.pObj = pVgroup,
|
||||
.pRow = pVgroup,
|
||||
.rowSize = sizeof(SVgObj),
|
||||
.pMsg = mnodeMsg,
|
||||
.fpWrite = mnodeCreateVgroupCb
|
||||
|
@ -976,7 +976,7 @@ static void mnodeProcessCreateVnodeRsp(SRpcMsg *rpcMsg) {
|
|||
SSWriteMsg wmsg = {
|
||||
.type = SDB_OPER_GLOBAL,
|
||||
.pTable = tsVgroupSdb,
|
||||
.pObj = pVgroup
|
||||
.pRow = pVgroup
|
||||
};
|
||||
sdbDeleteRow(&wmsg);
|
||||
dnodeSendRpcMWriteRsp(mnodeMsg, mnodeMsg->code);
|
||||
|
@ -1034,7 +1034,7 @@ static void mnodeProcessDropVnodeRsp(SRpcMsg *rpcMsg) {
|
|||
SSWriteMsg wmsg = {
|
||||
.type = SDB_OPER_GLOBAL,
|
||||
.pTable = tsVgroupSdb,
|
||||
.pObj = pVgroup
|
||||
.pRow = pVgroup
|
||||
};
|
||||
int32_t code = sdbDeleteRow(&wmsg);
|
||||
if (code != 0) {
|
||||
|
@ -1087,7 +1087,7 @@ void mnodeDropAllDnodeVgroups(SDnodeObj *pDropDnode) {
|
|||
SSWriteMsg wmsg = {
|
||||
.type = SDB_OPER_LOCAL,
|
||||
.pTable = tsVgroupSdb,
|
||||
.pObj = pVgroup,
|
||||
.pRow = pVgroup,
|
||||
};
|
||||
sdbDeleteRow(&wmsg);
|
||||
numOfVgroups++;
|
||||
|
@ -1138,7 +1138,7 @@ void mnodeDropAllDbVgroups(SDbObj *pDropDb) {
|
|||
SSWriteMsg wmsg = {
|
||||
.type = SDB_OPER_LOCAL,
|
||||
.pTable = tsVgroupSdb,
|
||||
.pObj = pVgroup,
|
||||
.pRow = pVgroup,
|
||||
};
|
||||
sdbDeleteRow(&wmsg);
|
||||
numOfVgroups++;
|
||||
|
|
Loading…
Reference in New Issue