enh: adjust show transcations output
This commit is contained in:
parent
b90f1f246c
commit
56ce7b1baa
|
@ -221,7 +221,7 @@ static const SSysDbTableSchema transSchema[] = {
|
||||||
{.name = "db", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
{.name = "db", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||||
{.name = "failed_times", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
{.name = "failed_times", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||||
{.name = "last_exec_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
{.name = "last_exec_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||||
{.name = "last_error", .bytes = (TSDB_TRANS_ERROR_LEN - 1) + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
{.name = "last_action_info", .bytes = (TSDB_TRANS_ERROR_LEN - 1) + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||||
};
|
};
|
||||||
|
|
||||||
static const SSysDbTableSchema configSchema[] = {
|
static const SSysDbTableSchema configSchema[] = {
|
||||||
|
|
|
@ -120,10 +120,10 @@ typedef struct {
|
||||||
SArray* commitActions;
|
SArray* commitActions;
|
||||||
int64_t createdTime;
|
int64_t createdTime;
|
||||||
int64_t lastExecTime;
|
int64_t lastExecTime;
|
||||||
int32_t lastErrorAction;
|
int32_t lastAction;
|
||||||
int32_t lastErrorNo;
|
int32_t lastErrorNo;
|
||||||
tmsg_t lastErrorMsgType;
|
tmsg_t lastMsgType;
|
||||||
SEpSet lastErrorEpset;
|
SEpSet lastEpset;
|
||||||
char dbname[TSDB_DB_FNAME_LEN];
|
char dbname[TSDB_DB_FNAME_LEN];
|
||||||
int32_t startFunc;
|
int32_t startFunc;
|
||||||
int32_t stopFunc;
|
int32_t stopFunc;
|
||||||
|
|
|
@ -894,10 +894,19 @@ static int32_t mndTransWriteSingleLog(SMnode *pMnode, STrans *pTrans, STransActi
|
||||||
code = 0;
|
code = 0;
|
||||||
mDebug("trans:%d, %s:%d write to sdb, type:%s status:%s", pTrans->id, mndTransStr(pAction->stage), pAction->id,
|
mDebug("trans:%d, %s:%d write to sdb, type:%s status:%s", pTrans->id, mndTransStr(pAction->stage), pAction->id,
|
||||||
sdbTableName(pAction->pRaw->type), sdbStatusName(pAction->pRaw->status));
|
sdbTableName(pAction->pRaw->type), sdbStatusName(pAction->pRaw->status));
|
||||||
|
|
||||||
|
pTrans->lastAction = pAction->id;
|
||||||
|
pTrans->lastMsgType = pAction->msgType;
|
||||||
|
pTrans->lastEpset = pAction->epSet;
|
||||||
|
pTrans->lastErrorNo = 0;
|
||||||
} else {
|
} else {
|
||||||
pAction->errCode = (terrno != 0) ? terrno : code;
|
pAction->errCode = (terrno != 0) ? terrno : code;
|
||||||
mError("trans:%d, %s:%d failed to write sdb since %s, type:%s status:%s", pTrans->id, mndTransStr(pAction->stage),
|
mError("trans:%d, %s:%d failed to write sdb since %s, type:%s status:%s", pTrans->id, mndTransStr(pAction->stage),
|
||||||
pAction->id, terrstr(), sdbTableName(pAction->pRaw->type), sdbStatusName(pAction->pRaw->status));
|
pAction->id, terrstr(), sdbTableName(pAction->pRaw->type), sdbStatusName(pAction->pRaw->status));
|
||||||
|
pTrans->lastAction = pAction->id;
|
||||||
|
pTrans->lastMsgType = pAction->msgType;
|
||||||
|
pTrans->lastEpset = pAction->epSet;
|
||||||
|
pTrans->lastErrorNo = pAction->errCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
|
@ -933,27 +942,48 @@ static int32_t mndTransSendSingleMsg(SMnode *pMnode, STrans *pTrans, STransActio
|
||||||
pAction->msgReceived = 0;
|
pAction->msgReceived = 0;
|
||||||
pAction->errCode = 0;
|
pAction->errCode = 0;
|
||||||
mDebug("trans:%d, %s:%d is sent, %s", pTrans->id, mndTransStr(pAction->stage), pAction->id, detail);
|
mDebug("trans:%d, %s:%d is sent, %s", pTrans->id, mndTransStr(pAction->stage), pAction->id, detail);
|
||||||
|
|
||||||
|
pTrans->lastAction = pAction->id;
|
||||||
|
pTrans->lastMsgType = pAction->msgType;
|
||||||
|
pTrans->lastEpset = pAction->epSet;
|
||||||
|
if (pTrans->lastErrorNo == 0) {
|
||||||
|
pTrans->lastErrorNo = TSDB_CODE_ACTION_IN_PROGRESS;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
pAction->msgSent = 0;
|
pAction->msgSent = 0;
|
||||||
pAction->msgReceived = 0;
|
pAction->msgReceived = 0;
|
||||||
pAction->errCode = (terrno != 0) ? terrno : code;
|
pAction->errCode = (terrno != 0) ? terrno : code;
|
||||||
mError("trans:%d, %s:%d not send since %s, %s", pTrans->id, mndTransStr(pAction->stage), pAction->id, terrstr(),
|
mError("trans:%d, %s:%d not send since %s, %s", pTrans->id, mndTransStr(pAction->stage), pAction->id, terrstr(),
|
||||||
detail);
|
detail);
|
||||||
|
|
||||||
|
pTrans->lastAction = pAction->id;
|
||||||
|
pTrans->lastMsgType = pAction->msgType;
|
||||||
|
pTrans->lastEpset = pAction->epSet;
|
||||||
|
pTrans->lastErrorNo = pAction->errCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t mndTransExecNullMsg(SMnode *pMnode, STrans *pTrans, STransAction *pAction) {
|
||||||
|
pAction->rawWritten = 0;
|
||||||
|
pAction->errCode = 0;
|
||||||
|
mDebug("trans:%d, %s:%d null action executed", pTrans->id, mndTransStr(pAction->stage), pAction->id);
|
||||||
|
|
||||||
|
pTrans->lastAction = pAction->id;
|
||||||
|
pTrans->lastMsgType = pAction->msgType;
|
||||||
|
pTrans->lastEpset = pAction->epSet;
|
||||||
|
pTrans->lastErrorNo == 0;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t mndTransExecSingleAction(SMnode *pMnode, STrans *pTrans, STransAction *pAction) {
|
static int32_t mndTransExecSingleAction(SMnode *pMnode, STrans *pTrans, STransAction *pAction) {
|
||||||
if (pAction->actionType == TRANS_ACTION_RAW) {
|
if (pAction->actionType == TRANS_ACTION_RAW) {
|
||||||
return mndTransWriteSingleLog(pMnode, pTrans, pAction);
|
return mndTransWriteSingleLog(pMnode, pTrans, pAction);
|
||||||
} else if (pAction->actionType == TRANS_ACTION_MSG) {
|
} else if (pAction->actionType == TRANS_ACTION_MSG) {
|
||||||
return mndTransSendSingleMsg(pMnode, pTrans, pAction);
|
return mndTransSendSingleMsg(pMnode, pTrans, pAction);
|
||||||
} else {
|
} else {
|
||||||
pAction->rawWritten = 0;
|
return mndTransExecNullMsg(pMnode, pTrans, pAction);
|
||||||
pAction->errCode = 0;
|
|
||||||
mDebug("trans:%d, %s:%d null action executed", pTrans->id, mndTransStr(pAction->stage), pAction->id);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -994,19 +1024,19 @@ static int32_t mndTransExecuteActions(SMnode *pMnode, STrans *pTrans, SArray *pA
|
||||||
|
|
||||||
if (numOfExecuted == numOfActions) {
|
if (numOfExecuted == numOfActions) {
|
||||||
if (errCode == 0) {
|
if (errCode == 0) {
|
||||||
pTrans->lastErrorAction = 0;
|
pTrans->lastAction = 0;
|
||||||
pTrans->lastErrorNo = 0;
|
pTrans->lastErrorNo = 0;
|
||||||
pTrans->lastErrorMsgType = 0;
|
pTrans->lastMsgType = 0;
|
||||||
memset(&pTrans->lastErrorEpset, 0, sizeof(pTrans->lastErrorEpset));
|
memset(&pTrans->lastEpset, 0, sizeof(pTrans->lastEpset));
|
||||||
mDebug("trans:%d, all %d actions execute successfully", pTrans->id, numOfActions);
|
mDebug("trans:%d, all %d actions execute successfully", pTrans->id, numOfActions);
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
mError("trans:%d, all %d actions executed, code:0x%x", pTrans->id, numOfActions, errCode & 0XFFFF);
|
mError("trans:%d, all %d actions executed, code:0x%x", pTrans->id, numOfActions, errCode & 0XFFFF);
|
||||||
if (pErrAction != NULL) {
|
if (pErrAction != NULL) {
|
||||||
pTrans->lastErrorMsgType = pErrAction->msgType;
|
pTrans->lastMsgType = pErrAction->msgType;
|
||||||
pTrans->lastErrorAction = pErrAction->id;
|
pTrans->lastAction = pErrAction->id;
|
||||||
pTrans->lastErrorNo = pErrAction->errCode;
|
pTrans->lastErrorNo = pErrAction->errCode;
|
||||||
pTrans->lastErrorEpset = pErrAction->epSet;
|
pTrans->lastEpset = pErrAction->epSet;
|
||||||
}
|
}
|
||||||
mndTransResetActions(pMnode, pTrans, pArray);
|
mndTransResetActions(pMnode, pTrans, pArray);
|
||||||
terrno = errCode;
|
terrno = errCode;
|
||||||
|
@ -1073,15 +1103,15 @@ static int32_t mndTransExecuteRedoActionsSerial(SMnode *pMnode, STrans *pTrans)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (code == 0) {
|
if (code == 0) {
|
||||||
pTrans->lastErrorAction = 0;
|
pTrans->lastAction = 0;
|
||||||
pTrans->lastErrorNo = 0;
|
pTrans->lastErrorNo = 0;
|
||||||
pTrans->lastErrorMsgType = 0;
|
pTrans->lastMsgType = 0;
|
||||||
memset(&pTrans->lastErrorEpset, 0, sizeof(pTrans->lastErrorEpset));
|
memset(&pTrans->lastEpset, 0, sizeof(pTrans->lastEpset));
|
||||||
} else {
|
} else {
|
||||||
pTrans->lastErrorMsgType = pAction->msgType;
|
pTrans->lastMsgType = pAction->msgType;
|
||||||
pTrans->lastErrorAction = action;
|
pTrans->lastAction = action;
|
||||||
pTrans->lastErrorNo = pAction->errCode;
|
pTrans->lastErrorNo = code;
|
||||||
pTrans->lastErrorEpset = pAction->epSet;
|
pTrans->lastEpset = pAction->epSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (code == 0) {
|
if (code == 0) {
|
||||||
|
@ -1432,23 +1462,21 @@ static int32_t mndRetrieveTrans(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBl
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
colDataAppend(pColInfo, numOfRows, (const char *)&pTrans->lastExecTime, false);
|
colDataAppend(pColInfo, numOfRows, (const char *)&pTrans->lastExecTime, false);
|
||||||
|
|
||||||
char lastError[TSDB_TRANS_ERROR_LEN + VARSTR_HEADER_SIZE] = {0};
|
char lastInfo[TSDB_TRANS_ERROR_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||||
char detail[TSDB_TRANS_ERROR_LEN] = {0};
|
char detail[TSDB_TRANS_ERROR_LEN] = {0};
|
||||||
if (pTrans->lastErrorNo != 0) {
|
int32_t len = snprintf(detail, sizeof(detail), "action:%d code:0x%x(%s) ", pTrans->lastAction,
|
||||||
int32_t len = snprintf(detail, sizeof(detail), "action:%d errno:0x%x(%s) ", pTrans->lastErrorAction,
|
pTrans->lastErrorNo & 0xFFFF, tstrerror(pTrans->lastErrorNo));
|
||||||
pTrans->lastErrorNo & 0xFFFF, tstrerror(pTrans->lastErrorNo));
|
SEpSet epset = pTrans->lastEpset;
|
||||||
SEpSet epset = pTrans->lastErrorEpset;
|
if (epset.numOfEps > 0) {
|
||||||
if (epset.numOfEps > 0) {
|
len += snprintf(detail + len, sizeof(detail) - len, "msgType:%s numOfEps:%d inUse:%d ",
|
||||||
len += snprintf(detail + len, sizeof(detail) - len, "msgType:%s numOfEps:%d inUse:%d ",
|
TMSG_INFO(pTrans->lastMsgType), epset.numOfEps, epset.inUse);
|
||||||
TMSG_INFO(pTrans->lastErrorMsgType), epset.numOfEps, epset.inUse);
|
for (int32_t i = 0; i < pTrans->lastEpset.numOfEps; ++i) {
|
||||||
for (int32_t i = 0; i < pTrans->lastErrorEpset.numOfEps; ++i) {
|
len += snprintf(detail + len, sizeof(detail) - len, "ep:%d-%s:%u ", i, epset.eps[i].fqdn, epset.eps[i].port);
|
||||||
len += snprintf(detail + len, sizeof(detail) - len, "ep:%d-%s:%u ", i, epset.eps[i].fqdn, epset.eps[i].port);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
STR_WITH_MAXSIZE_TO_VARSTR(lastError, detail, pShow->pMeta->pSchemas[cols].bytes);
|
STR_WITH_MAXSIZE_TO_VARSTR(lastInfo, detail, pShow->pMeta->pSchemas[cols].bytes);
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
colDataAppend(pColInfo, numOfRows, (const char *)lastError, false);
|
colDataAppend(pColInfo, numOfRows, (const char *)lastInfo, false);
|
||||||
|
|
||||||
numOfRows++;
|
numOfRows++;
|
||||||
sdbRelease(pSdb, pTrans);
|
sdbRelease(pSdb, pTrans);
|
||||||
|
|
|
@ -104,8 +104,7 @@ if $data(5)[4] != ready then
|
||||||
goto step2
|
goto step2
|
||||||
endi
|
endi
|
||||||
|
|
||||||
return
|
print =============== step31: move follower
|
||||||
print =============== step3: move follower
|
|
||||||
$leaderExist = 0
|
$leaderExist = 0
|
||||||
$leaderVnode = 0
|
$leaderVnode = 0
|
||||||
$follower1 = 0
|
$follower1 = 0
|
||||||
|
@ -120,23 +119,23 @@ step3:
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
sql show d1.vgroups
|
sql show d1.vgroups
|
||||||
print ===> $data00 $data01 $data02 $data03 $data04 $data05
|
print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
|
||||||
if $rows != 1 then
|
if $rows != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
if $data(2)[3] == leader then
|
if $data(2)[4] == leader then
|
||||||
$leaderExist = 1
|
$leaderExist = 1
|
||||||
$leaderVnode = 4
|
$leaderVnode = 4
|
||||||
$follower1 = 2
|
$follower1 = 2
|
||||||
$follower2 = 3
|
$follower2 = 3
|
||||||
endi
|
endi
|
||||||
if $data(2)[4] != ready then
|
if $data(2)[6] == leader then
|
||||||
$leaderExist = 1
|
$leaderExist = 1
|
||||||
$leaderVnode = 3
|
$leaderVnode = 3
|
||||||
$follower1 = 2
|
$follower1 = 2
|
||||||
$follower2 = 4
|
$follower2 = 4
|
||||||
endi
|
endi
|
||||||
if $data(3)[4] != ready then
|
if $data(2)[8] == leader then
|
||||||
$leaderExist = 1
|
$leaderExist = 1
|
||||||
$leaderVnode = 2
|
$leaderVnode = 2
|
||||||
$follower1 = 3
|
$follower1 = 3
|
||||||
|
@ -146,8 +145,25 @@ if $leaderExist != 1 then
|
||||||
goto step3
|
goto step3
|
||||||
endi
|
endi
|
||||||
|
|
||||||
print redistribute vgroup 2 dnode $follower1 dnode $follower2 dnode 5
|
print leader $leaderVnode
|
||||||
sql redistribute vgroup 2 dnode $follower1 dnode $follower2 dnode 5
|
print follower1 $follower1
|
||||||
|
print follower2 $follower2
|
||||||
|
|
||||||
|
print =============== step32: move follower2
|
||||||
|
print redistribute vgroup 2 dnode $leaderVnode dnode $follower2 dnode 5
|
||||||
|
sql redistribute vgroup 2 dnode $leaderVnode dnode $follower2 dnode 5
|
||||||
|
return
|
||||||
|
print =============== step33: move follower1
|
||||||
|
print redistribute vgroup 2 dnode $leaderVnode dnode $follower1 dnode 5
|
||||||
|
sql redistribute vgroup 2 dnode $leaderVnode dnode $follower1 dnode 5
|
||||||
|
|
||||||
|
print =============== step34: move follower2
|
||||||
|
print redistribute vgroup 2 dnode $leaderVnode dnode 5 dnode $follower2
|
||||||
|
sql redistribute vgroup 2 dnode $leaderVnode dnode 5 dnode $follower2
|
||||||
|
|
||||||
|
print =============== step35: move follower1
|
||||||
|
print redistribute vgroup 2 dnode $leaderVnode dnode 5 dnode $follower1
|
||||||
|
sql redistribute vgroup 2 dnode $leaderVnode dnode 5 dnode $follower1
|
||||||
|
|
||||||
print =============== step4: move leader
|
print =============== step4: move leader
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue