feat rename some names.
This commit is contained in:
parent
bdcec392b4
commit
359399f1cd
|
@ -363,7 +363,8 @@ typedef enum ELogicConditionType {
|
||||||
|
|
||||||
#define TSDB_MAX_REPLICA 5
|
#define TSDB_MAX_REPLICA 5
|
||||||
#define TSDB_MAX_LEARNER_REPLICA 10
|
#define TSDB_MAX_LEARNER_REPLICA 10
|
||||||
#define TSDB_SYNC_RESOTRE_lEN 20
|
#define TSDB_SYNC_RESTORE_lEN 20
|
||||||
|
#define TSDB_SYNC_APPLY_COMMIT_LEN 27
|
||||||
#define TSDB_SYNC_LOG_BUFFER_SIZE 4096
|
#define TSDB_SYNC_LOG_BUFFER_SIZE 4096
|
||||||
#define TSDB_SYNC_LOG_BUFFER_RETENTION 256
|
#define TSDB_SYNC_LOG_BUFFER_RETENTION 256
|
||||||
#define TSDB_SYNC_LOG_BUFFER_THRESHOLD (1024 * 1024 * 5)
|
#define TSDB_SYNC_LOG_BUFFER_THRESHOLD (1024 * 1024 * 5)
|
||||||
|
|
|
@ -290,17 +290,17 @@ static const SSysDbTableSchema vgroupsSchema[] = {
|
||||||
{.name = "db_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
{.name = "db_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||||
{.name = "tables", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
{.name = "tables", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
||||||
{.name = "v1_dnode", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT, .sysInfo = true},
|
{.name = "v1_dnode", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT, .sysInfo = true},
|
||||||
{.name = "v1_applied", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
|
||||||
{.name = "v1_status", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
{.name = "v1_status", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||||
|
{.name = "v1_applied/committed", .bytes = TSDB_SYNC_APPLY_COMMIT_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||||
{.name = "v2_dnode", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT, .sysInfo = true},
|
{.name = "v2_dnode", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT, .sysInfo = true},
|
||||||
{.name = "v2_applied", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
|
||||||
{.name = "v2_status", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
{.name = "v2_status", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||||
|
{.name = "v2_applied/committed", .bytes = TSDB_SYNC_APPLY_COMMIT_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||||
{.name = "v3_dnode", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT, .sysInfo = true},
|
{.name = "v3_dnode", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT, .sysInfo = true},
|
||||||
{.name = "v3_applied", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
|
||||||
{.name = "v3_status", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
{.name = "v3_status", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||||
|
{.name = "v3_applied/committed", .bytes = TSDB_SYNC_APPLY_COMMIT_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||||
{.name = "v4_dnode", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT, .sysInfo = true},
|
{.name = "v4_dnode", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT, .sysInfo = true},
|
||||||
{.name = "v4_applied", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
|
||||||
{.name = "v4_status", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
{.name = "v4_status", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||||
|
{.name = "v4_applied/committed", .bytes = TSDB_SYNC_APPLY_COMMIT_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||||
{.name = "cacheload", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
{.name = "cacheload", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
||||||
{.name = "cacheelements", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
{.name = "cacheelements", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
||||||
{.name = "tsma", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT, .sysInfo = true},
|
{.name = "tsma", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT, .sysInfo = true},
|
||||||
|
@ -371,7 +371,7 @@ static const SSysDbTableSchema vnodesSchema[] = {
|
||||||
{.name = "role_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = true},
|
{.name = "role_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = true},
|
||||||
{.name = "start_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = true},
|
{.name = "start_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = true},
|
||||||
{.name = "restored", .bytes = 1, .type = TSDB_DATA_TYPE_BOOL, .sysInfo = true},
|
{.name = "restored", .bytes = 1, .type = TSDB_DATA_TYPE_BOOL, .sysInfo = true},
|
||||||
{.name = "restored_finish", .bytes = TSDB_SYNC_RESOTRE_lEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
{.name = "apply_finish_time", .bytes = TSDB_SYNC_RESTORE_lEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||||
{.name = "unapplied", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
{.name = "unapplied", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -539,7 +539,7 @@ double calcAppliedRate(int64_t currentCount, int64_t lastCount, int64_t currentT
|
||||||
if ((currentTimeMs <= lastTimeMs) || (currentCount <= lastCount)) {
|
if ((currentTimeMs <= lastTimeMs) || (currentCount <= lastCount)) {
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t deltaCount = currentCount - lastCount;
|
int64_t deltaCount = currentCount - lastCount;
|
||||||
int64_t deltaMs = currentTimeMs - lastTimeMs;
|
int64_t deltaMs = currentTimeMs - lastTimeMs;
|
||||||
double rate = (double)deltaCount / (double)deltaMs;
|
double rate = (double)deltaCount / (double)deltaMs;
|
||||||
|
@ -552,7 +552,7 @@ static bool mndUpdateVnodeState(int32_t vgId, SVnodeGid *pGid, SVnodeLoad *pVloa
|
||||||
(pVload->syncTerm != -1 && pGid->syncTerm != pVload->syncTerm) ||
|
(pVload->syncTerm != -1 && pGid->syncTerm != pVload->syncTerm) ||
|
||||||
pGid->roleTimeMs != pVload->roleTimeMs;
|
pGid->roleTimeMs != pVload->roleTimeMs;
|
||||||
|
|
||||||
if (!pVload->syncRestore) {
|
if (pVload->syncCommitIndex > pVload->syncAppliedIndex) {
|
||||||
if (pGid->lastSyncAppliedIndexUpdateTime == 0) {
|
if (pGid->lastSyncAppliedIndexUpdateTime == 0) {
|
||||||
pGid->lastSyncAppliedIndexUpdateTime = taosGetTimestampMs();
|
pGid->lastSyncAppliedIndexUpdateTime = taosGetTimestampMs();
|
||||||
} else if (pGid->syncAppliedIndex != pVload->syncAppliedIndex) {
|
} else if (pGid->syncAppliedIndex != pVload->syncAppliedIndex) {
|
||||||
|
|
|
@ -1067,13 +1067,6 @@ static int32_t mndRetrieveVgroups(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *p
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
|
||||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)&pVgroup->vnodeGid[i].syncAppliedIndex, false);
|
|
||||||
if (code != 0) {
|
|
||||||
mError("vgId:%d, failed to set role, since %s", pVgroup->vgId, tstrerror(code));
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool exist = false;
|
bool exist = false;
|
||||||
bool online = false;
|
bool online = false;
|
||||||
SDnodeObj *pDnode = mndAcquireDnode(pMnode, pVgroup->vnodeGid[i].dnodeId);
|
SDnodeObj *pDnode = mndAcquireDnode(pMnode, pVgroup->vnodeGid[i].dnodeId);
|
||||||
|
@ -1131,6 +1124,19 @@ static int32_t mndRetrieveVgroups(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *p
|
||||||
mError("vgId:%d, failed to set role, since %s", pVgroup->vgId, tstrerror(code));
|
mError("vgId:%d, failed to set role, since %s", pVgroup->vgId, tstrerror(code));
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char applyStr[TSDB_SYNC_APPLY_COMMIT_LEN] = {0};
|
||||||
|
char buf[TSDB_SYNC_APPLY_COMMIT_LEN] = {0};
|
||||||
|
snprintf(applyStr, sizeof(applyStr), "%" PRId64 "/%" PRId64, pVgroup->vnodeGid[i].syncAppliedIndex,
|
||||||
|
pVgroup->vnodeGid[i].syncCommitIndex);
|
||||||
|
STR_WITH_MAXSIZE_TO_VARSTR(buf, applyStr, pShow->pMeta->pSchemas[cols].bytes);
|
||||||
|
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
code = colDataSetVal(pColInfo, numOfRows, (const char *)&buf, false);
|
||||||
|
if (code != 0) {
|
||||||
|
mError("vgId:%d, failed to set role, since %s", pVgroup->vgId, tstrerror(code));
|
||||||
|
return code;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
colDataSetNULL(pColInfo, numOfRows);
|
colDataSetNULL(pColInfo, numOfRows);
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
@ -1348,7 +1354,7 @@ static int32_t mndRetrieveVnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB
|
||||||
int64_t unappliedCount = pGid->syncCommitIndex - pGid->syncAppliedIndex;
|
int64_t unappliedCount = pGid->syncCommitIndex - pGid->syncAppliedIndex;
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
char restoreStr[20] = {0};
|
char restoreStr[20] = {0};
|
||||||
if (!pGid->syncRestore) {
|
if (unappliedCount > 0) {
|
||||||
calculateRstoreFinishTime(pGid->appliedRate, unappliedCount, restoreStr, sizeof(restoreStr));
|
calculateRstoreFinishTime(pGid->appliedRate, unappliedCount, restoreStr, sizeof(restoreStr));
|
||||||
}
|
}
|
||||||
STR_TO_VARSTR(buf, restoreStr);
|
STR_TO_VARSTR(buf, restoreStr);
|
||||||
|
|
Loading…
Reference in New Issue