提交 11e0df78 编写于 作者: C Cary Xu

[TS-953]<enhance>:add specificLogType to control createTable log

上级 2409a9d0
......@@ -211,6 +211,8 @@ extern int32_t wDebugFlag;
extern int32_t cqDebugFlag;
extern int32_t debugFlag;
extern int32_t tsSpecificLogType;
extern int8_t tsClientMerge;
#ifdef TD_TSZ
......@@ -245,6 +247,7 @@ bool taosCheckBalanceCfgOptions(const char *option, int32_t *vnodeId, int32_t
void taosAddDataDir(int index, char *v1, int level, int primary);
void taosReadDataDirCfg(char *v1, char *v2, char *v3);
void taosPrintDataDirCfg();
bool taosPrintCreateTable();
#ifdef __cplusplus
}
......
......@@ -255,6 +255,8 @@ int32_t tsdbDebugFlag = 131;
int32_t cqDebugFlag = 131;
int32_t fsDebugFlag = 135;
int32_t tsSpecificLogType = 0; // show specific log(bit operation): 0x01 create table, 0x02 ...
int8_t tsClientMerge = 0;
#ifdef TD_TSZ
......@@ -1620,6 +1622,16 @@ static void doInitGlobalConfig(void) {
cfg.unitType = TAOS_CFG_UTYPE_NONE;
taosInitConfigOption(cfg);
cfg.option = "specificLogType";
cfg.ptr = &tsSpecificLogType;
cfg.valType = TAOS_CFG_VTYPE_INT32;
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
cfg.minValue = 0;
cfg.maxValue = 2147483647;
cfg.ptrLength = 0;
cfg.unitType = TAOS_CFG_UTYPE_NONE;
taosInitConfigOption(cfg);
#ifdef TD_TSZ
// lossy compress
cfg.option = "lossyColumns";
......@@ -1819,3 +1831,5 @@ bool taosCheckBalanceCfgOptions(const char *option, int32_t *vnodeId, int32_t *d
return true;
}
bool taosPrintCreateTable() { return (tsSpecificLogType & LOG_CREATE_TABLE) ? true : false; }
......@@ -203,9 +203,16 @@ static void *dnodeProcessVWriteQueue(void *wparam) {
bool forceFsync = false;
for (int32_t i = 0; i < numOfMsgs; ++i) {
taosGetQitem(pWorker->qall, &qtype, (void **)&pWrite);
dTrace("msg:%p, app:%p type:%s will be processed in vwrite queue, qtype:%s hver:%" PRIu64, pWrite,
pWrite->rpcMsg.ahandle, taosMsg[pWrite->walHead.msgType], qtypeStr[qtype], pWrite->walHead.version);
if ((pWrite->walHead.msgType == TSDB_MSG_TYPE_MD_CREATE_TABLE) && taosPrintCreateTable()) {
SMDCreateTableMsg *pMsg = (SMDCreateTableMsg *)pWrite->walHead.cont;
dInfo("msg:%p, app:%p type:%s for uid:%" PRIu64 ", tid:%" PRIu32
" will be processed in vwrite queue, qtype:%s hver:%" PRIu64,
pWrite, pWrite->rpcMsg.ahandle, taosMsg[pWrite->walHead.msgType], pMsg ? htobe64(pMsg->uid) : -1,
pMsg ? htonl(pMsg->tid) : -1, qtypeStr[qtype], pWrite->walHead.version);
} else {
dTrace("msg:%p, app:%p type:%s will be processed in vwrite queue, qtype:%s hver:%" PRIu64, pWrite,
pWrite->rpcMsg.ahandle, taosMsg[pWrite->walHead.msgType], qtypeStr[qtype], pWrite->walHead.version);
}
pWrite->code = vnodeProcessWrite(pVnode, &pWrite->walHead, qtype, pWrite);
if (pWrite->code <= 0) atomic_add_fetch_32(&pWrite->processedCount, 1);
if (pWrite->code > 0) pWrite->code = 0;
......
......@@ -451,6 +451,11 @@ typedef enum {
TD_ROW_PARTIAL_UPDATE = 2
} TDUpdateConfig;
typedef enum {
LOG_CREATE_TABLE = 0x01,
// ...
} ESpecificLogType; // bit operation
extern char *qtypeStr[];
#ifdef __cplusplus
......
......@@ -939,9 +939,14 @@ static int32_t mnodeProcessCreateTableMsg(SMnodeMsg *pMsg) {
p->tableName, pMsg->rpcMsg.handle);
return mnodeProcessCreateSuperTableMsg(pMsg);
} else {
mDebug("msg:%p, app:%p table:%s, create ctable msg is received from thandle:%p", pMsg, pMsg->rpcMsg.ahandle,
mDebug("pmsg:%p, app:%p table:%s, create ctable msg is received from thandle:%p", pMsg, pMsg->rpcMsg.ahandle,
p->tableName, pMsg->rpcMsg.handle);
return mnodeProcessCreateChildTableMsg(pMsg);
int32_t code = mnodeProcessCreateChildTableMsg(pMsg);
if (code != TSDB_CODE_MND_ACTION_IN_PROGRESS && code != TSDB_CODE_SUCCESS) {
mError("msg:%p, app:%p table:%s, failed to create ctable for thandle:%p since %s", pMsg, pMsg->rpcMsg.ahandle,
p->tableName, pMsg->rpcMsg.handle, tstrerror(code));
}
return code;
}
}
......@@ -2201,10 +2206,10 @@ static int32_t mnodeDoCreateChildTable(SMnodeMsg *pMsg, int32_t tid) {
int32_t code = sdbInsertRow(&desc);
if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) {
mError("msg:%p, app:%p table:%s, failed to create, vgId:%d sid:%d uid:%" PRIu64 " reason:%s", pMsg,
pMsg->rpcMsg.ahandle, pCreate->tableName, pVgroup->vgId, pTable->tid, pTable->uid, tstrerror(code));
mnodeDestroyChildTable(pTable);
pMsg->pTable = NULL;
mError("msg:%p, app:%p table:%s, failed to create, reason:%s", pMsg, pMsg->rpcMsg.ahandle, pCreate->tableName,
tstrerror(code));
} else {
mDebug("msg:%p, app:%p table:%s, allocated in vgroup, vgId:%d sid:%d uid:%" PRIu64, pMsg, pMsg->rpcMsg.ahandle,
pTable->info.tableId, pVgroup->vgId, pTable->tid, pTable->uid);
......
......@@ -1161,6 +1161,11 @@ static void rpcProcessIncomingMsg(SRpcConn *pConn, SRpcHead *pHead, SRpcReqConte
rpcAddRef(pRpc); // add the refCount for requests
// notify the server app
if ((rpcMsg.msgType == TSDB_MSG_TYPE_MD_CREATE_TABLE) && taosPrintCreateTable()) {
SMDCreateTableMsg *pMsg = (SMDCreateTableMsg *)rpcMsg.pCont;
tInfo("%p, msg:%s received, uid:%" PRIu64 ", tid:%" PRIu32, rpcMsg.ahandle, taosMsg[rpcMsg.msgType],
htobe64(pMsg->uid), htonl(pMsg->tid));
}
(*(pRpc->cfp))(&rpcMsg, NULL);
} else {
// it's a response
......@@ -1348,6 +1353,10 @@ static void rpcSendMsgToPeer(SRpcConn *pConn, void *msg, int msgLen) {
}
//tTrace("connection type is: %d", pConn->connType);
if ((pConn->outType == TSDB_MSG_TYPE_MD_CREATE_TABLE) && taosPrintCreateTable()) {
tInfo("%s, msg:%s is sent to 0x%x:%hu, code:0x%x len:%d sig:0x%08x:0x%08x:%d", pConn->info, taosMsg[pHead->msgType],
pConn->peerIp, pConn->peerPort, htonl(pHead->code), msgLen, pHead->sourceId, pHead->destId, pHead->tranId);
}
writtenLen = (*taosSendData[pConn->connType])(pConn->peerIp, pConn->peerPort, pHead, msgLen, pConn->chandle);
if (writtenLen != msgLen) {
......@@ -1363,6 +1372,7 @@ static void rpcProcessConnError(void *param, void *id) {
SRpcMsg rpcMsg;
if (pRpc == NULL) {
tError("%p, pRpc is NULL", pContext->ahandle);
return;
}
......
......@@ -58,7 +58,7 @@ int tsdbCreateTable(STsdbRepo *repo, STableCfg *pCfg) {
STable * pTable = NULL;
if (tid < 1 || tid > TSDB_MAX_TABLES) {
tsdbError("vgId:%d failed to create table since invalid tid %d", REPO_ID(pRepo), tid);
tsdbError("vgId:%d failed to create table since invalid tid %d uid%" PRIu64, REPO_ID(pRepo), tid, pCfg->tableId.uid);
terrno = TSDB_CODE_TDB_IVD_CREATE_TABLE_INFO;
goto _err;
}
......@@ -942,7 +942,7 @@ static int tsdbAddTableToMeta(STsdbRepo *pRepo, STable *pTable, bool addIdx, boo
}
if (TABLE_TYPE(pTable) == TSDB_CHILD_TABLE && addIdx) { // add STABLE to the index
if (tsdbAddTableIntoIndex(pMeta, pTable, true) < 0) {
tsdbDebug("vgId:%d failed to add table %s to meta while add table to index since %s", REPO_ID(pRepo),
tsdbError("vgId:%d failed to add table %s to meta while add table to index since %s", REPO_ID(pRepo),
TABLE_CHAR_NAME(pTable), tstrerror(terrno));
goto _err;
}
......
......@@ -20,7 +20,7 @@
extern "C" {
#endif
#define TSDB_CFG_MAX_NUM 122
#define TSDB_CFG_MAX_NUM 123
#define TSDB_CFG_PRINT_LEN 23
#define TSDB_CFG_OPTION_LEN 24
#define TSDB_CFG_VALUE_LEN 41
......
......@@ -112,6 +112,10 @@ int32_t vnodeProcessWrite(void *vparam, void *wparam, int32_t qtype, void *rpara
code = (*vnodeProcessWriteMsgFp[pHead->msgType])(pVnode, pHead->cont, pRspRet);
if (code < 0) {
if (syncCode > 0) atomic_sub_fetch_32(&pWrite->processedCount, 1);
vError("app:%p, vgId:%d, hver:%" PRIu64 " vver:%" PRIu64 " msgType:% " PRId8
", code:0x%x, processWrite failed since %s",
pWrite->rpcMsg.ahandle, pVnode->vgId, pHead->version, pVnode->version, pHead->msgType, code,
tstrerror(code));
return code;
}
......@@ -170,17 +174,28 @@ static int32_t vnodeProcessSubmitMsg(SVnodeObj *pVnode, void *pCont, SRspRet *pR
static int32_t vnodeProcessCreateTableMsg(SVnodeObj *pVnode, void *pCont, SRspRet *pRet) {
int code = TSDB_CODE_SUCCESS;
STableCfg *pCfg = tsdbCreateTableCfgFromMsg((SMDCreateTableMsg *)pCont);
SMDCreateTableMsg *pMsg = (SMDCreateTableMsg *)pCont;
STableCfg *pCfg = tsdbCreateTableCfgFromMsg(pMsg);
if (pCfg == NULL) {
ASSERT(terrno != 0);
vError("vgId:%d, uid:%" PRIu64 ", tid:%" PRIu32 ", failed to create tableCfgFromMsg since %s", pVnode->vgId,
htobe64(pMsg->uid), htonl(pMsg->tid), tstrerror(terrno));
return terrno;
}
if (tsdbCreateTable(pVnode->tsdb, pCfg) < 0) {
code = terrno;
vError("vgId:%d, uid:%" PRIu64 ", tid:%" PRIu32 ", failed to create table since %s", pVnode->vgId,
htobe64(pMsg->uid), htonl(pMsg->tid), tstrerror(terrno));
ASSERT(code != 0);
}
if (taosPrintCreateTable()) {
vInfo("vgId:%d, table[%s], uid:%" PRIu64 ", tid:%" PRIu32 " is created successfully", pVnode->vgId,
pMsg->tableFname, htobe64(pMsg->uid), htonl(pMsg->tid));
}
tsdbClearTableCfg(pCfg);
return code;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册