From 6ff5f373e2b28f2f72e1fe740f505a834f8c14f1 Mon Sep 17 00:00:00 2001 From: slguan Date: Sat, 2 May 2020 13:05:56 +0800 Subject: [PATCH] add some log for sdb --- src/mnode/src/mgmtSdb.c | 23 ++++++++++++++--------- tests/script/unique/mnode/mgmt33.sim | 8 ++++---- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/mnode/src/mgmtSdb.c b/src/mnode/src/mgmtSdb.c index 53b9d2b814..839695a6e5 100644 --- a/src/mnode/src/mgmtSdb.c +++ b/src/mnode/src/mgmtSdb.c @@ -212,15 +212,16 @@ static void sdbNotifyRole(void *ahandle, int8_t role) { static void sdbConfirmForward(void *ahandle, void *param, int32_t code) { tsSdbObj.code = code; - sdbTrace("sdb forward request confirmed, result:%s", tstrerror(code)); sem_post(&tsSdbObj.sem); + sdbTrace("forward request confirmed, version:%" PRIu64 ", result:%s", (int64_t)param, tstrerror(code)); } -static int32_t sdbForwardToPeer(void *pHead) { +static int32_t sdbForwardToPeer(SWalHead *pHead) { if (tsSdbObj.sync == NULL) return TSDB_CODE_SUCCESS; - int32_t code = syncForwardToPeer(tsSdbObj.sync, pHead, NULL); + int32_t code = syncForwardToPeer(tsSdbObj.sync, pHead, (void*)pHead->version); if (code > 0) { + sdbTrace("forward request is sent, version:%" PRIu64 ", result:%s", pHead->version, tstrerror(code)); sem_wait(&tsSdbObj.sem); return tsSdbObj.code; } @@ -332,7 +333,7 @@ void sdbIncRef(void *handle, void *pRow) { SSdbTable *pTable = handle; int32_t * pRefCount = (int32_t *)(pRow + pTable->refCountPos); atomic_add_fetch_32(pRefCount, 1); - if (0 && pTable->tableId == SDB_TABLE_CTABLE) { + if (0 && (pTable->tableId == SDB_TABLE_MNODE || pTable->tableId == SDB_TABLE_DNODE)) { sdbTrace("table:%s, add ref to record:%s:%s:%d", pTable->tableName, pTable->tableName, sdbGetkeyStr(pTable, pRow), *pRefCount); } @@ -344,7 +345,7 @@ void sdbDecRef(void *handle, void *pRow) { SSdbTable *pTable = handle; int32_t * pRefCount = (int32_t *)(pRow + pTable->refCountPos); int32_t refCount = atomic_sub_fetch_32(pRefCount, 1); - if (0 && pTable->tableId == SDB_TABLE_CTABLE) { + if (0 && (pTable->tableId == SDB_TABLE_MNODE || pTable->tableId == SDB_TABLE_DNODE)) { sdbTrace("table:%s, def ref of record:%s:%s:%d", pTable->tableName, pTable->tableName, sdbGetkeyStr(pTable, pRow), *pRefCount); } @@ -474,14 +475,18 @@ static int sdbWrite(void *param, void *data, int type) { } walFsync(tsSdbObj.wal); - sdbForwardToPeer(pHead); + code = sdbForwardToPeer(pHead); pthread_mutex_unlock(&tsSdbObj.mutex); // from app, oper is created - if (param != NULL) return code; - - // from wal or forward msg, should create oper + if (param != NULL) { + //sdbTrace("request from app is disposed, version:%" PRIu64 " code:%s", pHead->version, tstrerror(code)); + return code; + } + + // from wal or forward msg, oper not created, should add into hash if (tsSdbObj.sync != NULL) { + sdbTrace("forward request is received, version:%" PRIu64 " result:%s, confirm it", pHead->version, tstrerror(code)); syncConfirmForward(tsSdbObj.sync, pHead->version, code); } diff --git a/tests/script/unique/mnode/mgmt33.sim b/tests/script/unique/mnode/mgmt33.sim index ef9b0bbcc7..30fae2c243 100644 --- a/tests/script/unique/mnode/mgmt33.sim +++ b/tests/script/unique/mnode/mgmt33.sim @@ -8,7 +8,7 @@ system sh/cfg.sh -n dnode2 -c numOfMPeers -v 3 system sh/cfg.sh -n dnode3 -c numOfMPeers -v 3 print ============== step1 -system sh/exec_up.sh -n dnode1 -s start +system sh/exec_up.sh -n dnode1 -s start -t sql connect sql show mnodes @@ -26,7 +26,7 @@ if $data3_3 != null then endi print ============== step2 -system sh/exec_up.sh -n dnode2 -s start +system sh/exec_up.sh -n dnode2 -s start -t sql create dnode $hostname2 sleep 8000 @@ -49,7 +49,7 @@ if $dnode3Role != null then endi print ============== step3 -system sh/exec_up.sh -n dnode3 -s start +system sh/exec_up.sh -n dnode3 -s start -t sql create dnode $hostname3 sleep 8000 @@ -98,7 +98,7 @@ sleep 3000 system sh/deploy.sh -n dnode2 -i 2 system sh/cfg.sh -n dnode2 -c numOfMPeers -v 3 -system sh/exec_up.sh -n dnode2 -s start +system sh/exec_up.sh -n dnode2 -s start -t print ============== step5 sql create dnode $hostname2 -- GitLab