Merge branch '3.0' of https://github.com/taosdata/TDengine into fix/sma_for_null
This commit is contained in:
commit
804c281197
|
@ -8,6 +8,9 @@ will automatically add the required columns to ensure that the data written by t
|
||||||
|
|
||||||
The schemaless writing method creates super tables and their corresponding subtables. These are completely indistinguishable from the super tables and subtables created directly via SQL. You can write data directly to them via SQL statements. Note that the names of tables created by schemaless writing are based on fixed mapping rules for tag values, so they are not explicitly ideographic and they lack readability.
|
The schemaless writing method creates super tables and their corresponding subtables. These are completely indistinguishable from the super tables and subtables created directly via SQL. You can write data directly to them via SQL statements. Note that the names of tables created by schemaless writing are based on fixed mapping rules for tag values, so they are not explicitly ideographic and they lack readability.
|
||||||
|
|
||||||
|
Tips:
|
||||||
|
The schemaless write will automatically create a table. You do not need to create a table manually, or an unknown error may occur.
|
||||||
|
|
||||||
## Schemaless Writing Line Protocol
|
## Schemaless Writing Line Protocol
|
||||||
|
|
||||||
TDengine's schemaless writing line protocol supports InfluxDB's Line Protocol, OpenTSDB's telnet line protocol, and OpenTSDB's JSON format protocol. However, when using these three protocols, you need to specify in the API the standard of the parsing protocol to be used for the input content.
|
TDengine's schemaless writing line protocol supports InfluxDB's Line Protocol, OpenTSDB's telnet line protocol, and OpenTSDB's JSON format protocol. However, when using these three protocols, you need to specify in the API the standard of the parsing protocol to be used for the input content.
|
||||||
|
|
|
@ -8,6 +8,8 @@ description: 'Schemaless 写入方式,可以免于预先创建超级表/子表
|
||||||
|
|
||||||
无模式写入方式建立的超级表及其对应的子表与通过 SQL 直接建立的超级表和子表完全没有区别,你也可以通过,SQL 语句直接向其中写入数据。需要注意的是,通过无模式写入方式建立的表,其表名是基于标签值按照固定的映射规则生成,所以无法明确地进行表意,缺乏可读性。
|
无模式写入方式建立的超级表及其对应的子表与通过 SQL 直接建立的超级表和子表完全没有区别,你也可以通过,SQL 语句直接向其中写入数据。需要注意的是,通过无模式写入方式建立的表,其表名是基于标签值按照固定的映射规则生成,所以无法明确地进行表意,缺乏可读性。
|
||||||
|
|
||||||
|
注意:无模式写入会自动建表,不需要手动建表,手动建表的话可能会出现未知的错误。
|
||||||
|
|
||||||
## 无模式写入行协议
|
## 无模式写入行协议
|
||||||
|
|
||||||
TDengine 的无模式写入的行协议兼容 InfluxDB 的 行协议(Line Protocol)、OpenTSDB 的 telnet 行协议、OpenTSDB 的 JSON 格式协议。但是使用这三种协议的时候,需要在 API 中指定输入内容使用解析协议的标准。
|
TDengine 的无模式写入的行协议兼容 InfluxDB 的 行协议(Line Protocol)、OpenTSDB 的 telnet 行协议、OpenTSDB 的 JSON 格式协议。但是使用这三种协议的时候,需要在 API 中指定输入内容使用解析协议的标准。
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
TDengine is a high-efficient, scalable, high-available distributed time-series database, which makes a lot of optimizations on inserting and querying data, which is far more efficient than normal regular databases. So TDengine can meet the high requirements of IOT and other areas on storing and querying a large amount of data.
|
TDengine is a high-efficient, scalable, high-available distributed time-series database, which makes a lot of optimizations on inserting and querying data, which is far more efficient than normal regular databases. So TDengine can meet the high requirements of IOT and other areas on storing and querying a large amount of data.
|
||||||
|
|
||||||
TDengine will be installed under C:\TDengine, users can modify configuration file C:\TDengine\cfg\taos.cfg, set the log file path or other parameters.
|
TDengine will be installed under C:\TDengine, users can modify configuration file C:\TDengine\cfg\taos.cfg, set the log file path or other parameters.
|
||||||
|
To start/stop TDengine with administrator privileges: sc start/stop taosd
|
||||||
|
To start/stop taosAdapter with administrator privileges: sc start/stop taosadapter
|
||||||
|
Please manually remove C:\TDengine from your system PATH environment after you remove TDengine software.
|
||||||
|
|
|
@ -287,7 +287,7 @@ int32_t vmGetQueueSize(SVnodeMgmt *pMgmt, int32_t vgId, EQueueType qtype) {
|
||||||
vmReleaseVnode(pMgmt, pVnode);
|
vmReleaseVnode(pMgmt, pVnode);
|
||||||
}
|
}
|
||||||
if (size < 0) {
|
if (size < 0) {
|
||||||
dError("vgId:%d, can't get size from queue since %s, qtype:%d", vgId, terrstr(), qtype);
|
dTrace("vgId:%d, can't get size from queue since %s, qtype:%d", vgId, terrstr(), qtype);
|
||||||
size = 0;
|
size = 0;
|
||||||
}
|
}
|
||||||
return size;
|
return size;
|
||||||
|
|
|
@ -508,6 +508,7 @@ int32_t mndScheduleStream(SMnode* pMnode, SStreamObj* pStream) {
|
||||||
qDestroyQueryPlan(pPlan);
|
qDestroyQueryPlan(pPlan);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
sdbRelease(pSdb, pVgroup);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
qDestroyQueryPlan(pPlan);
|
qDestroyQueryPlan(pPlan);
|
||||||
|
|
|
@ -295,6 +295,7 @@ static int32_t mndBuildStreamObjFromCreateReq(SMnode *pMnode, SStreamObj *pObj,
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
pObj->sourceDbUid = pSourceDb->uid;
|
pObj->sourceDbUid = pSourceDb->uid;
|
||||||
|
mndReleaseDb(pMnode, pSourceDb);
|
||||||
|
|
||||||
memcpy(pObj->targetSTbName, pCreate->targetStbFullName, TSDB_TABLE_FNAME_LEN);
|
memcpy(pObj->targetSTbName, pCreate->targetStbFullName, TSDB_TABLE_FNAME_LEN);
|
||||||
|
|
||||||
|
@ -307,6 +308,7 @@ static int32_t mndBuildStreamObjFromCreateReq(SMnode *pMnode, SStreamObj *pObj,
|
||||||
|
|
||||||
pObj->targetStbUid = mndGenerateUid(pObj->targetSTbName, TSDB_TABLE_FNAME_LEN);
|
pObj->targetStbUid = mndGenerateUid(pObj->targetSTbName, TSDB_TABLE_FNAME_LEN);
|
||||||
pObj->targetDbUid = pTargetDb->uid;
|
pObj->targetDbUid = pTargetDb->uid;
|
||||||
|
mndReleaseDb(pMnode, pTargetDb);
|
||||||
|
|
||||||
pObj->sql = pCreate->sql;
|
pObj->sql = pCreate->sql;
|
||||||
pObj->ast = pCreate->ast;
|
pObj->ast = pCreate->ast;
|
||||||
|
@ -523,6 +525,7 @@ static int32_t mndCreateStbForStream(SMnode *pMnode, STrans *pTrans, const SStre
|
||||||
|
|
||||||
tFreeSMCreateStbReq(&createReq);
|
tFreeSMCreateStbReq(&createReq);
|
||||||
mndFreeStb(&stbObj);
|
mndFreeStb(&stbObj);
|
||||||
|
mndReleaseDb(pMnode, pDb);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
_OVER:
|
_OVER:
|
||||||
|
|
|
@ -996,7 +996,7 @@ static int32_t mndRetrieveSubscribe(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
colDataAppend(pColInfo, numOfRows, (const char *)&pConsumerEp->consumerId, false);
|
colDataAppend(pColInfo, numOfRows, (const char *)&pConsumerEp->consumerId, false);
|
||||||
|
|
||||||
mDebug("mnd show subscrptions: topic %s, consumer %" PRId64 "cgroup %s vgid %d", varDataVal(topic),
|
mDebug("mnd show subscriptions: topic %s, consumer %" PRId64 " cgroup %s vgid %d", varDataVal(topic),
|
||||||
pConsumerEp->consumerId, varDataVal(cgroup), pVgEp->vgId);
|
pConsumerEp->consumerId, varDataVal(cgroup), pVgEp->vgId);
|
||||||
|
|
||||||
// offset
|
// offset
|
||||||
|
@ -1044,7 +1044,7 @@ static int32_t mndRetrieveSubscribe(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
colDataAppend(pColInfo, numOfRows, NULL, true);
|
colDataAppend(pColInfo, numOfRows, NULL, true);
|
||||||
|
|
||||||
mDebug("mnd show subscrptions(unassigned): topic %s, cgroup %s vgid %d", varDataVal(topic), varDataVal(cgroup),
|
mDebug("mnd show subscriptions(unassigned): topic %s, cgroup %s vgid %d", varDataVal(topic), varDataVal(cgroup),
|
||||||
pVgEp->vgId);
|
pVgEp->vgId);
|
||||||
|
|
||||||
// offset
|
// offset
|
||||||
|
|
|
@ -504,6 +504,7 @@ typedef struct SStreamScanInfo {
|
||||||
STimeWindow updateWin;
|
STimeWindow updateWin;
|
||||||
STimeWindowAggSupp twAggSup;
|
STimeWindowAggSupp twAggSup;
|
||||||
SSDataBlock* pUpdateDataRes;
|
SSDataBlock* pUpdateDataRes;
|
||||||
|
SHashObj* pGroupIdTbNameMap;
|
||||||
// status for tmq
|
// status for tmq
|
||||||
SNodeList* pGroupTags;
|
SNodeList* pGroupTags;
|
||||||
SNode* pTagCond;
|
SNode* pTagCond;
|
||||||
|
@ -893,11 +894,11 @@ int32_t getBufferPgSize(int32_t rowSize, uint32_t* defaultPgsz, uint32_t* defaul
|
||||||
void doDestroyExchangeOperatorInfo(void* param);
|
void doDestroyExchangeOperatorInfo(void* param);
|
||||||
|
|
||||||
void setOperatorCompleted(SOperatorInfo* pOperator);
|
void setOperatorCompleted(SOperatorInfo* pOperator);
|
||||||
void setOperatorInfo(SOperatorInfo* pOperator, const char* name, int32_t type, bool blocking, int32_t status, void* pInfo,
|
void setOperatorInfo(SOperatorInfo* pOperator, const char* name, int32_t type, bool blocking, int32_t status,
|
||||||
SExecTaskInfo* pTaskInfo);
|
void* pInfo, SExecTaskInfo* pTaskInfo);
|
||||||
void doFilter(SSDataBlock* pBlock, SFilterInfo* pFilterInfo, SColMatchInfo* pColMatchInfo);
|
void doFilter(SSDataBlock* pBlock, SFilterInfo* pFilterInfo, SColMatchInfo* pColMatchInfo);
|
||||||
int32_t addTagPseudoColumnData(SReadHandle* pHandle, const SExprInfo* pExpr, int32_t numOfExpr,
|
int32_t addTagPseudoColumnData(SReadHandle* pHandle, const SExprInfo* pExpr, int32_t numOfExpr, SSDataBlock* pBlock,
|
||||||
SSDataBlock* pBlock, int32_t rows, const char* idStr, STableMetaCacheInfo * pCache);
|
int32_t rows, const char* idStr, STableMetaCacheInfo* pCache);
|
||||||
|
|
||||||
void cleanupAggSup(SAggSupporter* pAggSup);
|
void cleanupAggSup(SAggSupporter* pAggSup);
|
||||||
void appendOneRowToDataBlock(SSDataBlock* pBlock, STupleHandle* pTupleHandle);
|
void appendOneRowToDataBlock(SSDataBlock* pBlock, STupleHandle* pTupleHandle);
|
||||||
|
@ -1038,6 +1039,7 @@ void appendOneRowToStreamSpecialBlock(SSDataBlock* pBlock, TSKEY* pStartTs, TSKE
|
||||||
uint64_t* pGp, void* pTbName);
|
uint64_t* pGp, void* pTbName);
|
||||||
void printDataBlock(SSDataBlock* pBlock, const char* flag);
|
void printDataBlock(SSDataBlock* pBlock, const char* flag);
|
||||||
uint64_t calGroupIdByData(SPartitionBySupporter* pParSup, SExprSupp* pExprSup, SSDataBlock* pBlock, int32_t rowId);
|
uint64_t calGroupIdByData(SPartitionBySupporter* pParSup, SExprSupp* pExprSup, SSDataBlock* pBlock, int32_t rowId);
|
||||||
|
void calBlockTbName(SStreamScanInfo* pInfo, SSDataBlock* pBlock);
|
||||||
|
|
||||||
int32_t finalizeResultRows(SDiskbasedBuf* pBuf, SResultRowPosition* resultRowPosition, SExprSupp* pSup,
|
int32_t finalizeResultRows(SDiskbasedBuf* pBuf, SResultRowPosition* resultRowPosition, SExprSupp* pSup,
|
||||||
SSDataBlock* pBlock, SExecTaskInfo* pTaskInfo);
|
SSDataBlock* pBlock, SExecTaskInfo* pTaskInfo);
|
||||||
|
@ -1061,7 +1063,7 @@ int32_t setOutputBuf(SStreamState* pState, STimeWindow* win, SResultRow** pResul
|
||||||
int32_t releaseOutputBuf(SStreamState* pState, SWinKey* pKey, SResultRow* pResult);
|
int32_t releaseOutputBuf(SStreamState* pState, SWinKey* pKey, SResultRow* pResult);
|
||||||
int32_t saveOutputBuf(SStreamState* pState, SWinKey* pKey, SResultRow* pResult, int32_t resSize);
|
int32_t saveOutputBuf(SStreamState* pState, SWinKey* pKey, SResultRow* pResult, int32_t resSize);
|
||||||
void getNextIntervalWindow(SInterval* pInterval, STimeWindow* tw, int32_t order);
|
void getNextIntervalWindow(SInterval* pInterval, STimeWindow* tw, int32_t order);
|
||||||
int32_t qAppendTaskStopInfo(SExecTaskInfo* pTaskInfo, SExchangeOpStopInfo *pInfo);
|
int32_t qAppendTaskStopInfo(SExecTaskInfo* pTaskInfo, SExchangeOpStopInfo* pInfo);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -1515,10 +1515,17 @@ static int32_t generateDeleteResultBlock(SStreamScanInfo* pInfo, SSDataBlock* pS
|
||||||
for (int32_t i = 0; i < pSrcBlock->info.rows; i++) {
|
for (int32_t i = 0; i < pSrcBlock->info.rows; i++) {
|
||||||
uint64_t srcUid = srcUidData[i];
|
uint64_t srcUid = srcUidData[i];
|
||||||
uint64_t groupId = srcGp[i];
|
uint64_t groupId = srcGp[i];
|
||||||
|
char* tbname[VARSTR_HEADER_SIZE + TSDB_TABLE_NAME_LEN] = {0};
|
||||||
if (groupId == 0) {
|
if (groupId == 0) {
|
||||||
groupId = getGroupIdByData(pInfo, srcUid, srcStartTsCol[i], version);
|
groupId = getGroupIdByData(pInfo, srcUid, srcStartTsCol[i], version);
|
||||||
}
|
}
|
||||||
appendOneRowToStreamSpecialBlock(pDestBlock, srcStartTsCol + i, srcEndTsCol + i, srcUidData + i, &groupId, NULL);
|
if (pInfo->tbnameCalSup.pExprInfo) {
|
||||||
|
char* parTbname = taosHashGet(pInfo->pGroupIdTbNameMap, &groupId, sizeof(int64_t));
|
||||||
|
memcpy(varDataVal(tbname), parTbname, TSDB_TABLE_NAME_LEN);
|
||||||
|
varDataSetLen(tbname, strlen(varDataVal(tbname)));
|
||||||
|
}
|
||||||
|
appendOneRowToStreamSpecialBlock(pDestBlock, srcStartTsCol + i, srcEndTsCol + i, srcUidData + i, &groupId,
|
||||||
|
tbname[0] == 0 ? NULL : tbname);
|
||||||
}
|
}
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -1562,9 +1569,16 @@ static void calBlockTag(SExprSupp* pTagCalSup, SSDataBlock* pBlock, SSDataBlock*
|
||||||
blockDataDestroy(pSrcBlock);
|
blockDataDestroy(pSrcBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void calBlockTbName(SExprSupp* pTbNameCalSup, SSDataBlock* pBlock) {
|
void calBlockTbName(SStreamScanInfo* pInfo, SSDataBlock* pBlock) {
|
||||||
|
SExprSupp* pTbNameCalSup = &pInfo->tbnameCalSup;
|
||||||
if (pTbNameCalSup == NULL || pTbNameCalSup->numOfExprs == 0) return;
|
if (pTbNameCalSup == NULL || pTbNameCalSup->numOfExprs == 0) return;
|
||||||
if (pBlock == NULL || pBlock->info.rows == 0) return;
|
if (pBlock == NULL || pBlock->info.rows == 0) return;
|
||||||
|
if (pBlock->info.groupId) {
|
||||||
|
char* tbname = taosHashGet(pInfo->pGroupIdTbNameMap, &pBlock->info.groupId, sizeof(int64_t));
|
||||||
|
if (tbname != NULL) {
|
||||||
|
memcpy(pBlock->info.parTbName, tbname, TSDB_TABLE_NAME_LEN);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SSDataBlock* pSrcBlock = blockCopyOneRow(pBlock, 0);
|
SSDataBlock* pSrcBlock = blockCopyOneRow(pBlock, 0);
|
||||||
ASSERT(pSrcBlock->info.rows == 1);
|
ASSERT(pSrcBlock->info.rows == 1);
|
||||||
|
@ -1592,6 +1606,11 @@ static void calBlockTbName(SExprSupp* pTbNameCalSup, SSDataBlock* pBlock) {
|
||||||
pBlock->info.parTbName[0] = 0;
|
pBlock->info.parTbName[0] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pBlock->info.groupId) {
|
||||||
|
taosHashPut(pInfo->pGroupIdTbNameMap, &pBlock->info.groupId, sizeof(int64_t), pBlock->info.parTbName,
|
||||||
|
TSDB_TABLE_NAME_LEN);
|
||||||
|
}
|
||||||
|
|
||||||
blockDataDestroy(pSrcBlock);
|
blockDataDestroy(pSrcBlock);
|
||||||
blockDataDestroy(pResBlock);
|
blockDataDestroy(pResBlock);
|
||||||
}
|
}
|
||||||
|
@ -1713,7 +1732,7 @@ static int32_t setBlockIntoRes(SStreamScanInfo* pInfo, const SSDataBlock* pBlock
|
||||||
blockDataUpdateTsWindow(pInfo->pRes, pInfo->primaryTsIndex);
|
blockDataUpdateTsWindow(pInfo->pRes, pInfo->primaryTsIndex);
|
||||||
blockDataFreeRes((SSDataBlock*)pBlock);
|
blockDataFreeRes((SSDataBlock*)pBlock);
|
||||||
|
|
||||||
calBlockTbName(&pInfo->tbnameCalSup, pInfo->pRes);
|
calBlockTbName(pInfo, pInfo->pRes);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1960,8 +1979,10 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) {
|
||||||
if (pTaskInfo->streamInfo.recoverStep == STREAM_RECOVER_STEP__SCAN) {
|
if (pTaskInfo->streamInfo.recoverStep == STREAM_RECOVER_STEP__SCAN) {
|
||||||
SSDataBlock* pBlock = doTableScan(pInfo->pTableScanOp);
|
SSDataBlock* pBlock = doTableScan(pInfo->pTableScanOp);
|
||||||
if (pBlock != NULL) {
|
if (pBlock != NULL) {
|
||||||
calBlockTbName(&pInfo->tbnameCalSup, pBlock);
|
calBlockTbName(pInfo, pBlock);
|
||||||
|
if (pInfo->pUpdateInfo) {
|
||||||
updateInfoFillBlockData(pInfo->pUpdateInfo, pBlock, pInfo->primaryTsIndex);
|
updateInfoFillBlockData(pInfo->pUpdateInfo, pBlock, pInfo->primaryTsIndex);
|
||||||
|
}
|
||||||
qDebug("stream recover scan get block, rows %d", pBlock->info.rows);
|
qDebug("stream recover scan get block, rows %d", pBlock->info.rows);
|
||||||
return pBlock;
|
return pBlock;
|
||||||
}
|
}
|
||||||
|
@ -2081,7 +2102,7 @@ FETCH_NEXT_BLOCK:
|
||||||
pSDB->info.type = pInfo->scanMode == STREAM_SCAN_FROM_DATAREADER_RANGE ? STREAM_NORMAL : STREAM_PULL_DATA;
|
pSDB->info.type = pInfo->scanMode == STREAM_SCAN_FROM_DATAREADER_RANGE ? STREAM_NORMAL : STREAM_PULL_DATA;
|
||||||
checkUpdateData(pInfo, true, pSDB, false);
|
checkUpdateData(pInfo, true, pSDB, false);
|
||||||
// printDataBlock(pSDB, "stream scan update");
|
// printDataBlock(pSDB, "stream scan update");
|
||||||
calBlockTbName(&pInfo->tbnameCalSup, pSDB);
|
calBlockTbName(pInfo, pSDB);
|
||||||
return pSDB;
|
return pSDB;
|
||||||
}
|
}
|
||||||
blockDataCleanup(pInfo->pUpdateDataRes);
|
blockDataCleanup(pInfo->pUpdateDataRes);
|
||||||
|
@ -2386,6 +2407,7 @@ static void destroyStreamScanOperatorInfo(void* param) {
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanupExprSupp(&pStreamScan->tbnameCalSup);
|
cleanupExprSupp(&pStreamScan->tbnameCalSup);
|
||||||
|
taosHashCleanup(pStreamScan->pGroupIdTbNameMap);
|
||||||
|
|
||||||
updateInfoDestroy(pStreamScan->pUpdateInfo);
|
updateInfoDestroy(pStreamScan->pUpdateInfo);
|
||||||
blockDataDestroy(pStreamScan->pRes);
|
blockDataDestroy(pStreamScan->pRes);
|
||||||
|
@ -2443,6 +2465,8 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys
|
||||||
if (initExprSupp(&pInfo->tbnameCalSup, pSubTableExpr, 1) != 0) {
|
if (initExprSupp(&pInfo->tbnameCalSup, pSubTableExpr, 1) != 0) {
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
pInfo->pGroupIdTbNameMap =
|
||||||
|
taosHashInit(1024, taosGetDefaultHashFunction(TSDB_DATA_TYPE_UBIGINT), false, HASH_NO_LOCK);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pTableScanNode->pTags != NULL) {
|
if (pTableScanNode->pTags != NULL) {
|
||||||
|
|
|
@ -4366,6 +4366,7 @@ static bool getHistogramBinDesc(SHistoFuncInfo* pInfo, char* binDescStr, int8_t
|
||||||
int32_t numOfParams = cJSON_GetArraySize(binDesc);
|
int32_t numOfParams = cJSON_GetArraySize(binDesc);
|
||||||
int32_t startIndex;
|
int32_t startIndex;
|
||||||
if (numOfParams != 4) {
|
if (numOfParams != 4) {
|
||||||
|
cJSON_Delete(binDesc);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4376,15 +4377,18 @@ static bool getHistogramBinDesc(SHistoFuncInfo* pInfo, char* binDescStr, int8_t
|
||||||
cJSON* infinity = cJSON_GetObjectItem(binDesc, "infinity");
|
cJSON* infinity = cJSON_GetObjectItem(binDesc, "infinity");
|
||||||
|
|
||||||
if (!cJSON_IsNumber(start) || !cJSON_IsNumber(count) || !cJSON_IsBool(infinity)) {
|
if (!cJSON_IsNumber(start) || !cJSON_IsNumber(count) || !cJSON_IsBool(infinity)) {
|
||||||
|
cJSON_Delete(binDesc);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count->valueint <= 0 || count->valueint > 1000) { // limit count to 1000
|
if (count->valueint <= 0 || count->valueint > 1000) { // limit count to 1000
|
||||||
|
cJSON_Delete(binDesc);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isinf(start->valuedouble) || (width != NULL && isinf(width->valuedouble)) ||
|
if (isinf(start->valuedouble) || (width != NULL && isinf(width->valuedouble)) ||
|
||||||
(factor != NULL && isinf(factor->valuedouble)) || (count != NULL && isinf(count->valuedouble))) {
|
(factor != NULL && isinf(factor->valuedouble)) || (count != NULL && isinf(count->valuedouble))) {
|
||||||
|
cJSON_Delete(binDesc);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4402,12 +4406,14 @@ static bool getHistogramBinDesc(SHistoFuncInfo* pInfo, char* binDescStr, int8_t
|
||||||
// linear bin process
|
// linear bin process
|
||||||
if (width->valuedouble == 0) {
|
if (width->valuedouble == 0) {
|
||||||
taosMemoryFree(intervals);
|
taosMemoryFree(intervals);
|
||||||
|
cJSON_Delete(binDesc);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < counter + 1; ++i) {
|
for (int i = 0; i < counter + 1; ++i) {
|
||||||
intervals[startIndex] = start->valuedouble + i * width->valuedouble;
|
intervals[startIndex] = start->valuedouble + i * width->valuedouble;
|
||||||
if (isinf(intervals[startIndex])) {
|
if (isinf(intervals[startIndex])) {
|
||||||
taosMemoryFree(intervals);
|
taosMemoryFree(intervals);
|
||||||
|
cJSON_Delete(binDesc);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
startIndex++;
|
startIndex++;
|
||||||
|
@ -4416,22 +4422,26 @@ static bool getHistogramBinDesc(SHistoFuncInfo* pInfo, char* binDescStr, int8_t
|
||||||
// log bin process
|
// log bin process
|
||||||
if (start->valuedouble == 0) {
|
if (start->valuedouble == 0) {
|
||||||
taosMemoryFree(intervals);
|
taosMemoryFree(intervals);
|
||||||
|
cJSON_Delete(binDesc);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (factor->valuedouble < 0 || factor->valuedouble == 0 || factor->valuedouble == 1) {
|
if (factor->valuedouble < 0 || factor->valuedouble == 0 || factor->valuedouble == 1) {
|
||||||
taosMemoryFree(intervals);
|
taosMemoryFree(intervals);
|
||||||
|
cJSON_Delete(binDesc);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < counter + 1; ++i) {
|
for (int i = 0; i < counter + 1; ++i) {
|
||||||
intervals[startIndex] = start->valuedouble * pow(factor->valuedouble, i * 1.0);
|
intervals[startIndex] = start->valuedouble * pow(factor->valuedouble, i * 1.0);
|
||||||
if (isinf(intervals[startIndex])) {
|
if (isinf(intervals[startIndex])) {
|
||||||
taosMemoryFree(intervals);
|
taosMemoryFree(intervals);
|
||||||
|
cJSON_Delete(binDesc);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
startIndex++;
|
startIndex++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
taosMemoryFree(intervals);
|
taosMemoryFree(intervals);
|
||||||
|
cJSON_Delete(binDesc);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4446,6 +4456,7 @@ static bool getHistogramBinDesc(SHistoFuncInfo* pInfo, char* binDescStr, int8_t
|
||||||
}
|
}
|
||||||
} else if (cJSON_IsArray(binDesc)) { /* user input bins */
|
} else if (cJSON_IsArray(binDesc)) { /* user input bins */
|
||||||
if (binType != USER_INPUT_BIN) {
|
if (binType != USER_INPUT_BIN) {
|
||||||
|
cJSON_Delete(binDesc);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
numOfBins = cJSON_GetArraySize(binDesc);
|
numOfBins = cJSON_GetArraySize(binDesc);
|
||||||
|
@ -4453,6 +4464,7 @@ static bool getHistogramBinDesc(SHistoFuncInfo* pInfo, char* binDescStr, int8_t
|
||||||
cJSON* bin = binDesc->child;
|
cJSON* bin = binDesc->child;
|
||||||
if (bin == NULL) {
|
if (bin == NULL) {
|
||||||
taosMemoryFree(intervals);
|
taosMemoryFree(intervals);
|
||||||
|
cJSON_Delete(binDesc);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
@ -4460,16 +4472,19 @@ static bool getHistogramBinDesc(SHistoFuncInfo* pInfo, char* binDescStr, int8_t
|
||||||
intervals[i] = bin->valuedouble;
|
intervals[i] = bin->valuedouble;
|
||||||
if (!cJSON_IsNumber(bin)) {
|
if (!cJSON_IsNumber(bin)) {
|
||||||
taosMemoryFree(intervals);
|
taosMemoryFree(intervals);
|
||||||
|
cJSON_Delete(binDesc);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (i != 0 && intervals[i] <= intervals[i - 1]) {
|
if (i != 0 && intervals[i] <= intervals[i - 1]) {
|
||||||
taosMemoryFree(intervals);
|
taosMemoryFree(intervals);
|
||||||
|
cJSON_Delete(binDesc);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
bin = bin->next;
|
bin = bin->next;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
cJSON_Delete(binDesc);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4482,6 +4497,8 @@ static bool getHistogramBinDesc(SHistoFuncInfo* pInfo, char* binDescStr, int8_t
|
||||||
}
|
}
|
||||||
|
|
||||||
taosMemoryFree(intervals);
|
taosMemoryFree(intervals);
|
||||||
|
cJSON_Delete(binDesc);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4495,18 +4512,23 @@ bool histogramFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultIn
|
||||||
pInfo->totalCount = 0;
|
pInfo->totalCount = 0;
|
||||||
pInfo->normalized = 0;
|
pInfo->normalized = 0;
|
||||||
|
|
||||||
int8_t binType = getHistogramBinType(varDataVal(pCtx->param[1].param.pz));
|
char *binTypeStr = strndup(varDataVal(pCtx->param[1].param.pz), varDataLen(pCtx->param[1].param.pz));
|
||||||
|
int8_t binType = getHistogramBinType(binTypeStr);
|
||||||
|
taosMemoryFree(binTypeStr);
|
||||||
|
|
||||||
if (binType == UNKNOWN_BIN) {
|
if (binType == UNKNOWN_BIN) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
char* binDesc = varDataVal(pCtx->param[2].param.pz);
|
char* binDesc = strndup(varDataVal(pCtx->param[2].param.pz), varDataLen(pCtx->param[2].param.pz));
|
||||||
int64_t normalized = pCtx->param[3].param.i;
|
int64_t normalized = pCtx->param[3].param.i;
|
||||||
if (normalized != 0 && normalized != 1) {
|
if (normalized != 0 && normalized != 1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!getHistogramBinDesc(pInfo, binDesc, binType, (bool)normalized)) {
|
if (!getHistogramBinDesc(pInfo, binDesc, binType, (bool)normalized)) {
|
||||||
|
taosMemoryFree(binDesc);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
taosMemoryFree(binDesc);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2620,6 +2620,7 @@ static bool getHistogramBinDesc(SHistoFuncBin **bins, int32_t *binNum, char *bin
|
||||||
int32_t numOfParams = cJSON_GetArraySize(binDesc);
|
int32_t numOfParams = cJSON_GetArraySize(binDesc);
|
||||||
int32_t startIndex;
|
int32_t startIndex;
|
||||||
if (numOfParams != 4) {
|
if (numOfParams != 4) {
|
||||||
|
cJSON_Delete(binDesc);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2630,15 +2631,18 @@ static bool getHistogramBinDesc(SHistoFuncBin **bins, int32_t *binNum, char *bin
|
||||||
cJSON *infinity = cJSON_GetObjectItem(binDesc, "infinity");
|
cJSON *infinity = cJSON_GetObjectItem(binDesc, "infinity");
|
||||||
|
|
||||||
if (!cJSON_IsNumber(start) || !cJSON_IsNumber(count) || !cJSON_IsBool(infinity)) {
|
if (!cJSON_IsNumber(start) || !cJSON_IsNumber(count) || !cJSON_IsBool(infinity)) {
|
||||||
|
cJSON_Delete(binDesc);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count->valueint <= 0 || count->valueint > 1000) { // limit count to 1000
|
if (count->valueint <= 0 || count->valueint > 1000) { // limit count to 1000
|
||||||
|
cJSON_Delete(binDesc);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isinf(start->valuedouble) || (width != NULL && isinf(width->valuedouble)) ||
|
if (isinf(start->valuedouble) || (width != NULL && isinf(width->valuedouble)) ||
|
||||||
(factor != NULL && isinf(factor->valuedouble)) || (count != NULL && isinf(count->valuedouble))) {
|
(factor != NULL && isinf(factor->valuedouble)) || (count != NULL && isinf(count->valuedouble))) {
|
||||||
|
cJSON_Delete(binDesc);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2656,12 +2660,14 @@ static bool getHistogramBinDesc(SHistoFuncBin **bins, int32_t *binNum, char *bin
|
||||||
// linear bin process
|
// linear bin process
|
||||||
if (width->valuedouble == 0) {
|
if (width->valuedouble == 0) {
|
||||||
taosMemoryFree(intervals);
|
taosMemoryFree(intervals);
|
||||||
|
cJSON_Delete(binDesc);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < counter + 1; ++i) {
|
for (int i = 0; i < counter + 1; ++i) {
|
||||||
intervals[startIndex] = start->valuedouble + i * width->valuedouble;
|
intervals[startIndex] = start->valuedouble + i * width->valuedouble;
|
||||||
if (isinf(intervals[startIndex])) {
|
if (isinf(intervals[startIndex])) {
|
||||||
taosMemoryFree(intervals);
|
taosMemoryFree(intervals);
|
||||||
|
cJSON_Delete(binDesc);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
startIndex++;
|
startIndex++;
|
||||||
|
@ -2670,22 +2676,26 @@ static bool getHistogramBinDesc(SHistoFuncBin **bins, int32_t *binNum, char *bin
|
||||||
// log bin process
|
// log bin process
|
||||||
if (start->valuedouble == 0) {
|
if (start->valuedouble == 0) {
|
||||||
taosMemoryFree(intervals);
|
taosMemoryFree(intervals);
|
||||||
|
cJSON_Delete(binDesc);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (factor->valuedouble < 0 || factor->valuedouble == 0 || factor->valuedouble == 1) {
|
if (factor->valuedouble < 0 || factor->valuedouble == 0 || factor->valuedouble == 1) {
|
||||||
taosMemoryFree(intervals);
|
taosMemoryFree(intervals);
|
||||||
|
cJSON_Delete(binDesc);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < counter + 1; ++i) {
|
for (int i = 0; i < counter + 1; ++i) {
|
||||||
intervals[startIndex] = start->valuedouble * pow(factor->valuedouble, i * 1.0);
|
intervals[startIndex] = start->valuedouble * pow(factor->valuedouble, i * 1.0);
|
||||||
if (isinf(intervals[startIndex])) {
|
if (isinf(intervals[startIndex])) {
|
||||||
taosMemoryFree(intervals);
|
taosMemoryFree(intervals);
|
||||||
|
cJSON_Delete(binDesc);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
startIndex++;
|
startIndex++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
taosMemoryFree(intervals);
|
taosMemoryFree(intervals);
|
||||||
|
cJSON_Delete(binDesc);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2700,6 +2710,7 @@ static bool getHistogramBinDesc(SHistoFuncBin **bins, int32_t *binNum, char *bin
|
||||||
}
|
}
|
||||||
} else if (cJSON_IsArray(binDesc)) { /* user input bins */
|
} else if (cJSON_IsArray(binDesc)) { /* user input bins */
|
||||||
if (binType != USER_INPUT_BIN) {
|
if (binType != USER_INPUT_BIN) {
|
||||||
|
cJSON_Delete(binDesc);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
numOfBins = cJSON_GetArraySize(binDesc);
|
numOfBins = cJSON_GetArraySize(binDesc);
|
||||||
|
@ -2707,6 +2718,7 @@ static bool getHistogramBinDesc(SHistoFuncBin **bins, int32_t *binNum, char *bin
|
||||||
cJSON *bin = binDesc->child;
|
cJSON *bin = binDesc->child;
|
||||||
if (bin == NULL) {
|
if (bin == NULL) {
|
||||||
taosMemoryFree(intervals);
|
taosMemoryFree(intervals);
|
||||||
|
cJSON_Delete(binDesc);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
@ -2714,16 +2726,19 @@ static bool getHistogramBinDesc(SHistoFuncBin **bins, int32_t *binNum, char *bin
|
||||||
intervals[i] = bin->valuedouble;
|
intervals[i] = bin->valuedouble;
|
||||||
if (!cJSON_IsNumber(bin)) {
|
if (!cJSON_IsNumber(bin)) {
|
||||||
taosMemoryFree(intervals);
|
taosMemoryFree(intervals);
|
||||||
|
cJSON_Delete(binDesc);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (i != 0 && intervals[i] <= intervals[i - 1]) {
|
if (i != 0 && intervals[i] <= intervals[i - 1]) {
|
||||||
taosMemoryFree(intervals);
|
taosMemoryFree(intervals);
|
||||||
|
cJSON_Delete(binDesc);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
bin = bin->next;
|
bin = bin->next;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
cJSON_Delete(binDesc);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2735,8 +2750,9 @@ static bool getHistogramBinDesc(SHistoFuncBin **bins, int32_t *binNum, char *bin
|
||||||
(*bins)[i].count = 0;
|
(*bins)[i].count = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
cJSON_Delete(binDesc);
|
|
||||||
taosMemoryFree(intervals);
|
taosMemoryFree(intervals);
|
||||||
|
cJSON_Delete(binDesc);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2748,14 +2764,19 @@ int32_t histogramScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarP
|
||||||
int32_t numOfBins = 0;
|
int32_t numOfBins = 0;
|
||||||
int32_t totalCount = 0;
|
int32_t totalCount = 0;
|
||||||
|
|
||||||
int8_t binType = getHistogramBinType(varDataVal(pInput[1].columnData->pData));
|
char *binTypeStr = strndup(varDataVal(pInput[1].columnData->pData), varDataLen(pInput[1].columnData->pData));
|
||||||
char *binDesc = varDataVal(pInput[2].columnData->pData);
|
int8_t binType = getHistogramBinType(binTypeStr);
|
||||||
|
taosMemoryFree(binTypeStr);
|
||||||
|
|
||||||
|
char *binDesc = strndup(varDataVal(pInput[2].columnData->pData), varDataLen(pInput[2].columnData->pData));
|
||||||
int64_t normalized = *(int64_t *)(pInput[3].columnData->pData);
|
int64_t normalized = *(int64_t *)(pInput[3].columnData->pData);
|
||||||
|
|
||||||
int32_t type = GET_PARAM_TYPE(pInput);
|
int32_t type = GET_PARAM_TYPE(pInput);
|
||||||
if (!getHistogramBinDesc(&bins, &numOfBins, binDesc, binType, (bool)normalized)) {
|
if (!getHistogramBinDesc(&bins, &numOfBins, binDesc, binType, (bool)normalized)) {
|
||||||
|
taosMemoryFree(binDesc);
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
|
taosMemoryFree(binDesc);
|
||||||
|
|
||||||
for (int32_t i = 0; i < pInput->numOfRows; ++i) {
|
for (int32_t i = 0; i < pInput->numOfRows; ++i) {
|
||||||
if (colDataIsNull_s(pInputData, i)) {
|
if (colDataIsNull_s(pInputData, i)) {
|
||||||
|
@ -2785,6 +2806,8 @@ int32_t histogramScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarP
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
colInfoDataEnsureCapacity(pOutputData, numOfBins, false);
|
||||||
|
|
||||||
for (int32_t k = 0; k < numOfBins; ++k) {
|
for (int32_t k = 0; k < numOfBins; ++k) {
|
||||||
int32_t len;
|
int32_t len;
|
||||||
char buf[512] = {0};
|
char buf[512] = {0};
|
||||||
|
|
|
@ -73,11 +73,12 @@ typedef struct SSyncTimer {
|
||||||
SSyncHbTimerData hbData;
|
SSyncHbTimerData hbData;
|
||||||
} SSyncTimer;
|
} SSyncTimer;
|
||||||
|
|
||||||
typedef struct SElectTimer {
|
typedef struct SElectTimerParam {
|
||||||
uint64_t logicClock;
|
uint64_t logicClock;
|
||||||
SSyncNode* pSyncNode;
|
SSyncNode* pSyncNode;
|
||||||
|
int64_t executeTime;
|
||||||
void* pData;
|
void* pData;
|
||||||
} SElectTimer;
|
} SElectTimerParam;
|
||||||
|
|
||||||
typedef struct SPeerState {
|
typedef struct SPeerState {
|
||||||
SyncIndex lastSendIndex;
|
SyncIndex lastSendIndex;
|
||||||
|
@ -153,6 +154,7 @@ typedef struct SSyncNode {
|
||||||
uint64_t electTimerLogicClock;
|
uint64_t electTimerLogicClock;
|
||||||
TAOS_TMR_CALLBACK FpElectTimerCB; // Timer Fp
|
TAOS_TMR_CALLBACK FpElectTimerCB; // Timer Fp
|
||||||
uint64_t electTimerCounter;
|
uint64_t electTimerCounter;
|
||||||
|
SElectTimerParam electTimerParam;
|
||||||
|
|
||||||
// heartbeat timer
|
// heartbeat timer
|
||||||
tmr_h pHeartbeatTimer;
|
tmr_h pHeartbeatTimer;
|
||||||
|
|
|
@ -429,7 +429,7 @@ bool syncIsReadyForRead(int64_t rid) {
|
||||||
|
|
||||||
int32_t syncNodeLeaderTransfer(SSyncNode* pSyncNode) {
|
int32_t syncNodeLeaderTransfer(SSyncNode* pSyncNode) {
|
||||||
if (pSyncNode->peersNum == 0) {
|
if (pSyncNode->peersNum == 0) {
|
||||||
sDebug("only one replica, cannot leader transfer");
|
sDebug("vgId:%d, only one replica, cannot leader transfer", pSyncNode->vgId);
|
||||||
terrno = TSDB_CODE_SYN_ONE_REPLICA;
|
terrno = TSDB_CODE_SYN_ONE_REPLICA;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -445,7 +445,7 @@ int32_t syncNodeLeaderTransfer(SSyncNode* pSyncNode) {
|
||||||
|
|
||||||
int32_t syncNodeLeaderTransferTo(SSyncNode* pSyncNode, SNodeInfo newLeader) {
|
int32_t syncNodeLeaderTransferTo(SSyncNode* pSyncNode, SNodeInfo newLeader) {
|
||||||
if (pSyncNode->replicaNum == 1) {
|
if (pSyncNode->replicaNum == 1) {
|
||||||
sDebug("only one replica, cannot leader transfer");
|
sDebug("vgId:%d, only one replica, cannot leader transfer", pSyncNode->vgId);
|
||||||
terrno = TSDB_CODE_SYN_ONE_REPLICA;
|
terrno = TSDB_CODE_SYN_ONE_REPLICA;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -1104,8 +1104,16 @@ int32_t syncNodeStartElectTimer(SSyncNode* pSyncNode, int32_t ms) {
|
||||||
int32_t ret = 0;
|
int32_t ret = 0;
|
||||||
if (syncIsInit()) {
|
if (syncIsInit()) {
|
||||||
pSyncNode->electTimerMS = ms;
|
pSyncNode->electTimerMS = ms;
|
||||||
|
|
||||||
|
int64_t execTime = taosGetTimestampMs() + ms;
|
||||||
|
atomic_store_64(&(pSyncNode->electTimerParam.executeTime), execTime);
|
||||||
|
atomic_store_64(&(pSyncNode->electTimerParam.logicClock), pSyncNode->electTimerLogicClock);
|
||||||
|
pSyncNode->electTimerParam.pSyncNode = pSyncNode;
|
||||||
|
pSyncNode->electTimerParam.pData = NULL;
|
||||||
|
|
||||||
taosTmrReset(pSyncNode->FpElectTimerCB, pSyncNode->electTimerMS, pSyncNode, syncEnv()->pTimerManager,
|
taosTmrReset(pSyncNode->FpElectTimerCB, pSyncNode->electTimerMS, pSyncNode, syncEnv()->pTimerManager,
|
||||||
&pSyncNode->pElectTimer);
|
&pSyncNode->pElectTimer);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
sError("vgId:%d, start elect timer error, sync env is stop", pSyncNode->vgId);
|
sError("vgId:%d, start elect timer error, sync env is stop", pSyncNode->vgId);
|
||||||
}
|
}
|
||||||
|
@ -1855,27 +1863,35 @@ static void syncNodeEqPingTimer(void* param, void* tmrId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void syncNodeEqElectTimer(void* param, void* tmrId) {
|
static void syncNodeEqElectTimer(void* param, void* tmrId) {
|
||||||
SSyncNode* pNode = param;
|
|
||||||
|
|
||||||
if (!syncIsInit()) return;
|
if (!syncIsInit()) return;
|
||||||
|
|
||||||
|
SSyncNode* pNode = (SSyncNode*)param;
|
||||||
|
|
||||||
if (pNode == NULL) return;
|
if (pNode == NULL) return;
|
||||||
if (pNode->syncEqMsg == NULL) return;
|
if (pNode->syncEqMsg == NULL) return;
|
||||||
|
|
||||||
|
int64_t tsNow = taosGetTimestampMs();
|
||||||
|
if (tsNow < pNode->electTimerParam.executeTime) return;
|
||||||
|
|
||||||
SRpcMsg rpcMsg = {0};
|
SRpcMsg rpcMsg = {0};
|
||||||
int32_t code =
|
int32_t code =
|
||||||
syncBuildTimeout(&rpcMsg, SYNC_TIMEOUT_ELECTION, pNode->electTimerLogicClock, pNode->electTimerMS, pNode);
|
syncBuildTimeout(&rpcMsg, SYNC_TIMEOUT_ELECTION, pNode->electTimerParam.logicClock, pNode->electTimerMS, pNode);
|
||||||
|
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
sError("failed to build elect msg");
|
sError("failed to build elect msg");
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SyncTimeout* pTimeout = rpcMsg.pCont;
|
SyncTimeout* pTimeout = rpcMsg.pCont;
|
||||||
sTrace("enqueue elect msg lc:%" PRId64, pTimeout->logicClock);
|
sNTrace(pNode, "enqueue elect msg lc:%" PRId64, pTimeout->logicClock);
|
||||||
|
|
||||||
code = pNode->syncEqMsg(pNode->msgcb, &rpcMsg);
|
code = pNode->syncEqMsg(pNode->msgcb, &rpcMsg);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
sError("failed to sync enqueue elect msg since %s", terrstr());
|
sError("failed to sync enqueue elect msg since %s", terrstr());
|
||||||
rpcFreeCont(rpcMsg.pCont);
|
rpcFreeCont(rpcMsg.pCont);
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2059,6 +2075,7 @@ int32_t syncNodeOnHeartbeat(SSyncNode* ths, const SRpcMsg* pRpcMsg) {
|
||||||
SyncLocalCmd* pSyncMsg = rpcMsgLocalCmd.pCont;
|
SyncLocalCmd* pSyncMsg = rpcMsgLocalCmd.pCont;
|
||||||
pSyncMsg->cmd = SYNC_LOCAL_CMD_FOLLOWER_CMT;
|
pSyncMsg->cmd = SYNC_LOCAL_CMD_FOLLOWER_CMT;
|
||||||
pSyncMsg->fcIndex = pMsg->commitIndex;
|
pSyncMsg->fcIndex = pMsg->commitIndex;
|
||||||
|
SyncIndex fcIndex = pSyncMsg->fcIndex;
|
||||||
|
|
||||||
if (ths->syncEqMsg != NULL && ths->msgcb != NULL) {
|
if (ths->syncEqMsg != NULL && ths->msgcb != NULL) {
|
||||||
int32_t code = ths->syncEqMsg(ths->msgcb, &rpcMsgLocalCmd);
|
int32_t code = ths->syncEqMsg(ths->msgcb, &rpcMsgLocalCmd);
|
||||||
|
@ -2066,7 +2083,7 @@ int32_t syncNodeOnHeartbeat(SSyncNode* ths, const SRpcMsg* pRpcMsg) {
|
||||||
sError("vgId:%d, sync enqueue fc-commit msg error, code:%d", ths->vgId, code);
|
sError("vgId:%d, sync enqueue fc-commit msg error, code:%d", ths->vgId, code);
|
||||||
rpcFreeCont(rpcMsgLocalCmd.pCont);
|
rpcFreeCont(rpcMsgLocalCmd.pCont);
|
||||||
} else {
|
} else {
|
||||||
sTrace("vgId:%d, sync enqueue fc-commit msg, fc-index:%" PRId64, ths->vgId, pSyncMsg->fcIndex);
|
sTrace("vgId:%d, sync enqueue fc-commit msg, fc-index:%" PRId64, ths->vgId, fcIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -193,7 +193,7 @@ static void syncPeerState2Str(SSyncNode* pSyncNode, char* buf, int32_t bufLen) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void syncPrintNodeLog(const char* flags, ELogLevel level, int32_t dflag, SSyncNode* pNode, const char* format, ...) {
|
void syncPrintNodeLog(const char* flags, ELogLevel level, int32_t dflag, SSyncNode* pNode, const char* format, ...) {
|
||||||
if (pNode == NULL || pNode->pRaftCfg != NULL && pNode->pRaftStore == NULL || pNode->pLogStore == NULL) return;
|
if (pNode == NULL || pNode->pRaftCfg == NULL || pNode->pRaftStore == NULL || pNode->pLogStore == NULL) return;
|
||||||
int64_t currentTerm = pNode->pRaftStore->currentTerm;
|
int64_t currentTerm = pNode->pRaftStore->currentTerm;
|
||||||
|
|
||||||
// save error code, otherwise it will be overwritten
|
// save error code, otherwise it will be overwritten
|
||||||
|
@ -252,7 +252,7 @@ void syncPrintNodeLog(const char* flags, ELogLevel level, int32_t dflag, SSyncNo
|
||||||
void syncPrintSnapshotSenderLog(const char* flags, ELogLevel level, int32_t dflag, SSyncSnapshotSender* pSender,
|
void syncPrintSnapshotSenderLog(const char* flags, ELogLevel level, int32_t dflag, SSyncSnapshotSender* pSender,
|
||||||
const char* format, ...) {
|
const char* format, ...) {
|
||||||
SSyncNode* pNode = pSender->pSyncNode;
|
SSyncNode* pNode = pSender->pSyncNode;
|
||||||
if (pNode == NULL || pNode->pRaftCfg != NULL && pNode->pRaftStore == NULL || pNode->pLogStore == NULL) return;
|
if (pNode == NULL || pNode->pRaftCfg == NULL || pNode->pRaftStore == NULL || pNode->pLogStore == NULL) return;
|
||||||
|
|
||||||
SSnapshot snapshot = {.data = NULL, .lastApplyIndex = -1, .lastApplyTerm = 0};
|
SSnapshot snapshot = {.data = NULL, .lastApplyIndex = -1, .lastApplyTerm = 0};
|
||||||
if (pNode->pFsm != NULL && pNode->pFsm->FpGetSnapshotInfo != NULL) {
|
if (pNode->pFsm != NULL && pNode->pFsm->FpGetSnapshotInfo != NULL) {
|
||||||
|
@ -304,7 +304,7 @@ void syncPrintSnapshotSenderLog(const char* flags, ELogLevel level, int32_t dfla
|
||||||
void syncPrintSnapshotReceiverLog(const char* flags, ELogLevel level, int32_t dflag, SSyncSnapshotReceiver* pReceiver,
|
void syncPrintSnapshotReceiverLog(const char* flags, ELogLevel level, int32_t dflag, SSyncSnapshotReceiver* pReceiver,
|
||||||
const char* format, ...) {
|
const char* format, ...) {
|
||||||
SSyncNode* pNode = pReceiver->pSyncNode;
|
SSyncNode* pNode = pReceiver->pSyncNode;
|
||||||
if (pNode == NULL || pNode->pRaftCfg != NULL && pNode->pRaftStore == NULL || pNode->pLogStore == NULL) return;
|
if (pNode == NULL || pNode->pRaftCfg == NULL || pNode->pRaftStore == NULL || pNode->pLogStore == NULL) return;
|
||||||
|
|
||||||
SSnapshot snapshot = {.data = NULL, .lastApplyIndex = -1, .lastApplyTerm = 0};
|
SSnapshot snapshot = {.data = NULL, .lastApplyIndex = -1, .lastApplyTerm = 0};
|
||||||
if (pNode->pFsm != NULL && pNode->pFsm->FpGetSnapshotInfo != NULL) {
|
if (pNode->pFsm != NULL && pNode->pFsm->FpGetSnapshotInfo != NULL) {
|
||||||
|
|
|
@ -325,10 +325,10 @@ int32_t walEndSnapshot(SWal *pWal) {
|
||||||
SWalFileInfo *pInfo = taosArraySearch(pWal->fileInfoSet, &tmp, compareWalFileInfo, TD_LE);
|
SWalFileInfo *pInfo = taosArraySearch(pWal->fileInfoSet, &tmp, compareWalFileInfo, TD_LE);
|
||||||
if (pInfo) {
|
if (pInfo) {
|
||||||
if (ver >= pInfo->lastVer) {
|
if (ver >= pInfo->lastVer) {
|
||||||
pInfo++;
|
pInfo--;
|
||||||
}
|
}
|
||||||
if (POINTER_DISTANCE(pInfo, pWal->fileInfoSet->pData) > 0) {
|
if (POINTER_DISTANCE(pInfo, pWal->fileInfoSet->pData) > 0) {
|
||||||
wDebug("vgId:%d, wal end remove from %" PRId64, pWal->cfg.vgId, pInfo->firstVer);
|
wDebug("vgId:%d, wal end remove for %" PRId64, pWal->cfg.vgId, pInfo->firstVer);
|
||||||
} else {
|
} else {
|
||||||
wDebug("vgId:%d, wal no remove", pWal->cfg.vgId);
|
wDebug("vgId:%d, wal no remove", pWal->cfg.vgId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,10 +37,10 @@
|
||||||
,,y,script,./test.sh -f tsim/db/taosdlog.sim
|
,,y,script,./test.sh -f tsim/db/taosdlog.sim
|
||||||
,,,script,./test.sh -f tsim/dnode/balance_replica1.sim
|
,,,script,./test.sh -f tsim/dnode/balance_replica1.sim
|
||||||
,,,script,./test.sh -f tsim/dnode/balance_replica3.sim
|
,,,script,./test.sh -f tsim/dnode/balance_replica3.sim
|
||||||
#,,,script,./test.sh -f tsim/dnode/balance1.sim
|
,,,script,./test.sh -f tsim/dnode/balance1.sim
|
||||||
#,,,script,./test.sh -f tsim/dnode/balance2.sim
|
,,,script,./test.sh -f tsim/dnode/balance2.sim
|
||||||
#,,,script,./test.sh -f tsim/dnode/balance3.sim
|
,,,script,./test.sh -f tsim/dnode/balance3.sim
|
||||||
#,,,script,./test.sh -f tsim/dnode/balancex.sim
|
,,,script,./test.sh -f tsim/dnode/balancex.sim
|
||||||
,,y,script,./test.sh -f tsim/dnode/create_dnode.sim
|
,,y,script,./test.sh -f tsim/dnode/create_dnode.sim
|
||||||
,,y,script,./test.sh -f tsim/dnode/drop_dnode_has_mnode.sim
|
,,y,script,./test.sh -f tsim/dnode/drop_dnode_has_mnode.sim
|
||||||
,,y,script,./test.sh -f tsim/dnode/drop_dnode_has_qnode_snode.sim
|
,,y,script,./test.sh -f tsim/dnode/drop_dnode_has_qnode_snode.sim
|
||||||
|
@ -55,7 +55,7 @@
|
||||||
,,,script,./test.sh -f tsim/dnode/redistribute_vgroup_replica3_v1_follower.sim
|
,,,script,./test.sh -f tsim/dnode/redistribute_vgroup_replica3_v1_follower.sim
|
||||||
,,,script,./test.sh -f tsim/dnode/redistribute_vgroup_replica3_v2.sim
|
,,,script,./test.sh -f tsim/dnode/redistribute_vgroup_replica3_v2.sim
|
||||||
,,,script,./test.sh -f tsim/dnode/redistribute_vgroup_replica3_v3.sim
|
,,,script,./test.sh -f tsim/dnode/redistribute_vgroup_replica3_v3.sim
|
||||||
#,,,script,./test.sh -f tsim/dnode/vnode_clean.sim
|
,,,script,./test.sh -f tsim/dnode/vnode_clean.sim
|
||||||
,,,script,./test.sh -f tsim/dnode/use_dropped_dnode.sim
|
,,,script,./test.sh -f tsim/dnode/use_dropped_dnode.sim
|
||||||
,,,script,./test.sh -f tsim/dnode/split_vgroup_replica1.sim
|
,,,script,./test.sh -f tsim/dnode/split_vgroup_replica1.sim
|
||||||
,,,script,./test.sh -f tsim/dnode/split_vgroup_replica3.sim
|
,,,script,./test.sh -f tsim/dnode/split_vgroup_replica3.sim
|
||||||
|
@ -117,7 +117,7 @@
|
||||||
,,y,script,./test.sh -f tsim/parser/fourArithmetic-basic.sim
|
,,y,script,./test.sh -f tsim/parser/fourArithmetic-basic.sim
|
||||||
,,y,script,./test.sh -f tsim/parser/function.sim
|
,,y,script,./test.sh -f tsim/parser/function.sim
|
||||||
,,y,script,./test.sh -f tsim/parser/groupby-basic.sim
|
,,y,script,./test.sh -f tsim/parser/groupby-basic.sim
|
||||||
,,,script,./test.sh -f tsim/parser/groupby.sim
|
,,y,script,./test.sh -f tsim/parser/groupby.sim
|
||||||
,,y,script,./test.sh -f tsim/parser/having_child.sim
|
,,y,script,./test.sh -f tsim/parser/having_child.sim
|
||||||
,,y,script,./test.sh -f tsim/parser/having.sim
|
,,y,script,./test.sh -f tsim/parser/having.sim
|
||||||
,,y,script,./test.sh -f tsim/parser/import_commit1.sim
|
,,y,script,./test.sh -f tsim/parser/import_commit1.sim
|
||||||
|
@ -220,7 +220,7 @@
|
||||||
,,y,script,./test.sh -f tsim/stream/distributeInterval0.sim
|
,,y,script,./test.sh -f tsim/stream/distributeInterval0.sim
|
||||||
,,y,script,./test.sh -f tsim/stream/distributeIntervalRetrive0.sim
|
,,y,script,./test.sh -f tsim/stream/distributeIntervalRetrive0.sim
|
||||||
,,y,script,./test.sh -f tsim/stream/distributeSession0.sim
|
,,y,script,./test.sh -f tsim/stream/distributeSession0.sim
|
||||||
,,,script,./test.sh -f tsim/stream/session0.sim
|
,,y,script,./test.sh -f tsim/stream/session0.sim
|
||||||
,,y,script,./test.sh -f tsim/stream/session1.sim
|
,,y,script,./test.sh -f tsim/stream/session1.sim
|
||||||
,,y,script,./test.sh -f tsim/stream/state0.sim
|
,,y,script,./test.sh -f tsim/stream/state0.sim
|
||||||
,,y,script,./test.sh -f tsim/stream/triggerInterval0.sim
|
,,y,script,./test.sh -f tsim/stream/triggerInterval0.sim
|
||||||
|
@ -296,7 +296,7 @@
|
||||||
,,y,script,./test.sh -f tsim/vnode/replica3_vgroup.sim
|
,,y,script,./test.sh -f tsim/vnode/replica3_vgroup.sim
|
||||||
,,y,script,./test.sh -f tsim/vnode/replica3_many.sim
|
,,y,script,./test.sh -f tsim/vnode/replica3_many.sim
|
||||||
,,y,script,./test.sh -f tsim/vnode/replica3_import.sim
|
,,y,script,./test.sh -f tsim/vnode/replica3_import.sim
|
||||||
#,,,script,./test.sh -f tsim/vnode/stable_balance_replica1.sim
|
,,,script,./test.sh -f tsim/vnode/stable_balance_replica1.sim
|
||||||
,,y,script,./test.sh -f tsim/vnode/stable_dnode2_stop.sim
|
,,y,script,./test.sh -f tsim/vnode/stable_dnode2_stop.sim
|
||||||
,,y,script,./test.sh -f tsim/vnode/stable_dnode2.sim
|
,,y,script,./test.sh -f tsim/vnode/stable_dnode2.sim
|
||||||
,,y,script,./test.sh -f tsim/vnode/stable_dnode3.sim
|
,,y,script,./test.sh -f tsim/vnode/stable_dnode3.sim
|
||||||
|
|
Loading…
Reference in New Issue