more code format
This commit is contained in:
parent
c4b3da5032
commit
8a033aca5c
|
@ -20,7 +20,6 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -13,18 +13,19 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "tmsg.h"
|
|
||||||
#include "queryInt.h"
|
|
||||||
#include "query.h"
|
#include "query.h"
|
||||||
#include "trpc.h"
|
#include "queryInt.h"
|
||||||
#include "systable.h"
|
#include "systable.h"
|
||||||
|
#include "tmsg.h"
|
||||||
|
#include "trpc.h"
|
||||||
|
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
#ifdef COMPILER_SUPPORTS_CXX13
|
#ifdef COMPILER_SUPPORTS_CXX13
|
||||||
#pragma GCC diagnostic ignored "-Wformat-truncation"
|
#pragma GCC diagnostic ignored "-Wformat-truncation"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int32_t (*queryBuildMsg[TDMT_MAX])(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void*(*mallocFp)(int32_t)) = {0};
|
int32_t (*queryBuildMsg[TDMT_MAX])(void *input, char **msg, int32_t msgSize, int32_t *msgLen,
|
||||||
|
void *(*mallocFp)(int32_t)) = {0};
|
||||||
int32_t (*queryProcessMsgRsp[TDMT_MAX])(void *output, char *msg, int32_t msgSize) = {0};
|
int32_t (*queryProcessMsgRsp[TDMT_MAX])(void *output, char *msg, int32_t msgSize) = {0};
|
||||||
|
|
||||||
int32_t queryBuildUseDbOutput(SUseDbOutput *pOut, SUseDbRsp *usedbRsp) {
|
int32_t queryBuildUseDbOutput(SUseDbOutput *pOut, SUseDbRsp *usedbRsp) {
|
||||||
|
@ -66,7 +67,8 @@ int32_t queryBuildUseDbOutput(SUseDbOutput *pOut, SUseDbRsp *usedbRsp) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t queryBuildTableMetaReqMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void*(*mallcFp)(int32_t)) {
|
int32_t queryBuildTableMetaReqMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen,
|
||||||
|
void *(*mallcFp)(int32_t)) {
|
||||||
SBuildTableInput *pInput = input;
|
SBuildTableInput *pInput = input;
|
||||||
if (NULL == input || NULL == msg || NULL == msgLen) {
|
if (NULL == input || NULL == msg || NULL == msgLen) {
|
||||||
return TSDB_CODE_TSC_INVALID_INPUT;
|
return TSDB_CODE_TSC_INVALID_INPUT;
|
||||||
|
@ -89,7 +91,7 @@ int32_t queryBuildTableMetaReqMsg(void *input, char **msg, int32_t msgSize, int3
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t queryBuildUseDbMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void*(*mallcFp)(int32_t)) {
|
int32_t queryBuildUseDbMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int32_t)) {
|
||||||
SBuildUseDBInput *pInput = input;
|
SBuildUseDBInput *pInput = input;
|
||||||
if (NULL == pInput || NULL == msg || NULL == msgLen) {
|
if (NULL == pInput || NULL == msg || NULL == msgLen) {
|
||||||
return TSDB_CODE_TSC_INVALID_INPUT;
|
return TSDB_CODE_TSC_INVALID_INPUT;
|
||||||
|
@ -112,7 +114,7 @@ int32_t queryBuildUseDbMsg(void *input, char **msg, int32_t msgSize, int32_t *ms
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t queryBuildQnodeListMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void*(*mallcFp)(int32_t)) {
|
int32_t queryBuildQnodeListMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int32_t)) {
|
||||||
if (NULL == msg || NULL == msgLen) {
|
if (NULL == msg || NULL == msgLen) {
|
||||||
return TSDB_CODE_TSC_INVALID_INPUT;
|
return TSDB_CODE_TSC_INVALID_INPUT;
|
||||||
}
|
}
|
||||||
|
@ -130,7 +132,7 @@ int32_t queryBuildQnodeListMsg(void *input, char **msg, int32_t msgSize, int32_t
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t queryBuildDnodeListMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void*(*mallcFp)(int32_t)) {
|
int32_t queryBuildDnodeListMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int32_t)) {
|
||||||
if (NULL == msg || NULL == msgLen) {
|
if (NULL == msg || NULL == msgLen) {
|
||||||
return TSDB_CODE_TSC_INVALID_INPUT;
|
return TSDB_CODE_TSC_INVALID_INPUT;
|
||||||
}
|
}
|
||||||
|
@ -148,7 +150,7 @@ int32_t queryBuildDnodeListMsg(void *input, char **msg, int32_t msgSize, int32_t
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t queryBuildGetSerVerMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void*(*mallcFp)(int32_t)) {
|
int32_t queryBuildGetSerVerMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int32_t)) {
|
||||||
if (NULL == msg || NULL == msgLen) {
|
if (NULL == msg || NULL == msgLen) {
|
||||||
return TSDB_CODE_TSC_INVALID_INPUT;
|
return TSDB_CODE_TSC_INVALID_INPUT;
|
||||||
}
|
}
|
||||||
|
@ -165,8 +167,7 @@ int32_t queryBuildGetSerVerMsg(void *input, char **msg, int32_t msgSize, int32_t
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t queryBuildGetDBCfgMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int32_t)) {
|
||||||
int32_t queryBuildGetDBCfgMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void*(*mallcFp)(int32_t)) {
|
|
||||||
if (NULL == msg || NULL == msgLen) {
|
if (NULL == msg || NULL == msgLen) {
|
||||||
return TSDB_CODE_TSC_INVALID_INPUT;
|
return TSDB_CODE_TSC_INVALID_INPUT;
|
||||||
}
|
}
|
||||||
|
@ -184,7 +185,7 @@ int32_t queryBuildGetDBCfgMsg(void *input, char **msg, int32_t msgSize, int32_t
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t queryBuildGetIndexMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void*(*mallcFp)(int32_t)) {
|
int32_t queryBuildGetIndexMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int32_t)) {
|
||||||
if (NULL == msg || NULL == msgLen) {
|
if (NULL == msg || NULL == msgLen) {
|
||||||
return TSDB_CODE_TSC_INVALID_INPUT;
|
return TSDB_CODE_TSC_INVALID_INPUT;
|
||||||
}
|
}
|
||||||
|
@ -202,7 +203,8 @@ int32_t queryBuildGetIndexMsg(void *input, char **msg, int32_t msgSize, int32_t
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t queryBuildRetrieveFuncMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void*(*mallcFp)(int32_t)) {
|
int32_t queryBuildRetrieveFuncMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen,
|
||||||
|
void *(*mallcFp)(int32_t)) {
|
||||||
if (NULL == msg || NULL == msgLen) {
|
if (NULL == msg || NULL == msgLen) {
|
||||||
return TSDB_CODE_TSC_INVALID_INPUT;
|
return TSDB_CODE_TSC_INVALID_INPUT;
|
||||||
}
|
}
|
||||||
|
@ -225,7 +227,7 @@ int32_t queryBuildRetrieveFuncMsg(void *input, char **msg, int32_t msgSize, int3
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t queryBuildGetUserAuthMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void*(*mallcFp)(int32_t)) {
|
int32_t queryBuildGetUserAuthMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int32_t)) {
|
||||||
if (NULL == msg || NULL == msgLen) {
|
if (NULL == msg || NULL == msgLen) {
|
||||||
return TSDB_CODE_TSC_INVALID_INPUT;
|
return TSDB_CODE_TSC_INVALID_INPUT;
|
||||||
}
|
}
|
||||||
|
@ -243,7 +245,7 @@ int32_t queryBuildGetUserAuthMsg(void *input, char **msg, int32_t msgSize, int32
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t queryBuildGetTbIndexMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void*(*mallcFp)(int32_t)) {
|
int32_t queryBuildGetTbIndexMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int32_t)) {
|
||||||
if (NULL == msg || NULL == msgLen) {
|
if (NULL == msg || NULL == msgLen) {
|
||||||
return TSDB_CODE_TSC_INVALID_INPUT;
|
return TSDB_CODE_TSC_INVALID_INPUT;
|
||||||
}
|
}
|
||||||
|
@ -261,7 +263,7 @@ int32_t queryBuildGetTbIndexMsg(void *input, char **msg, int32_t msgSize, int32_
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t queryBuildGetTbCfgMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void*(*mallcFp)(int32_t)) {
|
int32_t queryBuildGetTbCfgMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int32_t)) {
|
||||||
if (NULL == msg || NULL == msgLen) {
|
if (NULL == msg || NULL == msgLen) {
|
||||||
return TSDB_CODE_TSC_INVALID_INPUT;
|
return TSDB_CODE_TSC_INVALID_INPUT;
|
||||||
}
|
}
|
||||||
|
@ -282,7 +284,6 @@ int32_t queryBuildGetTbCfgMsg(void *input, char **msg, int32_t msgSize, int32_t
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t queryProcessUseDBRsp(void *output, char *msg, int32_t msgSize) {
|
int32_t queryProcessUseDBRsp(void *output, char *msg, int32_t msgSize) {
|
||||||
SUseDbOutput *pOut = output;
|
SUseDbOutput *pOut = output;
|
||||||
SUseDbRsp usedbRsp = {0};
|
SUseDbRsp usedbRsp = {0};
|
||||||
|
@ -362,13 +363,12 @@ int32_t queryCreateCTableMetaFromMsg(STableMetaRsp *msg, SCTableMeta *pMeta) {
|
||||||
pMeta->uid = msg->tuid;
|
pMeta->uid = msg->tuid;
|
||||||
pMeta->suid = msg->suid;
|
pMeta->suid = msg->suid;
|
||||||
|
|
||||||
qDebug("ctable %s uid %" PRIx64 " meta returned, type %d vgId:%d db %s suid %" PRIx64 ,
|
qDebug("ctable %s uid %" PRIx64 " meta returned, type %d vgId:%d db %s suid %" PRIx64, msg->tbName, pMeta->uid,
|
||||||
msg->tbName, pMeta->uid, pMeta->tableType, pMeta->vgId, msg->dbFName, pMeta->suid);
|
pMeta->tableType, pMeta->vgId, msg->dbFName, pMeta->suid);
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t queryCreateTableMetaFromMsg(STableMetaRsp *msg, bool isStb, STableMeta **pMeta) {
|
int32_t queryCreateTableMetaFromMsg(STableMetaRsp *msg, bool isStb, STableMeta **pMeta) {
|
||||||
int32_t total = msg->numOfColumns + msg->numOfTags;
|
int32_t total = msg->numOfColumns + msg->numOfTags;
|
||||||
int32_t metaSize = sizeof(STableMeta) + sizeof(SSchema) * total;
|
int32_t metaSize = sizeof(STableMeta) + sizeof(SSchema) * total;
|
||||||
|
@ -425,7 +425,8 @@ int32_t queryProcessTableMetaRsp(void *output, char *msg, int32_t msgSize) {
|
||||||
goto PROCESS_META_OVER;
|
goto PROCESS_META_OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 != strcmp(metaRsp.dbFName, TSDB_INFORMATION_SCHEMA_DB) && !tIsValidSchema(metaRsp.pSchemas, metaRsp.numOfColumns, metaRsp.numOfTags)) {
|
if (0 != strcmp(metaRsp.dbFName, TSDB_INFORMATION_SCHEMA_DB) &&
|
||||||
|
!tIsValidSchema(metaRsp.pSchemas, metaRsp.numOfColumns, metaRsp.numOfTags)) {
|
||||||
code = TSDB_CODE_TSC_INVALID_VALUE;
|
code = TSDB_CODE_TSC_INVALID_VALUE;
|
||||||
goto PROCESS_META_OVER;
|
goto PROCESS_META_OVER;
|
||||||
}
|
}
|
||||||
|
@ -461,7 +462,6 @@ PROCESS_META_OVER:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t queryProcessQnodeListRsp(void *output, char *msg, int32_t msgSize) {
|
int32_t queryProcessQnodeListRsp(void *output, char *msg, int32_t msgSize) {
|
||||||
SQnodeListRsp out = {0};
|
SQnodeListRsp out = {0};
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
@ -496,7 +496,7 @@ int32_t queryProcessDnodeListRsp(void *output, char *msg, int32_t msgSize) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
*(SArray**)output = out.dnodeList;
|
*(SArray **)output = out.dnodeList;
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -516,12 +516,11 @@ int32_t queryProcessGetSerVerRsp(void *output, char *msg, int32_t msgSize) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
*(char**)output = strdup(out.ver);
|
*(char **)output = strdup(out.ver);
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t queryProcessGetDbCfgRsp(void *output, char *msg, int32_t msgSize) {
|
int32_t queryProcessGetDbCfgRsp(void *output, char *msg, int32_t msgSize) {
|
||||||
SDbCfgRsp out = {0};
|
SDbCfgRsp out = {0};
|
||||||
|
|
||||||
|
@ -573,7 +572,7 @@ int32_t queryProcessRetrieveFuncRsp(void *output, char *msg, int32_t msgSize) {
|
||||||
return TSDB_CODE_INVALID_MSG;
|
return TSDB_CODE_INVALID_MSG;
|
||||||
}
|
}
|
||||||
|
|
||||||
SFuncInfo * funcInfo = taosArrayGet(out.pFuncInfos, 0);
|
SFuncInfo *funcInfo = taosArrayGet(out.pFuncInfos, 0);
|
||||||
|
|
||||||
memcpy(output, funcInfo, sizeof(*funcInfo));
|
memcpy(output, funcInfo, sizeof(*funcInfo));
|
||||||
taosArrayDestroy(out.pFuncInfos);
|
taosArrayDestroy(out.pFuncInfos);
|
||||||
|
@ -599,7 +598,7 @@ int32_t queryProcessGetTbIndexRsp(void *output, char *msg, int32_t msgSize) {
|
||||||
return TSDB_CODE_TSC_INVALID_INPUT;
|
return TSDB_CODE_TSC_INVALID_INPUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
STableIndexRsp *out = (STableIndexRsp*)output;
|
STableIndexRsp *out = (STableIndexRsp *)output;
|
||||||
if (tDeserializeSTableIndexRsp(msg, msgSize, out) != 0) {
|
if (tDeserializeSTableIndexRsp(msg, msgSize, out) != 0) {
|
||||||
qError("tDeserializeSTableIndexRsp failed, msgSize:%d", msgSize);
|
qError("tDeserializeSTableIndexRsp failed, msgSize:%d", msgSize);
|
||||||
return TSDB_CODE_INVALID_MSG;
|
return TSDB_CODE_INVALID_MSG;
|
||||||
|
@ -619,7 +618,7 @@ int32_t queryProcessGetTbCfgRsp(void *output, char *msg, int32_t msgSize) {
|
||||||
return TSDB_CODE_INVALID_MSG;
|
return TSDB_CODE_INVALID_MSG;
|
||||||
}
|
}
|
||||||
|
|
||||||
*(STableCfgRsp**)output = out;
|
*(STableCfgRsp **)output = out;
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,8 +15,9 @@
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "tmsg.h"
|
|
||||||
#include "query.h"
|
#include "query.h"
|
||||||
|
#include "tmsg.h"
|
||||||
#include "trpc.h"
|
#include "trpc.h"
|
||||||
|
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
|
@ -37,7 +38,7 @@ int32_t testPrint(void* p) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t testPrintError(void* p) {
|
int32_t testPrintError(void* p) {
|
||||||
SParam* param = (SParam*) p;
|
SParam* param = (SParam*)p;
|
||||||
taosMemoryFreeClear(p);
|
taosMemoryFreeClear(p);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -67,8 +68,8 @@ TEST(testCase, async_task_test) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(testCase, many_async_task_test) {
|
TEST(testCase, many_async_task_test) {
|
||||||
for(int32_t i = 0; i < 50; ++i) {
|
for (int32_t i = 0; i < 50; ++i) {
|
||||||
SParam* p = (SParam*) taosMemoryCalloc(1, sizeof(SParam));
|
SParam* p = (SParam*)taosMemoryCalloc(1, sizeof(SParam));
|
||||||
p->v = i;
|
p->v = i;
|
||||||
taosAsyncExec(testPrint, p, NULL);
|
taosAsyncExec(testPrint, p, NULL);
|
||||||
}
|
}
|
||||||
|
@ -78,7 +79,7 @@ TEST(testCase, many_async_task_test) {
|
||||||
|
|
||||||
TEST(testCase, error_in_async_test) {
|
TEST(testCase, error_in_async_test) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SParam* p = (SParam*) taosMemoryCalloc(1, sizeof(SParam));
|
SParam* p = (SParam*)taosMemoryCalloc(1, sizeof(SParam));
|
||||||
taosAsyncExec(testPrintError, p, &code);
|
taosAsyncExec(testPrintError, p, &code);
|
||||||
taosMsleep(1);
|
taosMsleep(1);
|
||||||
printf("Error code:%d after asynchronously exec function\n", code);
|
printf("Error code:%d after asynchronously exec function\n", code);
|
||||||
|
|
|
@ -20,14 +20,14 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "executor.h"
|
||||||
#include "osDef.h"
|
#include "osDef.h"
|
||||||
|
#include "plannodes.h"
|
||||||
#include "qworker.h"
|
#include "qworker.h"
|
||||||
#include "tlockfree.h"
|
#include "tlockfree.h"
|
||||||
#include "ttimer.h"
|
|
||||||
#include "tref.h"
|
#include "tref.h"
|
||||||
#include "plannodes.h"
|
|
||||||
#include "executor.h"
|
|
||||||
#include "trpc.h"
|
#include "trpc.h"
|
||||||
|
#include "ttimer.h"
|
||||||
|
|
||||||
#define QW_DEFAULT_SCHEDULER_NUMBER 100
|
#define QW_DEFAULT_SCHEDULER_NUMBER 100
|
||||||
#define QW_DEFAULT_TASK_NUMBER 10000
|
#define QW_DEFAULT_TASK_NUMBER 10000
|
||||||
|
@ -183,7 +183,7 @@ typedef struct SQWorker {
|
||||||
SQWorkerCfg cfg;
|
SQWorkerCfg cfg;
|
||||||
int8_t nodeType;
|
int8_t nodeType;
|
||||||
int32_t nodeId;
|
int32_t nodeId;
|
||||||
void * timer;
|
void *timer;
|
||||||
tmr_h hbTimer;
|
tmr_h hbTimer;
|
||||||
SRWLatch schLock;
|
SRWLatch schLock;
|
||||||
// SRWLatch ctxLock;
|
// SRWLatch ctxLock;
|
||||||
|
@ -217,7 +217,12 @@ typedef struct SQWorkerMgmt {
|
||||||
#define QW_SET_EVENT_PROCESSED(ctx, event) atomic_store_8(&(ctx)->events[event], QW_EVENT_PROCESSED)
|
#define QW_SET_EVENT_PROCESSED(ctx, event) atomic_store_8(&(ctx)->events[event], QW_EVENT_PROCESSED)
|
||||||
|
|
||||||
#define QW_GET_PHASE(ctx) atomic_load_8(&(ctx)->phase)
|
#define QW_GET_PHASE(ctx) atomic_load_8(&(ctx)->phase)
|
||||||
#define QW_SET_PHASE(ctx, _value) do { if ((_value) != QW_PHASE_PRE_FETCH && (_value) != QW_PHASE_POST_FETCH) { atomic_store_8(&(ctx)->phase, _value); } } while (0)
|
#define QW_SET_PHASE(ctx, _value) \
|
||||||
|
do { \
|
||||||
|
if ((_value) != QW_PHASE_PRE_FETCH && (_value) != QW_PHASE_POST_FETCH) { \
|
||||||
|
atomic_store_8(&(ctx)->phase, _value); \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define QW_SET_RSP_CODE(ctx, code) atomic_store_32(&(ctx)->rspCode, code)
|
#define QW_SET_RSP_CODE(ctx, code) atomic_store_32(&(ctx)->rspCode, code)
|
||||||
#define QW_UPDATE_RSP_CODE(ctx, code) atomic_val_compare_exchange_32(&(ctx)->rspCode, 0, code)
|
#define QW_UPDATE_RSP_CODE(ctx, code) atomic_val_compare_exchange_32(&(ctx)->rspCode, 0, code)
|
||||||
|
@ -288,11 +293,14 @@ typedef struct SQWorkerMgmt {
|
||||||
#define QW_TASK_DLOG_E(param) qDebug("QID:0x%" PRIx64 ",TID:0x%" PRIx64 ",EID:%d " param, qId, tId, eId)
|
#define QW_TASK_DLOG_E(param) qDebug("QID:0x%" PRIx64 ",TID:0x%" PRIx64 ",EID:%d " param, qId, tId, eId)
|
||||||
|
|
||||||
#define QW_SCH_TASK_ELOG(param, ...) \
|
#define QW_SCH_TASK_ELOG(param, ...) \
|
||||||
qError("QW:%p SID:0x%" PRIx64 ",QID:0x%" PRIx64 ",TID:0x%" PRIx64 ",EID:%d " param, mgmt, sId, qId, tId, eId, __VA_ARGS__)
|
qError("QW:%p SID:0x%" PRIx64 ",QID:0x%" PRIx64 ",TID:0x%" PRIx64 ",EID:%d " param, mgmt, sId, qId, tId, eId, \
|
||||||
|
__VA_ARGS__)
|
||||||
#define QW_SCH_TASK_WLOG(param, ...) \
|
#define QW_SCH_TASK_WLOG(param, ...) \
|
||||||
qWarn("QW:%p SID:0x%" PRIx64 ",QID:0x%" PRIx64 ",TID:0x%" PRIx64 ",EID:%d " param, mgmt, sId, qId, tId, eId, __VA_ARGS__)
|
qWarn("QW:%p SID:0x%" PRIx64 ",QID:0x%" PRIx64 ",TID:0x%" PRIx64 ",EID:%d " param, mgmt, sId, qId, tId, eId, \
|
||||||
|
__VA_ARGS__)
|
||||||
#define QW_SCH_TASK_DLOG(param, ...) \
|
#define QW_SCH_TASK_DLOG(param, ...) \
|
||||||
qDebug("QW:%p SID:0x%" PRIx64 ",QID:0x%" PRIx64 ",TID:0x%" PRIx64 ",EID:%d " param, mgmt, sId, qId, tId, eId, __VA_ARGS__)
|
qDebug("QW:%p SID:0x%" PRIx64 ",QID:0x%" PRIx64 ",TID:0x%" PRIx64 ",EID:%d " param, mgmt, sId, qId, tId, eId, \
|
||||||
|
__VA_ARGS__)
|
||||||
|
|
||||||
#define QW_LOCK_DEBUG(...) \
|
#define QW_LOCK_DEBUG(...) \
|
||||||
do { \
|
do { \
|
||||||
|
@ -337,10 +345,11 @@ typedef struct SQWorkerMgmt {
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
|
||||||
extern SQWorkerMgmt gQwMgmt;
|
extern SQWorkerMgmt gQwMgmt;
|
||||||
|
|
||||||
static FORCE_INLINE SQWorker *qwAcquire(int64_t refId) { return (SQWorker *)taosAcquireRef(atomic_load_32(&gQwMgmt.qwRef), refId); }
|
static FORCE_INLINE SQWorker *qwAcquire(int64_t refId) {
|
||||||
|
return (SQWorker *)taosAcquireRef(atomic_load_32(&gQwMgmt.qwRef), refId);
|
||||||
|
}
|
||||||
static FORCE_INLINE int32_t qwRelease(int64_t refId) { return taosReleaseRef(gQwMgmt.qwRef, refId); }
|
static FORCE_INLINE int32_t qwRelease(int64_t refId) { return taosReleaseRef(gQwMgmt.qwRef, refId); }
|
||||||
|
|
||||||
char *qwPhaseStr(int32_t phase);
|
char *qwPhaseStr(int32_t phase);
|
||||||
|
@ -360,7 +369,7 @@ int32_t qwOpenRef(void);
|
||||||
void qwSetHbParam(int64_t refId, SQWHbParam **pParam);
|
void qwSetHbParam(int64_t refId, SQWHbParam **pParam);
|
||||||
int32_t qwUpdateTimeInQueue(SQWorker *mgmt, int64_t ts, EQueueType type);
|
int32_t qwUpdateTimeInQueue(SQWorker *mgmt, int64_t ts, EQueueType type);
|
||||||
int64_t qwGetTimeInQueue(SQWorker *mgmt, EQueueType type);
|
int64_t qwGetTimeInQueue(SQWorker *mgmt, EQueueType type);
|
||||||
void qwClearExpiredSch(SQWorker *mgmt, SArray* pExpiredSch);
|
void qwClearExpiredSch(SQWorker *mgmt, SArray *pExpiredSch);
|
||||||
int32_t qwAcquireScheduler(SQWorker *mgmt, uint64_t sId, int32_t rwType, SQWSchStatus **sch);
|
int32_t qwAcquireScheduler(SQWorker *mgmt, uint64_t sId, int32_t rwType, SQWSchStatus **sch);
|
||||||
void qwFreeTaskCtx(SQWTaskCtx *ctx);
|
void qwFreeTaskCtx(SQWTaskCtx *ctx);
|
||||||
|
|
||||||
|
@ -372,7 +381,6 @@ void qwDbgSimulateRedirect(SQWMsg *qwMsg, SQWTaskCtx *ctx, bool *rsped);
|
||||||
void qwDbgSimulateSleep(void);
|
void qwDbgSimulateSleep(void);
|
||||||
void qwDbgSimulateDead(QW_FPARAMS_DEF, SQWTaskCtx *ctx, bool *rsped);
|
void qwDbgSimulateDead(QW_FPARAMS_DEF, SQWTaskCtx *ctx, bool *rsped);
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -20,12 +20,12 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "qwInt.h"
|
|
||||||
#include "dataSinkMgt.h"
|
#include "dataSinkMgt.h"
|
||||||
|
#include "qwInt.h"
|
||||||
|
|
||||||
int32_t qwAbortPrerocessQuery(QW_FPARAMS_DEF);
|
int32_t qwAbortPrerocessQuery(QW_FPARAMS_DEF);
|
||||||
int32_t qwPreprocessQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg);
|
int32_t qwPreprocessQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg);
|
||||||
int32_t qwProcessQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg, char* sql);
|
int32_t qwProcessQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg, char *sql);
|
||||||
int32_t qwProcessCQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg);
|
int32_t qwProcessCQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg);
|
||||||
int32_t qwProcessReady(QW_FPARAMS_DEF, SQWMsg *qwMsg);
|
int32_t qwProcessReady(QW_FPARAMS_DEF, SQWMsg *qwMsg);
|
||||||
int32_t qwProcessFetch(QW_FPARAMS_DEF, SQWMsg *qwMsg);
|
int32_t qwProcessFetch(QW_FPARAMS_DEF, SQWMsg *qwMsg);
|
||||||
|
@ -35,11 +35,12 @@ int32_t qwProcessDelete(QW_FPARAMS_DEF, SQWMsg *qwMsg, SDeleteRes *pRes);
|
||||||
|
|
||||||
int32_t qwBuildAndSendDropRsp(SRpcHandleInfo *pConn, int32_t code);
|
int32_t qwBuildAndSendDropRsp(SRpcHandleInfo *pConn, int32_t code);
|
||||||
int32_t qwBuildAndSendCancelRsp(SRpcHandleInfo *pConn, int32_t code);
|
int32_t qwBuildAndSendCancelRsp(SRpcHandleInfo *pConn, int32_t code);
|
||||||
int32_t qwBuildAndSendFetchRsp(int32_t rspType, SRpcHandleInfo *pConn, SRetrieveTableRsp *pRsp, int32_t dataLength, int32_t code);
|
int32_t qwBuildAndSendFetchRsp(int32_t rspType, SRpcHandleInfo *pConn, SRetrieveTableRsp *pRsp, int32_t dataLength,
|
||||||
|
int32_t code);
|
||||||
void qwBuildFetchRsp(void *msg, SOutputData *input, int32_t len, bool qComplete);
|
void qwBuildFetchRsp(void *msg, SOutputData *input, int32_t len, bool qComplete);
|
||||||
int32_t qwBuildAndSendCQueryMsg(QW_FPARAMS_DEF, SRpcHandleInfo *pConn);
|
int32_t qwBuildAndSendCQueryMsg(QW_FPARAMS_DEF, SRpcHandleInfo *pConn);
|
||||||
int32_t qwBuildAndSendQueryRsp(int32_t rspType, SRpcHandleInfo *pConn, int32_t code, SQWTaskCtx *ctx);
|
int32_t qwBuildAndSendQueryRsp(int32_t rspType, SRpcHandleInfo *pConn, int32_t code, SQWTaskCtx *ctx);
|
||||||
int32_t qwBuildAndSendExplainRsp(SRpcHandleInfo *pConn, SArray* pExecList);
|
int32_t qwBuildAndSendExplainRsp(SRpcHandleInfo *pConn, SArray *pExecList);
|
||||||
int32_t qwBuildAndSendErrorRsp(int32_t rspType, SRpcHandleInfo *pConn, int32_t code);
|
int32_t qwBuildAndSendErrorRsp(int32_t rspType, SRpcHandleInfo *pConn, int32_t code);
|
||||||
void qwFreeFetchRsp(void *msg);
|
void qwFreeFetchRsp(void *msg);
|
||||||
int32_t qwMallocFetchRsp(int8_t rpcMalloc, int32_t length, SRetrieveTableRsp **rsp);
|
int32_t qwMallocFetchRsp(int8_t rpcMalloc, int32_t length, SRetrieveTableRsp **rsp);
|
||||||
|
|
|
@ -1,15 +1,19 @@
|
||||||
#include "qworker.h"
|
|
||||||
#include "dataSinkMgt.h"
|
#include "dataSinkMgt.h"
|
||||||
#include "executor.h"
|
#include "executor.h"
|
||||||
#include "planner.h"
|
#include "planner.h"
|
||||||
#include "query.h"
|
#include "query.h"
|
||||||
#include "qwInt.h"
|
#include "qwInt.h"
|
||||||
#include "qwMsg.h"
|
#include "qwMsg.h"
|
||||||
|
#include "qworker.h"
|
||||||
#include "tcommon.h"
|
#include "tcommon.h"
|
||||||
#include "tmsg.h"
|
#include "tmsg.h"
|
||||||
#include "tname.h"
|
#include "tname.h"
|
||||||
|
|
||||||
SQWDebug gQWDebug = {.statusEnable = true, .dumpEnable = false, .redirectSimulate = false, .deadSimulate = false, .sleepSimulate = false};
|
SQWDebug gQWDebug = {.statusEnable = true,
|
||||||
|
.dumpEnable = false,
|
||||||
|
.redirectSimulate = false,
|
||||||
|
.deadSimulate = false,
|
||||||
|
.sleepSimulate = false};
|
||||||
|
|
||||||
int32_t qwDbgValidateStatus(QW_FPARAMS_DEF, int8_t oriStatus, int8_t newStatus, bool *ignore) {
|
int32_t qwDbgValidateStatus(QW_FPARAMS_DEF, int8_t oriStatus, int8_t newStatus, bool *ignore) {
|
||||||
if (!gQWDebug.statusEnable) {
|
if (!gQWDebug.statusEnable) {
|
||||||
|
@ -29,15 +33,13 @@ int32_t qwDbgValidateStatus(QW_FPARAMS_DEF, int8_t oriStatus, int8_t newStatus,
|
||||||
|
|
||||||
switch (oriStatus) {
|
switch (oriStatus) {
|
||||||
case JOB_TASK_STATUS_NULL:
|
case JOB_TASK_STATUS_NULL:
|
||||||
if (newStatus != JOB_TASK_STATUS_EXEC && newStatus != JOB_TASK_STATUS_FAIL &&
|
if (newStatus != JOB_TASK_STATUS_EXEC && newStatus != JOB_TASK_STATUS_FAIL && newStatus != JOB_TASK_STATUS_INIT) {
|
||||||
newStatus != JOB_TASK_STATUS_INIT) {
|
|
||||||
QW_ERR_JRET(TSDB_CODE_QRY_APP_ERROR);
|
QW_ERR_JRET(TSDB_CODE_QRY_APP_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case JOB_TASK_STATUS_INIT:
|
case JOB_TASK_STATUS_INIT:
|
||||||
if (newStatus != JOB_TASK_STATUS_DROP && newStatus != JOB_TASK_STATUS_EXEC
|
if (newStatus != JOB_TASK_STATUS_DROP && newStatus != JOB_TASK_STATUS_EXEC && newStatus != JOB_TASK_STATUS_FAIL) {
|
||||||
&& newStatus != JOB_TASK_STATUS_FAIL) {
|
|
||||||
QW_ERR_JRET(TSDB_CODE_QRY_APP_ERROR);
|
QW_ERR_JRET(TSDB_CODE_QRY_APP_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,8 +52,8 @@ int32_t qwDbgValidateStatus(QW_FPARAMS_DEF, int8_t oriStatus, int8_t newStatus,
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case JOB_TASK_STATUS_PART_SUCC:
|
case JOB_TASK_STATUS_PART_SUCC:
|
||||||
if (newStatus != JOB_TASK_STATUS_EXEC && newStatus != JOB_TASK_STATUS_SUCC &&
|
if (newStatus != JOB_TASK_STATUS_EXEC && newStatus != JOB_TASK_STATUS_SUCC && newStatus != JOB_TASK_STATUS_FAIL &&
|
||||||
newStatus != JOB_TASK_STATUS_FAIL && newStatus != JOB_TASK_STATUS_DROP) {
|
newStatus != JOB_TASK_STATUS_DROP) {
|
||||||
QW_ERR_JRET(TSDB_CODE_QRY_APP_ERROR);
|
QW_ERR_JRET(TSDB_CODE_QRY_APP_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,7 +91,8 @@ _return:
|
||||||
|
|
||||||
void qwDbgDumpSchInfo(SQWorker *mgmt, SQWSchStatus *sch, int32_t i) {
|
void qwDbgDumpSchInfo(SQWorker *mgmt, SQWSchStatus *sch, int32_t i) {
|
||||||
QW_LOCK(QW_READ, &sch->tasksLock);
|
QW_LOCK(QW_READ, &sch->tasksLock);
|
||||||
QW_DLOG("the %dth scheduler status, hbBrokenTs:%" PRId64 ",taskNum:%d", i, sch->hbBrokenTs, taosHashGetSize(sch->tasksHash));
|
QW_DLOG("the %dth scheduler status, hbBrokenTs:%" PRId64 ",taskNum:%d", i, sch->hbBrokenTs,
|
||||||
|
taosHashGetSize(sch->tasksHash));
|
||||||
QW_UNLOCK(QW_READ, &sch->tasksLock);
|
QW_UNLOCK(QW_READ, &sch->tasksLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,10 +123,9 @@ void qwDbgDumpMgmtInfo(SQWorker *mgmt) {
|
||||||
QW_DUMP("total remain ctx num %d", taosHashGetSize(mgmt->ctxHash));
|
QW_DUMP("total remain ctx num %d", taosHashGetSize(mgmt->ctxHash));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t qwDbgBuildAndSendRedirectRsp(int32_t rspType, SRpcHandleInfo *pConn, int32_t code, SEpSet *pEpSet) {
|
int32_t qwDbgBuildAndSendRedirectRsp(int32_t rspType, SRpcHandleInfo *pConn, int32_t code, SEpSet *pEpSet) {
|
||||||
int32_t contLen = 0;
|
int32_t contLen = 0;
|
||||||
char* rsp = NULL;
|
char *rsp = NULL;
|
||||||
|
|
||||||
if (pEpSet) {
|
if (pEpSet) {
|
||||||
contLen = tSerializeSEpSet(NULL, 0, pEpSet);
|
contLen = tSerializeSEpSet(NULL, 0, pEpSet);
|
||||||
|
@ -213,7 +215,9 @@ void qwDbgSimulateDead(QW_FPARAMS_DEF, SQWTaskCtx *ctx, bool *rsped) {
|
||||||
static int32_t ignoreTime = 0;
|
static int32_t ignoreTime = 0;
|
||||||
|
|
||||||
if (++ignoreTime > 10 && 0 == taosRand() % 9) {
|
if (++ignoreTime > 10 && 0 == taosRand() % 9) {
|
||||||
SRpcHandleInfo *pConn = ((ctx->msgType == TDMT_SCH_FETCH || ctx->msgType == TDMT_SCH_MERGE_FETCH) ? &ctx->dataConnInfo : &ctx->ctrlConnInfo);
|
SRpcHandleInfo *pConn =
|
||||||
|
((ctx->msgType == TDMT_SCH_FETCH || ctx->msgType == TDMT_SCH_MERGE_FETCH) ? &ctx->dataConnInfo
|
||||||
|
: &ctx->ctrlConnInfo);
|
||||||
qwBuildAndSendErrorRsp(ctx->msgType + 1, pConn, TSDB_CODE_RPC_BROKEN_LINK);
|
qwBuildAndSendErrorRsp(ctx->msgType + 1, pConn, TSDB_CODE_RPC_BROKEN_LINK);
|
||||||
|
|
||||||
qwBuildAndSendDropMsg(QW_FPARAMS(), pConn);
|
qwBuildAndSendDropMsg(QW_FPARAMS(), pConn);
|
||||||
|
@ -223,8 +227,6 @@ void qwDbgSimulateDead(QW_FPARAMS_DEF, SQWTaskCtx *ctx, bool *rsped) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int32_t qwDbgEnableDebug(char *option) {
|
int32_t qwDbgEnableDebug(char *option) {
|
||||||
if (0 == strcasecmp(option, "lock")) {
|
if (0 == strcasecmp(option, "lock")) {
|
||||||
gQWDebug.lockEnable = true;
|
gQWDebug.lockEnable = true;
|
||||||
|
@ -266,5 +268,3 @@ int32_t qwDbgEnableDebug(char *option) {
|
||||||
|
|
||||||
return TSDB_CODE_APP_ERROR;
|
return TSDB_CODE_APP_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
#include "executor.h"
|
#include "executor.h"
|
||||||
#include "planner.h"
|
#include "planner.h"
|
||||||
#include "query.h"
|
#include "query.h"
|
||||||
#include "qworker.h"
|
|
||||||
#include "qwInt.h"
|
#include "qwInt.h"
|
||||||
|
#include "qworker.h"
|
||||||
#include "tcommon.h"
|
#include "tcommon.h"
|
||||||
#include "tmsg.h"
|
#include "tmsg.h"
|
||||||
#include "tname.h"
|
#include "tname.h"
|
||||||
|
@ -12,7 +12,8 @@
|
||||||
int32_t qwMallocFetchRsp(int8_t rpcMalloc, int32_t length, SRetrieveTableRsp **rsp) {
|
int32_t qwMallocFetchRsp(int8_t rpcMalloc, int32_t length, SRetrieveTableRsp **rsp) {
|
||||||
int32_t msgSize = sizeof(SRetrieveTableRsp) + length;
|
int32_t msgSize = sizeof(SRetrieveTableRsp) + length;
|
||||||
|
|
||||||
SRetrieveTableRsp *pRsp = (SRetrieveTableRsp *)(rpcMalloc ? rpcReallocCont(*rsp, msgSize) : taosMemoryRealloc(*rsp, msgSize));
|
SRetrieveTableRsp *pRsp =
|
||||||
|
(SRetrieveTableRsp *)(rpcMalloc ? rpcReallocCont(*rsp, msgSize) : taosMemoryRealloc(*rsp, msgSize));
|
||||||
if (NULL == pRsp) {
|
if (NULL == pRsp) {
|
||||||
qError("rpcMallocCont %d failed", msgSize);
|
qError("rpcMallocCont %d failed", msgSize);
|
||||||
QW_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
QW_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||||
|
@ -61,7 +62,7 @@ int32_t qwBuildAndSendErrorRsp(int32_t rspType, SRpcHandleInfo *pConn, int32_t c
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t qwBuildAndSendQueryRsp(int32_t rspType, SRpcHandleInfo *pConn, int32_t code, SQWTaskCtx *ctx) {
|
int32_t qwBuildAndSendQueryRsp(int32_t rspType, SRpcHandleInfo *pConn, int32_t code, SQWTaskCtx *ctx) {
|
||||||
STbVerInfo* tbInfo = ctx ? &ctx->tbInfo : NULL;
|
STbVerInfo *tbInfo = ctx ? &ctx->tbInfo : NULL;
|
||||||
int64_t affectedRows = ctx ? ctx->affectedRows : 0;
|
int64_t affectedRows = ctx ? ctx->affectedRows : 0;
|
||||||
SQueryTableRsp *pRsp = (SQueryTableRsp *)rpcMallocCont(sizeof(SQueryTableRsp));
|
SQueryTableRsp *pRsp = (SQueryTableRsp *)rpcMallocCont(sizeof(SQueryTableRsp));
|
||||||
pRsp->code = htonl(code);
|
pRsp->code = htonl(code);
|
||||||
|
@ -85,12 +86,12 @@ int32_t qwBuildAndSendQueryRsp(int32_t rspType, SRpcHandleInfo *pConn, int32_t c
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t qwBuildAndSendExplainRsp(SRpcHandleInfo *pConn, SArray* pExecList) {
|
int32_t qwBuildAndSendExplainRsp(SRpcHandleInfo *pConn, SArray *pExecList) {
|
||||||
SExplainExecInfo* pInfo = taosArrayGet(pExecList, 0);
|
SExplainExecInfo *pInfo = taosArrayGet(pExecList, 0);
|
||||||
SExplainRsp rsp = {.numOfPlans = taosArrayGetSize(pExecList), .subplanInfo = pInfo};
|
SExplainRsp rsp = {.numOfPlans = taosArrayGetSize(pExecList), .subplanInfo = pInfo};
|
||||||
|
|
||||||
int32_t contLen = tSerializeSExplainRsp(NULL, 0, &rsp);
|
int32_t contLen = tSerializeSExplainRsp(NULL, 0, &rsp);
|
||||||
void * pRsp = rpcMallocCont(contLen);
|
void *pRsp = rpcMallocCont(contLen);
|
||||||
tSerializeSExplainRsp(pRsp, contLen, &rsp);
|
tSerializeSExplainRsp(pRsp, contLen, &rsp);
|
||||||
|
|
||||||
SRpcMsg rpcRsp = {
|
SRpcMsg rpcRsp = {
|
||||||
|
@ -108,7 +109,7 @@ int32_t qwBuildAndSendExplainRsp(SRpcHandleInfo *pConn, SArray* pExecList) {
|
||||||
|
|
||||||
int32_t qwBuildAndSendHbRsp(SRpcHandleInfo *pConn, SSchedulerHbRsp *pStatus, int32_t code) {
|
int32_t qwBuildAndSendHbRsp(SRpcHandleInfo *pConn, SSchedulerHbRsp *pStatus, int32_t code) {
|
||||||
int32_t contLen = tSerializeSSchedulerHbRsp(NULL, 0, pStatus);
|
int32_t contLen = tSerializeSSchedulerHbRsp(NULL, 0, pStatus);
|
||||||
void * pRsp = rpcMallocCont(contLen);
|
void *pRsp = rpcMallocCont(contLen);
|
||||||
tSerializeSSchedulerHbRsp(pRsp, contLen, pStatus);
|
tSerializeSSchedulerHbRsp(pRsp, contLen, pStatus);
|
||||||
|
|
||||||
SRpcMsg rpcRsp = {
|
SRpcMsg rpcRsp = {
|
||||||
|
@ -124,7 +125,8 @@ int32_t qwBuildAndSendHbRsp(SRpcHandleInfo *pConn, SSchedulerHbRsp *pStatus, int
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t qwBuildAndSendFetchRsp(int32_t rspType, SRpcHandleInfo *pConn, SRetrieveTableRsp *pRsp, int32_t dataLength, int32_t code) {
|
int32_t qwBuildAndSendFetchRsp(int32_t rspType, SRpcHandleInfo *pConn, SRetrieveTableRsp *pRsp, int32_t dataLength,
|
||||||
|
int32_t code) {
|
||||||
if (NULL == pRsp) {
|
if (NULL == pRsp) {
|
||||||
pRsp = (SRetrieveTableRsp *)rpcMallocCont(sizeof(SRetrieveTableRsp));
|
pRsp = (SRetrieveTableRsp *)rpcMallocCont(sizeof(SRetrieveTableRsp));
|
||||||
memset(pRsp, 0, sizeof(SRetrieveTableRsp));
|
memset(pRsp, 0, sizeof(SRetrieveTableRsp));
|
||||||
|
@ -209,7 +211,6 @@ int32_t qwBuildAndSendDropMsg(QW_FPARAMS_DEF, SRpcHandleInfo *pConn) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t qwBuildAndSendCQueryMsg(QW_FPARAMS_DEF, SRpcHandleInfo *pConn) {
|
int32_t qwBuildAndSendCQueryMsg(QW_FPARAMS_DEF, SRpcHandleInfo *pConn) {
|
||||||
SQueryContinueReq *req = (SQueryContinueReq *)rpcMallocCont(sizeof(SQueryContinueReq));
|
SQueryContinueReq *req = (SQueryContinueReq *)rpcMallocCont(sizeof(SQueryContinueReq));
|
||||||
if (NULL == req) {
|
if (NULL == req) {
|
||||||
|
@ -309,7 +310,7 @@ int32_t qWorkerPreprocessQueryMsg(void *qWorkerMgmt, SRpcMsg *pMsg) {
|
||||||
|
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SSubQueryMsg *msg = pMsg->pCont;
|
SSubQueryMsg *msg = pMsg->pCont;
|
||||||
SQWorker * mgmt = (SQWorker *)qWorkerMgmt;
|
SQWorker *mgmt = (SQWorker *)qWorkerMgmt;
|
||||||
|
|
||||||
if (NULL == msg || pMsg->contLen <= sizeof(*msg)) {
|
if (NULL == msg || pMsg->contLen <= sizeof(*msg)) {
|
||||||
QW_ELOG("invalid query msg, msg:%p, msgLen:%d", msg, pMsg->contLen);
|
QW_ELOG("invalid query msg, msg:%p, msgLen:%d", msg, pMsg->contLen);
|
||||||
|
@ -330,7 +331,8 @@ int32_t qWorkerPreprocessQueryMsg(void *qWorkerMgmt, SRpcMsg *pMsg) {
|
||||||
int64_t rId = msg->refId;
|
int64_t rId = msg->refId;
|
||||||
int32_t eId = msg->execId;
|
int32_t eId = msg->execId;
|
||||||
|
|
||||||
SQWMsg qwMsg = {.msgType = pMsg->msgType, .msg = msg->msg + msg->sqlLen, .msgLen = msg->phyLen, .connInfo = pMsg->info};
|
SQWMsg qwMsg = {
|
||||||
|
.msgType = pMsg->msgType, .msg = msg->msg + msg->sqlLen, .msgLen = msg->phyLen, .connInfo = pMsg->info};
|
||||||
|
|
||||||
QW_SCH_TASK_DLOG("prerocessQuery start, handle:%p", pMsg->info.handle);
|
QW_SCH_TASK_DLOG("prerocessQuery start, handle:%p", pMsg->info.handle);
|
||||||
QW_ERR_RET(qwPreprocessQuery(QW_FPARAMS(), &qwMsg));
|
QW_ERR_RET(qwPreprocessQuery(QW_FPARAMS(), &qwMsg));
|
||||||
|
@ -345,7 +347,7 @@ int32_t qWorkerAbortPreprocessQueryMsg(void *qWorkerMgmt, SRpcMsg *pMsg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SSubQueryMsg *msg = pMsg->pCont;
|
SSubQueryMsg *msg = pMsg->pCont;
|
||||||
SQWorker * mgmt = (SQWorker *)qWorkerMgmt;
|
SQWorker *mgmt = (SQWorker *)qWorkerMgmt;
|
||||||
|
|
||||||
uint64_t sId = msg->sId;
|
uint64_t sId = msg->sId;
|
||||||
uint64_t qId = msg->queryId;
|
uint64_t qId = msg->queryId;
|
||||||
|
@ -367,7 +369,7 @@ int32_t qWorkerProcessQueryMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg, int
|
||||||
|
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SSubQueryMsg *msg = pMsg->pCont;
|
SSubQueryMsg *msg = pMsg->pCont;
|
||||||
SQWorker * mgmt = (SQWorker *)qWorkerMgmt;
|
SQWorker *mgmt = (SQWorker *)qWorkerMgmt;
|
||||||
|
|
||||||
qwUpdateTimeInQueue(mgmt, ts, QUERY_QUEUE);
|
qwUpdateTimeInQueue(mgmt, ts, QUERY_QUEUE);
|
||||||
QW_STAT_INC(mgmt->stat.msgStat.queryProcessed, 1);
|
QW_STAT_INC(mgmt->stat.msgStat.queryProcessed, 1);
|
||||||
|
@ -383,13 +385,18 @@ int32_t qWorkerProcessQueryMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg, int
|
||||||
int64_t rId = msg->refId;
|
int64_t rId = msg->refId;
|
||||||
int32_t eId = msg->execId;
|
int32_t eId = msg->execId;
|
||||||
|
|
||||||
SQWMsg qwMsg = {.node = node, .msg = msg->msg + msg->sqlLen, .msgLen = msg->phyLen, .connInfo = pMsg->info, .msgType = pMsg->msgType};
|
SQWMsg qwMsg = {.node = node,
|
||||||
|
.msg = msg->msg + msg->sqlLen,
|
||||||
|
.msgLen = msg->phyLen,
|
||||||
|
.connInfo = pMsg->info,
|
||||||
|
.msgType = pMsg->msgType};
|
||||||
qwMsg.msgInfo.explain = msg->explain;
|
qwMsg.msgInfo.explain = msg->explain;
|
||||||
qwMsg.msgInfo.taskType = msg->taskType;
|
qwMsg.msgInfo.taskType = msg->taskType;
|
||||||
qwMsg.msgInfo.needFetch = msg->needFetch;
|
qwMsg.msgInfo.needFetch = msg->needFetch;
|
||||||
|
|
||||||
char * sql = strndup(msg->msg, msg->sqlLen);
|
char *sql = strndup(msg->msg, msg->sqlLen);
|
||||||
QW_SCH_TASK_DLOG("processQuery start, node:%p, type:%s, handle:%p, SQL:%s", node, TMSG_INFO(pMsg->msgType), pMsg->info.handle, sql);
|
QW_SCH_TASK_DLOG("processQuery start, node:%p, type:%s, handle:%p, SQL:%s", node, TMSG_INFO(pMsg->msgType),
|
||||||
|
pMsg->info.handle, sql);
|
||||||
QW_ERR_JRET(qwProcessQuery(QW_FPARAMS(), &qwMsg, sql));
|
QW_ERR_JRET(qwProcessQuery(QW_FPARAMS(), &qwMsg, sql));
|
||||||
|
|
||||||
_return:
|
_return:
|
||||||
|
@ -405,8 +412,8 @@ int32_t qWorkerProcessCQueryMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg, in
|
||||||
bool queryDone = false;
|
bool queryDone = false;
|
||||||
SQueryContinueReq *msg = (SQueryContinueReq *)pMsg->pCont;
|
SQueryContinueReq *msg = (SQueryContinueReq *)pMsg->pCont;
|
||||||
bool needStop = false;
|
bool needStop = false;
|
||||||
SQWTaskCtx * handles = NULL;
|
SQWTaskCtx *handles = NULL;
|
||||||
SQWorker * mgmt = (SQWorker *)qWorkerMgmt;
|
SQWorker *mgmt = (SQWorker *)qWorkerMgmt;
|
||||||
|
|
||||||
qwUpdateTimeInQueue(mgmt, ts, QUERY_QUEUE);
|
qwUpdateTimeInQueue(mgmt, ts, QUERY_QUEUE);
|
||||||
QW_STAT_INC(mgmt->stat.msgStat.cqueryProcessed, 1);
|
QW_STAT_INC(mgmt->stat.msgStat.cqueryProcessed, 1);
|
||||||
|
@ -439,7 +446,7 @@ int32_t qWorkerProcessFetchMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg, int
|
||||||
}
|
}
|
||||||
|
|
||||||
SResFetchReq *msg = pMsg->pCont;
|
SResFetchReq *msg = pMsg->pCont;
|
||||||
SQWorker * mgmt = (SQWorker *)qWorkerMgmt;
|
SQWorker *mgmt = (SQWorker *)qWorkerMgmt;
|
||||||
|
|
||||||
qwUpdateTimeInQueue(mgmt, ts, FETCH_QUEUE);
|
qwUpdateTimeInQueue(mgmt, ts, FETCH_QUEUE);
|
||||||
QW_STAT_INC(mgmt->stat.msgStat.fetchProcessed, 1);
|
QW_STAT_INC(mgmt->stat.msgStat.fetchProcessed, 1);
|
||||||
|
@ -472,7 +479,7 @@ int32_t qWorkerProcessFetchMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg, int
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t qWorkerProcessRspMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg, int64_t ts) {
|
int32_t qWorkerProcessRspMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg, int64_t ts) {
|
||||||
SQWorker * mgmt = (SQWorker *)qWorkerMgmt;
|
SQWorker *mgmt = (SQWorker *)qWorkerMgmt;
|
||||||
if (mgmt) {
|
if (mgmt) {
|
||||||
qwUpdateTimeInQueue(mgmt, ts, FETCH_QUEUE);
|
qwUpdateTimeInQueue(mgmt, ts, FETCH_QUEUE);
|
||||||
QW_STAT_INC(mgmt->stat.msgStat.rspProcessed, 1);
|
QW_STAT_INC(mgmt->stat.msgStat.rspProcessed, 1);
|
||||||
|
@ -488,7 +495,7 @@ int32_t qWorkerProcessCancelMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg, in
|
||||||
return TSDB_CODE_QRY_INVALID_INPUT;
|
return TSDB_CODE_QRY_INVALID_INPUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
SQWorker * mgmt = (SQWorker *)qWorkerMgmt;
|
SQWorker *mgmt = (SQWorker *)qWorkerMgmt;
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
STaskCancelReq *msg = pMsg->pCont;
|
STaskCancelReq *msg = pMsg->pCont;
|
||||||
|
|
||||||
|
@ -531,7 +538,7 @@ int32_t qWorkerProcessDropMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg, int6
|
||||||
|
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
STaskDropReq *msg = pMsg->pCont;
|
STaskDropReq *msg = pMsg->pCont;
|
||||||
SQWorker * mgmt = (SQWorker *)qWorkerMgmt;
|
SQWorker *mgmt = (SQWorker *)qWorkerMgmt;
|
||||||
|
|
||||||
qwUpdateTimeInQueue(mgmt, ts, FETCH_QUEUE);
|
qwUpdateTimeInQueue(mgmt, ts, FETCH_QUEUE);
|
||||||
QW_STAT_INC(mgmt->stat.msgStat.dropProcessed, 1);
|
QW_STAT_INC(mgmt->stat.msgStat.dropProcessed, 1);
|
||||||
|
@ -575,7 +582,7 @@ int32_t qWorkerProcessHbMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg, int64_
|
||||||
|
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SSchedulerHbReq req = {0};
|
SSchedulerHbReq req = {0};
|
||||||
SQWorker * mgmt = (SQWorker *)qWorkerMgmt;
|
SQWorker *mgmt = (SQWorker *)qWorkerMgmt;
|
||||||
|
|
||||||
qwUpdateTimeInQueue(mgmt, ts, FETCH_QUEUE);
|
qwUpdateTimeInQueue(mgmt, ts, FETCH_QUEUE);
|
||||||
QW_STAT_INC(mgmt->stat.msgStat.hbProcessed, 1);
|
QW_STAT_INC(mgmt->stat.msgStat.hbProcessed, 1);
|
||||||
|
@ -606,7 +613,6 @@ int32_t qWorkerProcessHbMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg, int64_
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t qWorkerProcessDeleteMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg, SDeleteRes *pRes) {
|
int32_t qWorkerProcessDeleteMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg, SDeleteRes *pRes) {
|
||||||
if (NULL == node || NULL == qWorkerMgmt || NULL == pMsg) {
|
if (NULL == node || NULL == qWorkerMgmt || NULL == pMsg) {
|
||||||
QW_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
|
QW_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
|
||||||
|
@ -614,7 +620,7 @@ int32_t qWorkerProcessDeleteMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg, SD
|
||||||
|
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SVDeleteReq req = {0};
|
SVDeleteReq req = {0};
|
||||||
SQWorker * mgmt = (SQWorker *)qWorkerMgmt;
|
SQWorker *mgmt = (SQWorker *)qWorkerMgmt;
|
||||||
|
|
||||||
QW_STAT_INC(mgmt->stat.msgStat.deleteProcessed, 1);
|
QW_STAT_INC(mgmt->stat.msgStat.deleteProcessed, 1);
|
||||||
|
|
||||||
|
@ -639,5 +645,3 @@ _return:
|
||||||
|
|
||||||
QW_RET(code);
|
QW_RET(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -550,8 +550,7 @@ int64_t qwGetTimeInQueue(SQWorker *mgmt, EQueueType type) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void qwClearExpiredSch(SQWorker *mgmt, SArray *pExpiredSch) {
|
||||||
void qwClearExpiredSch(SQWorker *mgmt, SArray* pExpiredSch) {
|
|
||||||
int32_t num = taosArrayGetSize(pExpiredSch);
|
int32_t num = taosArrayGetSize(pExpiredSch);
|
||||||
for (int32_t i = 0; i < num; ++i) {
|
for (int32_t i = 0; i < num; ++i) {
|
||||||
uint64_t *sId = taosArrayGet(pExpiredSch, i);
|
uint64_t *sId = taosArrayGet(pExpiredSch, i);
|
||||||
|
@ -569,5 +568,3 @@ void qwClearExpiredSch(SQWorker *mgmt, SArray* pExpiredSch) {
|
||||||
qwReleaseScheduler(QW_WRITE, mgmt);
|
qwReleaseScheduler(QW_WRITE, mgmt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -7,9 +7,9 @@
|
||||||
#include "qwInt.h"
|
#include "qwInt.h"
|
||||||
#include "qwMsg.h"
|
#include "qwMsg.h"
|
||||||
#include "tcommon.h"
|
#include "tcommon.h"
|
||||||
|
#include "tdatablock.h"
|
||||||
#include "tmsg.h"
|
#include "tmsg.h"
|
||||||
#include "tname.h"
|
#include "tname.h"
|
||||||
#include "tdatablock.h"
|
|
||||||
|
|
||||||
SQWorkerMgmt gQwMgmt = {
|
SQWorkerMgmt gQwMgmt = {
|
||||||
.lock = 0,
|
.lock = 0,
|
||||||
|
@ -17,8 +17,8 @@ SQWorkerMgmt gQwMgmt = {
|
||||||
.qwNum = 0,
|
.qwNum = 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void freeBlock(void* param) {
|
static void freeBlock(void *param) {
|
||||||
SSDataBlock* pBlock = *(SSDataBlock**)param;
|
SSDataBlock *pBlock = *(SSDataBlock **)param;
|
||||||
blockDataDestroy(pBlock);
|
blockDataDestroy(pBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ int32_t qwExecTask(QW_FPARAMS_DEF, SQWTaskCtx *ctx, bool *queryStop) {
|
||||||
int32_t execNum = 0;
|
int32_t execNum = 0;
|
||||||
qTaskInfo_t taskHandle = ctx->taskHandle;
|
qTaskInfo_t taskHandle = ctx->taskHandle;
|
||||||
DataSinkHandle sinkHandle = ctx->sinkHandle;
|
DataSinkHandle sinkHandle = ctx->sinkHandle;
|
||||||
SLocalFetch localFetch = {(void*)mgmt, ctx->localExec, qWorkerProcessLocalFetch, ctx->explainRes};
|
SLocalFetch localFetch = {(void *)mgmt, ctx->localExec, qWorkerProcessLocalFetch, ctx->explainRes};
|
||||||
|
|
||||||
SArray *pResList = taosArrayInit(4, POINTER_BYTES);
|
SArray *pResList = taosArrayInit(4, POINTER_BYTES);
|
||||||
while (true) {
|
while (true) {
|
||||||
|
@ -1153,8 +1153,9 @@ int32_t qWorkerGetStat(SReadHandle *handle, void *qWorkerMgmt, SQWorkerStat *pSt
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t qWorkerProcessLocalQuery(void *pMgmt, uint64_t sId, uint64_t qId, uint64_t tId, int64_t rId, int32_t eId, SQWMsg *qwMsg, SArray *explainRes) {
|
int32_t qWorkerProcessLocalQuery(void *pMgmt, uint64_t sId, uint64_t qId, uint64_t tId, int64_t rId, int32_t eId,
|
||||||
SQWorker *mgmt = (SQWorker*)pMgmt;
|
SQWMsg *qwMsg, SArray *explainRes) {
|
||||||
|
SQWorker *mgmt = (SQWorker *)pMgmt;
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SQWTaskCtx *ctx = NULL;
|
SQWTaskCtx *ctx = NULL;
|
||||||
SSubplan *plan = (SSubplan *)qwMsg->msg;
|
SSubplan *plan = (SSubplan *)qwMsg->msg;
|
||||||
|
@ -1212,8 +1213,9 @@ _return:
|
||||||
QW_RET(code);
|
QW_RET(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t qWorkerProcessLocalFetch(void *pMgmt, uint64_t sId, uint64_t qId, uint64_t tId, int64_t rId, int32_t eId, void** pRsp, SArray* explainRes) {
|
int32_t qWorkerProcessLocalFetch(void *pMgmt, uint64_t sId, uint64_t qId, uint64_t tId, int64_t rId, int32_t eId,
|
||||||
SQWorker *mgmt = (SQWorker*)pMgmt;
|
void **pRsp, SArray *explainRes) {
|
||||||
|
SQWorker *mgmt = (SQWorker *)pMgmt;
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
int32_t dataLen = 0;
|
int32_t dataLen = 0;
|
||||||
SQWTaskCtx *ctx = NULL;
|
SQWTaskCtx *ctx = NULL;
|
||||||
|
@ -1259,5 +1261,3 @@ _return:
|
||||||
|
|
||||||
QW_RET(code);
|
QW_RET(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -32,18 +32,17 @@
|
||||||
#endif
|
#endif
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
|
|
||||||
#include "tglobal.h"
|
#include "dataSinkMgt.h"
|
||||||
#include "taos.h"
|
#include "executor.h"
|
||||||
#include "tdef.h"
|
|
||||||
#include "tvariant.h"
|
|
||||||
#include "tdatablock.h"
|
|
||||||
#include "trpc.h"
|
|
||||||
#include "planner.h"
|
#include "planner.h"
|
||||||
#include "qworker.h"
|
#include "qworker.h"
|
||||||
#include "stub.h"
|
#include "stub.h"
|
||||||
#include "executor.h"
|
#include "taos.h"
|
||||||
#include "dataSinkMgt.h"
|
#include "tdatablock.h"
|
||||||
|
#include "tdef.h"
|
||||||
|
#include "tglobal.h"
|
||||||
|
#include "trpc.h"
|
||||||
|
#include "tvariant.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
@ -68,7 +67,6 @@ tsem_t qwtTestQuerySem;
|
||||||
tsem_t qwtTestFetchSem;
|
tsem_t qwtTestFetchSem;
|
||||||
int32_t qwtTestQuitThreadNum = 0;
|
int32_t qwtTestQuitThreadNum = 0;
|
||||||
|
|
||||||
|
|
||||||
int32_t qwtTestQueryQueueRIdx = 0;
|
int32_t qwtTestQueryQueueRIdx = 0;
|
||||||
int32_t qwtTestQueryQueueWIdx = 0;
|
int32_t qwtTestQueryQueueWIdx = 0;
|
||||||
int32_t qwtTestQueryQueueNum = 0;
|
int32_t qwtTestQueryQueueNum = 0;
|
||||||
|
@ -81,14 +79,12 @@ int32_t qwtTestFetchQueueNum = 0;
|
||||||
SRWLatch qwtTestFetchQueueLock = 0;
|
SRWLatch qwtTestFetchQueueLock = 0;
|
||||||
struct SRpcMsg *qwtTestFetchQueue[qwtTestFetchQueueSize] = {0};
|
struct SRpcMsg *qwtTestFetchQueue[qwtTestFetchQueueSize] = {0};
|
||||||
|
|
||||||
|
|
||||||
int32_t qwtTestSinkBlockNum = 0;
|
int32_t qwtTestSinkBlockNum = 0;
|
||||||
int32_t qwtTestSinkMaxBlockNum = 0;
|
int32_t qwtTestSinkMaxBlockNum = 0;
|
||||||
bool qwtTestSinkQueryEnd = false;
|
bool qwtTestSinkQueryEnd = false;
|
||||||
SRWLatch qwtTestSinkLock = 0;
|
SRWLatch qwtTestSinkLock = 0;
|
||||||
int32_t qwtTestSinkLastLen = 0;
|
int32_t qwtTestSinkLastLen = 0;
|
||||||
|
|
||||||
|
|
||||||
SSubQueryMsg qwtqueryMsg = {0};
|
SSubQueryMsg qwtqueryMsg = {0};
|
||||||
SRpcMsg qwtfetchRpc = {0};
|
SRpcMsg qwtfetchRpc = {0};
|
||||||
SResFetchReq qwtfetchMsg = {0};
|
SResFetchReq qwtfetchMsg = {0};
|
||||||
|
@ -98,7 +94,6 @@ SRpcMsg qwtdropRpc = {0};
|
||||||
STaskDropReq qwtdropMsg = {0};
|
STaskDropReq qwtdropMsg = {0};
|
||||||
SSchTasksStatusReq qwtstatusMsg = {0};
|
SSchTasksStatusReq qwtstatusMsg = {0};
|
||||||
|
|
||||||
|
|
||||||
void qwtInitLogFile() {
|
void qwtInitLogFile() {
|
||||||
if (!qwtEnableLog) {
|
if (!qwtEnableLog) {
|
||||||
return;
|
return;
|
||||||
|
@ -113,7 +108,6 @@ void qwtInitLogFile() {
|
||||||
if (taosInitLog(defaultLogFileNamePrefix, maxLogFileNum) < 0) {
|
if (taosInitLog(defaultLogFileNamePrefix, maxLogFileNum) < 0) {
|
||||||
printf("failed to open log file in directory:%s\n", tsLogDir);
|
printf("failed to open log file in directory:%s\n", tsLogDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void qwtBuildQueryReqMsg(SRpcMsg *queryRpc) {
|
void qwtBuildQueryReqMsg(SRpcMsg *queryRpc) {
|
||||||
|
@ -145,7 +139,7 @@ void qwtBuildDropReqMsg(STaskDropReq *dropMsg, SRpcMsg *dropRpc) {
|
||||||
dropRpc->contLen = sizeof(STaskDropReq);
|
dropRpc->contLen = sizeof(STaskDropReq);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t qwtStringToPlan(const char* str, SSubplan** subplan) {
|
int32_t qwtStringToPlan(const char *str, SSubplan **subplan) {
|
||||||
*subplan = (SSubplan *)0x1;
|
*subplan = (SSubplan *)0x1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -194,13 +188,9 @@ int32_t qwtPutReqToQueue(void *node, EQueueType qtype, struct SRpcMsg *pMsg) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void qwtSendReqToDnode(void* pVnode, struct SEpSet* epSet, struct SRpcMsg* pReq) {
|
void qwtSendReqToDnode(void *pVnode, struct SEpSet *epSet, struct SRpcMsg *pReq) {}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void qwtRpcSendResponse(const SRpcMsg *pRsp) {
|
void qwtRpcSendResponse(const SRpcMsg *pRsp) {
|
||||||
|
|
||||||
switch (pRsp->msgType) {
|
switch (pRsp->msgType) {
|
||||||
case TDMT_SCH_QUERY_RSP:
|
case TDMT_SCH_QUERY_RSP:
|
||||||
case TDMT_SCH_MERGE_QUERY_RSP: {
|
case TDMT_SCH_MERGE_QUERY_RSP: {
|
||||||
|
@ -240,24 +230,24 @@ void qwtRpcSendResponse(const SRpcMsg *pRsp) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t qwtCreateExecTask(void* tsdb, int32_t vgId, uint64_t taskId, struct SSubplan* pPlan, qTaskInfo_t* pTaskInfo, DataSinkHandle* handle) {
|
int32_t qwtCreateExecTask(void *tsdb, int32_t vgId, uint64_t taskId, struct SSubplan *pPlan, qTaskInfo_t *pTaskInfo,
|
||||||
|
DataSinkHandle *handle) {
|
||||||
qwtTestSinkBlockNum = 0;
|
qwtTestSinkBlockNum = 0;
|
||||||
qwtTestSinkMaxBlockNum = taosRand() % 100 + 1;
|
qwtTestSinkMaxBlockNum = taosRand() % 100 + 1;
|
||||||
qwtTestSinkQueryEnd = false;
|
qwtTestSinkQueryEnd = false;
|
||||||
|
|
||||||
*pTaskInfo = (qTaskInfo_t)((char*)qwtTestCaseIdx+1);
|
*pTaskInfo = (qTaskInfo_t)((char *)qwtTestCaseIdx + 1);
|
||||||
*handle = (DataSinkHandle)((char*)qwtTestCaseIdx+2);
|
*handle = (DataSinkHandle)((char *)qwtTestCaseIdx + 2);
|
||||||
|
|
||||||
++qwtTestCaseIdx;
|
++qwtTestCaseIdx;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t qwtExecTask(qTaskInfo_t tinfo, SSDataBlock** pRes, uint64_t *useconds) {
|
int32_t qwtExecTask(qTaskInfo_t tinfo, SSDataBlock **pRes, uint64_t *useconds) {
|
||||||
int32_t endExec = 0;
|
int32_t endExec = 0;
|
||||||
|
|
||||||
if (NULL == tinfo) {
|
if (NULL == tinfo) {
|
||||||
|
@ -284,7 +274,7 @@ int32_t qwtExecTask(qTaskInfo_t tinfo, SSDataBlock** pRes, uint64_t *useconds) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (endExec) {
|
if (endExec) {
|
||||||
*pRes = (SSDataBlock*)taosMemoryCalloc(1, sizeof(SSDataBlock));
|
*pRes = (SSDataBlock *)taosMemoryCalloc(1, sizeof(SSDataBlock));
|
||||||
(*pRes)->info.rows = taosRand() % 1000 + 1;
|
(*pRes)->info.rows = taosRand() % 1000 + 1;
|
||||||
} else {
|
} else {
|
||||||
*pRes = NULL;
|
*pRes = NULL;
|
||||||
|
@ -295,15 +285,11 @@ int32_t qwtExecTask(qTaskInfo_t tinfo, SSDataBlock** pRes, uint64_t *useconds) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t qwtKillTask(qTaskInfo_t qinfo) {
|
int32_t qwtKillTask(qTaskInfo_t qinfo) { return 0; }
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void qwtDestroyTask(qTaskInfo_t qHandle) {
|
void qwtDestroyTask(qTaskInfo_t qHandle) {}
|
||||||
}
|
|
||||||
|
|
||||||
|
int32_t qwtPutDataBlock(DataSinkHandle handle, const SInputData *pInput, bool *pContinue) {
|
||||||
int32_t qwtPutDataBlock(DataSinkHandle handle, const SInputData* pInput, bool* pContinue) {
|
|
||||||
if (NULL == handle || NULL == pInput || NULL == pContinue) {
|
if (NULL == handle || NULL == pInput || NULL == pContinue) {
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
|
@ -332,7 +318,7 @@ void qwtEndPut(DataSinkHandle handle, uint64_t useconds) {
|
||||||
qwtTestSinkQueryEnd = true;
|
qwtTestSinkQueryEnd = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void qwtGetDataLength(DataSinkHandle handle, int64_t* pLen, bool* pQueryEnd) {
|
void qwtGetDataLength(DataSinkHandle handle, int64_t *pLen, bool *pQueryEnd) {
|
||||||
static int32_t in = 0;
|
static int32_t in = 0;
|
||||||
|
|
||||||
if (in > 0) {
|
if (in > 0) {
|
||||||
|
@ -360,7 +346,7 @@ void qwtGetDataLength(DataSinkHandle handle, int64_t* pLen, bool* pQueryEnd) {
|
||||||
atomic_sub_fetch_32(&in, 1);
|
atomic_sub_fetch_32(&in, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t qwtGetDataBlock(DataSinkHandle handle, SOutputData* pOutput) {
|
int32_t qwtGetDataBlock(DataSinkHandle handle, SOutputData *pOutput) {
|
||||||
taosWLockLatch(&qwtTestSinkLock);
|
taosWLockLatch(&qwtTestSinkLock);
|
||||||
if (qwtTestSinkLastLen > 0) {
|
if (qwtTestSinkLastLen > 0) {
|
||||||
pOutput->numOfRows = taosRand() % 10 + 1;
|
pOutput->numOfRows = taosRand() % 10 + 1;
|
||||||
|
@ -368,7 +354,7 @@ int32_t qwtGetDataBlock(DataSinkHandle handle, SOutputData* pOutput) {
|
||||||
pOutput->queryEnd = qwtTestSinkQueryEnd;
|
pOutput->queryEnd = qwtTestSinkQueryEnd;
|
||||||
if (qwtTestSinkBlockNum == 0) {
|
if (qwtTestSinkBlockNum == 0) {
|
||||||
pOutput->bufStatus = DS_BUF_EMPTY;
|
pOutput->bufStatus = DS_BUF_EMPTY;
|
||||||
} else if (qwtTestSinkBlockNum <= qwtTestSinkMaxBlockNum*0.5) {
|
} else if (qwtTestSinkBlockNum <= qwtTestSinkMaxBlockNum * 0.5) {
|
||||||
pOutput->bufStatus = DS_BUF_LOW;
|
pOutput->bufStatus = DS_BUF_LOW;
|
||||||
} else {
|
} else {
|
||||||
pOutput->bufStatus = DS_BUF_FULL;
|
pOutput->bufStatus = DS_BUF_FULL;
|
||||||
|
@ -382,7 +368,7 @@ int32_t qwtGetDataBlock(DataSinkHandle handle, SOutputData* pOutput) {
|
||||||
pOutput->queryEnd = qwtTestSinkQueryEnd;
|
pOutput->queryEnd = qwtTestSinkQueryEnd;
|
||||||
if (qwtTestSinkBlockNum == 0) {
|
if (qwtTestSinkBlockNum == 0) {
|
||||||
pOutput->bufStatus = DS_BUF_EMPTY;
|
pOutput->bufStatus = DS_BUF_EMPTY;
|
||||||
} else if (qwtTestSinkBlockNum <= qwtTestSinkMaxBlockNum*0.5) {
|
} else if (qwtTestSinkBlockNum <= qwtTestSinkMaxBlockNum * 0.5) {
|
||||||
pOutput->bufStatus = DS_BUF_LOW;
|
pOutput->bufStatus = DS_BUF_LOW;
|
||||||
} else {
|
} else {
|
||||||
pOutput->bufStatus = DS_BUF_FULL;
|
pOutput->bufStatus = DS_BUF_FULL;
|
||||||
|
@ -397,11 +383,7 @@ int32_t qwtGetDataBlock(DataSinkHandle handle, SOutputData* pOutput) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void qwtDestroyDataSinker(DataSinkHandle handle) {
|
void qwtDestroyDataSinker(DataSinkHandle handle) {}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void stubSetStringToPlan() {
|
void stubSetStringToPlan() {
|
||||||
static Stub stub;
|
static Stub stub;
|
||||||
|
@ -409,15 +391,15 @@ void stubSetStringToPlan() {
|
||||||
{
|
{
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
AddrAny any;
|
AddrAny any;
|
||||||
std::map<std::string,void*> result;
|
std::map<std::string, void *> result;
|
||||||
any.get_func_addr("qStringToSubplan", result);
|
any.get_func_addr("qStringToSubplan", result);
|
||||||
#endif
|
#endif
|
||||||
#ifdef LINUX
|
#ifdef LINUX
|
||||||
AddrAny any("libplanner.so");
|
AddrAny any("libplanner.so");
|
||||||
std::map<std::string,void*> result;
|
std::map<std::string, void *> result;
|
||||||
any.get_global_func_addr_dynsym("^qStringToSubplan$", result);
|
any.get_global_func_addr_dynsym("^qStringToSubplan$", result);
|
||||||
#endif
|
#endif
|
||||||
for (const auto& f : result) {
|
for (const auto &f : result) {
|
||||||
stub.set(f.second, qwtStringToPlan);
|
stub.set(f.second, qwtStringToPlan);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -429,37 +411,35 @@ void stubSetExecTask() {
|
||||||
{
|
{
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
AddrAny any;
|
AddrAny any;
|
||||||
std::map<std::string,void*> result;
|
std::map<std::string, void *> result;
|
||||||
any.get_func_addr("qExecTask", result);
|
any.get_func_addr("qExecTask", result);
|
||||||
#endif
|
#endif
|
||||||
#ifdef LINUX
|
#ifdef LINUX
|
||||||
AddrAny any("libexecutor.so");
|
AddrAny any("libexecutor.so");
|
||||||
std::map<std::string,void*> result;
|
std::map<std::string, void *> result;
|
||||||
any.get_global_func_addr_dynsym("^qExecTask$", result);
|
any.get_global_func_addr_dynsym("^qExecTask$", result);
|
||||||
#endif
|
#endif
|
||||||
for (const auto& f : result) {
|
for (const auto &f : result) {
|
||||||
stub.set(f.second, qwtExecTask);
|
stub.set(f.second, qwtExecTask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void stubSetCreateExecTask() {
|
void stubSetCreateExecTask() {
|
||||||
static Stub stub;
|
static Stub stub;
|
||||||
stub.set(qCreateExecTask, qwtCreateExecTask);
|
stub.set(qCreateExecTask, qwtCreateExecTask);
|
||||||
{
|
{
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
AddrAny any;
|
AddrAny any;
|
||||||
std::map<std::string,void*> result;
|
std::map<std::string, void *> result;
|
||||||
any.get_func_addr("qCreateExecTask", result);
|
any.get_func_addr("qCreateExecTask", result);
|
||||||
#endif
|
#endif
|
||||||
#ifdef LINUX
|
#ifdef LINUX
|
||||||
AddrAny any("libexecutor.so");
|
AddrAny any("libexecutor.so");
|
||||||
std::map<std::string,void*> result;
|
std::map<std::string, void *> result;
|
||||||
any.get_global_func_addr_dynsym("^qCreateExecTask$", result);
|
any.get_global_func_addr_dynsym("^qCreateExecTask$", result);
|
||||||
#endif
|
#endif
|
||||||
for (const auto& f : result) {
|
for (const auto &f : result) {
|
||||||
stub.set(f.second, qwtCreateExecTask);
|
stub.set(f.second, qwtCreateExecTask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -471,15 +451,15 @@ void stubSetAsyncKillTask() {
|
||||||
{
|
{
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
AddrAny any;
|
AddrAny any;
|
||||||
std::map<std::string,void*> result;
|
std::map<std::string, void *> result;
|
||||||
any.get_func_addr("qAsyncKillTask", result);
|
any.get_func_addr("qAsyncKillTask", result);
|
||||||
#endif
|
#endif
|
||||||
#ifdef LINUX
|
#ifdef LINUX
|
||||||
AddrAny any("libexecutor.so");
|
AddrAny any("libexecutor.so");
|
||||||
std::map<std::string,void*> result;
|
std::map<std::string, void *> result;
|
||||||
any.get_global_func_addr_dynsym("^qAsyncKillTask$", result);
|
any.get_global_func_addr_dynsym("^qAsyncKillTask$", result);
|
||||||
#endif
|
#endif
|
||||||
for (const auto& f : result) {
|
for (const auto &f : result) {
|
||||||
stub.set(f.second, qwtKillTask);
|
stub.set(f.second, qwtKillTask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -491,36 +471,35 @@ void stubSetDestroyTask() {
|
||||||
{
|
{
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
AddrAny any;
|
AddrAny any;
|
||||||
std::map<std::string,void*> result;
|
std::map<std::string, void *> result;
|
||||||
any.get_func_addr("qDestroyTask", result);
|
any.get_func_addr("qDestroyTask", result);
|
||||||
#endif
|
#endif
|
||||||
#ifdef LINUX
|
#ifdef LINUX
|
||||||
AddrAny any("libexecutor.so");
|
AddrAny any("libexecutor.so");
|
||||||
std::map<std::string,void*> result;
|
std::map<std::string, void *> result;
|
||||||
any.get_global_func_addr_dynsym("^qDestroyTask$", result);
|
any.get_global_func_addr_dynsym("^qDestroyTask$", result);
|
||||||
#endif
|
#endif
|
||||||
for (const auto& f : result) {
|
for (const auto &f : result) {
|
||||||
stub.set(f.second, qwtDestroyTask);
|
stub.set(f.second, qwtDestroyTask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void stubSetDestroyDataSinker() {
|
void stubSetDestroyDataSinker() {
|
||||||
static Stub stub;
|
static Stub stub;
|
||||||
stub.set(dsDestroyDataSinker, qwtDestroyDataSinker);
|
stub.set(dsDestroyDataSinker, qwtDestroyDataSinker);
|
||||||
{
|
{
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
AddrAny any;
|
AddrAny any;
|
||||||
std::map<std::string,void*> result;
|
std::map<std::string, void *> result;
|
||||||
any.get_func_addr("dsDestroyDataSinker", result);
|
any.get_func_addr("dsDestroyDataSinker", result);
|
||||||
#endif
|
#endif
|
||||||
#ifdef LINUX
|
#ifdef LINUX
|
||||||
AddrAny any("libexecutor.so");
|
AddrAny any("libexecutor.so");
|
||||||
std::map<std::string,void*> result;
|
std::map<std::string, void *> result;
|
||||||
any.get_global_func_addr_dynsym("^dsDestroyDataSinker$", result);
|
any.get_global_func_addr_dynsym("^dsDestroyDataSinker$", result);
|
||||||
#endif
|
#endif
|
||||||
for (const auto& f : result) {
|
for (const auto &f : result) {
|
||||||
stub.set(f.second, qwtDestroyDataSinker);
|
stub.set(f.second, qwtDestroyDataSinker);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -532,15 +511,15 @@ void stubSetGetDataLength() {
|
||||||
{
|
{
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
AddrAny any;
|
AddrAny any;
|
||||||
std::map<std::string,void*> result;
|
std::map<std::string, void *> result;
|
||||||
any.get_func_addr("dsGetDataLength", result);
|
any.get_func_addr("dsGetDataLength", result);
|
||||||
#endif
|
#endif
|
||||||
#ifdef LINUX
|
#ifdef LINUX
|
||||||
AddrAny any("libexecutor.so");
|
AddrAny any("libexecutor.so");
|
||||||
std::map<std::string,void*> result;
|
std::map<std::string, void *> result;
|
||||||
any.get_global_func_addr_dynsym("^dsGetDataLength$", result);
|
any.get_global_func_addr_dynsym("^dsGetDataLength$", result);
|
||||||
#endif
|
#endif
|
||||||
for (const auto& f : result) {
|
for (const auto &f : result) {
|
||||||
stub.set(f.second, qwtGetDataLength);
|
stub.set(f.second, qwtGetDataLength);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -552,15 +531,15 @@ void stubSetEndPut() {
|
||||||
{
|
{
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
AddrAny any;
|
AddrAny any;
|
||||||
std::map<std::string,void*> result;
|
std::map<std::string, void *> result;
|
||||||
any.get_func_addr("dsEndPut", result);
|
any.get_func_addr("dsEndPut", result);
|
||||||
#endif
|
#endif
|
||||||
#ifdef LINUX
|
#ifdef LINUX
|
||||||
AddrAny any("libexecutor.so");
|
AddrAny any("libexecutor.so");
|
||||||
std::map<std::string,void*> result;
|
std::map<std::string, void *> result;
|
||||||
any.get_global_func_addr_dynsym("^dsEndPut$", result);
|
any.get_global_func_addr_dynsym("^dsEndPut$", result);
|
||||||
#endif
|
#endif
|
||||||
for (const auto& f : result) {
|
for (const auto &f : result) {
|
||||||
stub.set(f.second, qwtEndPut);
|
stub.set(f.second, qwtEndPut);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -572,15 +551,15 @@ void stubSetPutDataBlock() {
|
||||||
{
|
{
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
AddrAny any;
|
AddrAny any;
|
||||||
std::map<std::string,void*> result;
|
std::map<std::string, void *> result;
|
||||||
any.get_func_addr("dsPutDataBlock", result);
|
any.get_func_addr("dsPutDataBlock", result);
|
||||||
#endif
|
#endif
|
||||||
#ifdef LINUX
|
#ifdef LINUX
|
||||||
AddrAny any("libexecutor.so");
|
AddrAny any("libexecutor.so");
|
||||||
std::map<std::string,void*> result;
|
std::map<std::string, void *> result;
|
||||||
any.get_global_func_addr_dynsym("^dsPutDataBlock$", result);
|
any.get_global_func_addr_dynsym("^dsPutDataBlock$", result);
|
||||||
#endif
|
#endif
|
||||||
for (const auto& f : result) {
|
for (const auto &f : result) {
|
||||||
stub.set(f.second, qwtPutDataBlock);
|
stub.set(f.second, qwtPutDataBlock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -592,15 +571,15 @@ void stubSetRpcSendResponse() {
|
||||||
{
|
{
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
AddrAny any;
|
AddrAny any;
|
||||||
std::map<std::string,void*> result;
|
std::map<std::string, void *> result;
|
||||||
any.get_func_addr("rpcSendResponse", result);
|
any.get_func_addr("rpcSendResponse", result);
|
||||||
#endif
|
#endif
|
||||||
#ifdef LINUX
|
#ifdef LINUX
|
||||||
AddrAny any("libtransport.so");
|
AddrAny any("libtransport.so");
|
||||||
std::map<std::string,void*> result;
|
std::map<std::string, void *> result;
|
||||||
any.get_global_func_addr_dynsym("^rpcSendResponse$", result);
|
any.get_global_func_addr_dynsym("^rpcSendResponse$", result);
|
||||||
#endif
|
#endif
|
||||||
for (const auto& f : result) {
|
for (const auto &f : result) {
|
||||||
stub.set(f.second, qwtRpcSendResponse);
|
stub.set(f.second, qwtRpcSendResponse);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -612,21 +591,20 @@ void stubSetGetDataBlock() {
|
||||||
{
|
{
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
AddrAny any;
|
AddrAny any;
|
||||||
std::map<std::string,void*> result;
|
std::map<std::string, void *> result;
|
||||||
any.get_func_addr("dsGetDataBlock", result);
|
any.get_func_addr("dsGetDataBlock", result);
|
||||||
#endif
|
#endif
|
||||||
#ifdef LINUX
|
#ifdef LINUX
|
||||||
AddrAny any("libtransport.so");
|
AddrAny any("libtransport.so");
|
||||||
std::map<std::string,void*> result;
|
std::map<std::string, void *> result;
|
||||||
any.get_global_func_addr_dynsym("^dsGetDataBlock$", result);
|
any.get_global_func_addr_dynsym("^dsGetDataBlock$", result);
|
||||||
#endif
|
#endif
|
||||||
for (const auto& f : result) {
|
for (const auto &f : result) {
|
||||||
stub.set(f.second, qwtGetDataBlock);
|
stub.set(f.second, qwtGetDataBlock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void *queryThread(void *param) {
|
void *queryThread(void *param) {
|
||||||
SRpcMsg queryRpc = {0};
|
SRpcMsg queryRpc = {0};
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
@ -638,7 +616,7 @@ void *queryThread(void *param) {
|
||||||
qwtBuildQueryReqMsg(&queryRpc);
|
qwtBuildQueryReqMsg(&queryRpc);
|
||||||
qWorkerProcessQueryMsg(mockPointer, mgmt, &queryRpc, 0);
|
qWorkerProcessQueryMsg(mockPointer, mgmt, &queryRpc, 0);
|
||||||
if (qwtTestEnableSleep) {
|
if (qwtTestEnableSleep) {
|
||||||
taosUsleep(taosRand()%5);
|
taosUsleep(taosRand() % 5);
|
||||||
}
|
}
|
||||||
if (++n % qwtTestPrintNum == 0) {
|
if (++n % qwtTestPrintNum == 0) {
|
||||||
printf("query:%d\n", n);
|
printf("query:%d\n", n);
|
||||||
|
@ -660,7 +638,7 @@ void *fetchThread(void *param) {
|
||||||
qwtBuildFetchReqMsg(&fetchMsg, &fetchRpc);
|
qwtBuildFetchReqMsg(&fetchMsg, &fetchRpc);
|
||||||
code = qWorkerProcessFetchMsg(mockPointer, mgmt, &fetchRpc, 0);
|
code = qWorkerProcessFetchMsg(mockPointer, mgmt, &fetchRpc, 0);
|
||||||
if (qwtTestEnableSleep) {
|
if (qwtTestEnableSleep) {
|
||||||
taosUsleep(taosRand()%5);
|
taosUsleep(taosRand() % 5);
|
||||||
}
|
}
|
||||||
if (++n % qwtTestPrintNum == 0) {
|
if (++n % qwtTestPrintNum == 0) {
|
||||||
printf("fetch:%d\n", n);
|
printf("fetch:%d\n", n);
|
||||||
|
@ -682,7 +660,7 @@ void *dropThread(void *param) {
|
||||||
qwtBuildDropReqMsg(&dropMsg, &dropRpc);
|
qwtBuildDropReqMsg(&dropMsg, &dropRpc);
|
||||||
code = qWorkerProcessDropMsg(mockPointer, mgmt, &dropRpc, 0);
|
code = qWorkerProcessDropMsg(mockPointer, mgmt, &dropRpc, 0);
|
||||||
if (qwtTestEnableSleep) {
|
if (qwtTestEnableSleep) {
|
||||||
taosUsleep(taosRand()%5);
|
taosUsleep(taosRand() % 5);
|
||||||
}
|
}
|
||||||
if (++n % qwtTestPrintNum == 0) {
|
if (++n % qwtTestPrintNum == 0) {
|
||||||
printf("drop:%d\n", n);
|
printf("drop:%d\n", n);
|
||||||
|
@ -711,7 +689,6 @@ void *qwtclientThread(void *param) {
|
||||||
taosUsleep(1);
|
taosUsleep(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (++n % qwtTestPrintNum == 0) {
|
if (++n % qwtTestPrintNum == 0) {
|
||||||
printf("case run:%d\n", n);
|
printf("case run:%d\n", n);
|
||||||
}
|
}
|
||||||
|
@ -749,7 +726,6 @@ void *queryQueueThread(void *param) {
|
||||||
qwtTestQueryQueueNum--;
|
qwtTestQueryQueueNum--;
|
||||||
taosWUnLockLatch(&qwtTestQueryQueueLock);
|
taosWUnLockLatch(&qwtTestQueryQueueLock);
|
||||||
|
|
||||||
|
|
||||||
if (qwtTestEnableSleep && qwtTestReqMaxDelayUsec > 0) {
|
if (qwtTestEnableSleep && qwtTestReqMaxDelayUsec > 0) {
|
||||||
int32_t delay = taosRand() % qwtTestReqMaxDelayUsec;
|
int32_t delay = taosRand() % qwtTestReqMaxDelayUsec;
|
||||||
|
|
||||||
|
@ -843,10 +819,7 @@ void *fetchQueueThread(void *param) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
TEST(seqTest, normalCase) {
|
TEST(seqTest, normalCase) {
|
||||||
void *mgmt = NULL;
|
void *mgmt = NULL;
|
||||||
|
@ -883,8 +856,8 @@ TEST(seqTest, normalCase) {
|
||||||
code = qWorkerProcessQueryMsg(mockPointer, mgmt, &queryRpc, 0);
|
code = qWorkerProcessQueryMsg(mockPointer, mgmt, &queryRpc, 0);
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
//code = qWorkerProcessReadyMsg(mockPointer, mgmt, &readyRpc);
|
// code = qWorkerProcessReadyMsg(mockPointer, mgmt, &readyRpc);
|
||||||
//ASSERT_EQ(code, 0);
|
// ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
code = qWorkerProcessFetchMsg(mockPointer, mgmt, &fetchRpc, 0);
|
code = qWorkerProcessFetchMsg(mockPointer, mgmt, &fetchRpc, 0);
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
@ -958,32 +931,32 @@ TEST(seqTest, randCase) {
|
||||||
while (true) {
|
while (true) {
|
||||||
int32_t r = taosRand() % maxr;
|
int32_t r = taosRand() % maxr;
|
||||||
|
|
||||||
if (r >= 0 && r < maxr/5) {
|
if (r >= 0 && r < maxr / 5) {
|
||||||
printf("Query,%d\n", t++);
|
printf("Query,%d\n", t++);
|
||||||
qwtBuildQueryReqMsg(&queryRpc);
|
qwtBuildQueryReqMsg(&queryRpc);
|
||||||
code = qWorkerProcessQueryMsg(mockPointer, mgmt, &queryRpc, 0);
|
code = qWorkerProcessQueryMsg(mockPointer, mgmt, &queryRpc, 0);
|
||||||
} else if (r >= maxr/5 && r < maxr * 2/5) {
|
} else if (r >= maxr / 5 && r < maxr * 2 / 5) {
|
||||||
//printf("Ready,%d\n", t++);
|
// printf("Ready,%d\n", t++);
|
||||||
//qwtBuildReadyReqMsg(&readyMsg, &readyRpc);
|
// qwtBuildReadyReqMsg(&readyMsg, &readyRpc);
|
||||||
//code = qWorkerProcessReadyMsg(mockPointer, mgmt, &readyRpc);
|
// code = qWorkerProcessReadyMsg(mockPointer, mgmt, &readyRpc);
|
||||||
//if (qwtTestEnableSleep) {
|
// if (qwtTestEnableSleep) {
|
||||||
// taosUsleep(1);
|
// taosUsleep(1);
|
||||||
//}
|
// }
|
||||||
} else if (r >= maxr * 2/5 && r < maxr* 3/5) {
|
} else if (r >= maxr * 2 / 5 && r < maxr * 3 / 5) {
|
||||||
printf("Fetch,%d\n", t++);
|
printf("Fetch,%d\n", t++);
|
||||||
qwtBuildFetchReqMsg(&fetchMsg, &fetchRpc);
|
qwtBuildFetchReqMsg(&fetchMsg, &fetchRpc);
|
||||||
code = qWorkerProcessFetchMsg(mockPointer, mgmt, &fetchRpc, 0);
|
code = qWorkerProcessFetchMsg(mockPointer, mgmt, &fetchRpc, 0);
|
||||||
if (qwtTestEnableSleep) {
|
if (qwtTestEnableSleep) {
|
||||||
taosUsleep(1);
|
taosUsleep(1);
|
||||||
}
|
}
|
||||||
} else if (r >= maxr * 3/5 && r < maxr * 4/5) {
|
} else if (r >= maxr * 3 / 5 && r < maxr * 4 / 5) {
|
||||||
printf("Drop,%d\n", t++);
|
printf("Drop,%d\n", t++);
|
||||||
qwtBuildDropReqMsg(&dropMsg, &dropRpc);
|
qwtBuildDropReqMsg(&dropMsg, &dropRpc);
|
||||||
code = qWorkerProcessDropMsg(mockPointer, mgmt, &dropRpc, 0);
|
code = qWorkerProcessDropMsg(mockPointer, mgmt, &dropRpc, 0);
|
||||||
if (qwtTestEnableSleep) {
|
if (qwtTestEnableSleep) {
|
||||||
taosUsleep(1);
|
taosUsleep(1);
|
||||||
}
|
}
|
||||||
} else if (r >= maxr * 4/5 && r < maxr-1) {
|
} else if (r >= maxr * 4 / 5 && r < maxr - 1) {
|
||||||
printf("Status,%d\n", t++);
|
printf("Status,%d\n", t++);
|
||||||
if (qwtTestEnableSleep) {
|
if (qwtTestEnableSleep) {
|
||||||
taosUsleep(1);
|
taosUsleep(1);
|
||||||
|
@ -1027,9 +1000,9 @@ TEST(seqTest, multithreadRand) {
|
||||||
TdThreadAttr thattr;
|
TdThreadAttr thattr;
|
||||||
taosThreadAttrInit(&thattr);
|
taosThreadAttrInit(&thattr);
|
||||||
|
|
||||||
TdThread t1,t2,t3,t4,t5,t6;
|
TdThread t1, t2, t3, t4, t5, t6;
|
||||||
taosThreadCreate(&(t1), &thattr, queryThread, mgmt);
|
taosThreadCreate(&(t1), &thattr, queryThread, mgmt);
|
||||||
//taosThreadCreate(&(t2), &thattr, readyThread, NULL);
|
// taosThreadCreate(&(t2), &thattr, readyThread, NULL);
|
||||||
taosThreadCreate(&(t3), &thattr, fetchThread, NULL);
|
taosThreadCreate(&(t3), &thattr, fetchThread, NULL);
|
||||||
taosThreadCreate(&(t4), &thattr, dropThread, NULL);
|
taosThreadCreate(&(t4), &thattr, dropThread, NULL);
|
||||||
taosThreadCreate(&(t6), &thattr, fetchQueueThread, mgmt);
|
taosThreadCreate(&(t6), &thattr, fetchQueueThread, mgmt);
|
||||||
|
@ -1096,7 +1069,7 @@ TEST(rcTest, shortExecshortDelay) {
|
||||||
TdThreadAttr thattr;
|
TdThreadAttr thattr;
|
||||||
taosThreadAttrInit(&thattr);
|
taosThreadAttrInit(&thattr);
|
||||||
|
|
||||||
TdThread t1,t2,t3,t4,t5;
|
TdThread t1, t2, t3, t4, t5;
|
||||||
taosThreadCreate(&(t1), &thattr, qwtclientThread, mgmt);
|
taosThreadCreate(&(t1), &thattr, qwtclientThread, mgmt);
|
||||||
taosThreadCreate(&(t2), &thattr, queryQueueThread, mgmt);
|
taosThreadCreate(&(t2), &thattr, queryQueueThread, mgmt);
|
||||||
taosThreadCreate(&(t3), &thattr, fetchQueueThread, mgmt);
|
taosThreadCreate(&(t3), &thattr, fetchQueueThread, mgmt);
|
||||||
|
@ -1127,7 +1100,6 @@ TEST(rcTest, shortExecshortDelay) {
|
||||||
taosUsleep(10);
|
taosUsleep(10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
qwtTestQueryQueueNum = 0;
|
qwtTestQueryQueueNum = 0;
|
||||||
|
@ -1180,7 +1152,7 @@ TEST(rcTest, longExecshortDelay) {
|
||||||
TdThreadAttr thattr;
|
TdThreadAttr thattr;
|
||||||
taosThreadAttrInit(&thattr);
|
taosThreadAttrInit(&thattr);
|
||||||
|
|
||||||
TdThread t1,t2,t3,t4,t5;
|
TdThread t1, t2, t3, t4, t5;
|
||||||
taosThreadCreate(&(t1), &thattr, qwtclientThread, mgmt);
|
taosThreadCreate(&(t1), &thattr, qwtclientThread, mgmt);
|
||||||
taosThreadCreate(&(t2), &thattr, queryQueueThread, mgmt);
|
taosThreadCreate(&(t2), &thattr, queryQueueThread, mgmt);
|
||||||
taosThreadCreate(&(t3), &thattr, fetchQueueThread, mgmt);
|
taosThreadCreate(&(t3), &thattr, fetchQueueThread, mgmt);
|
||||||
|
@ -1196,7 +1168,6 @@ TEST(rcTest, longExecshortDelay) {
|
||||||
|
|
||||||
qwtTestStop = true;
|
qwtTestStop = true;
|
||||||
|
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
if (qwtTestQuitThreadNum == 3) {
|
if (qwtTestQuitThreadNum == 3) {
|
||||||
break;
|
break;
|
||||||
|
@ -1212,7 +1183,6 @@ TEST(rcTest, longExecshortDelay) {
|
||||||
taosUsleep(10);
|
taosUsleep(10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
qwtTestQueryQueueNum = 0;
|
qwtTestQueryQueueNum = 0;
|
||||||
|
@ -1227,7 +1197,6 @@ TEST(rcTest, longExecshortDelay) {
|
||||||
qWorkerDestroy(&mgmt);
|
qWorkerDestroy(&mgmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST(rcTest, shortExeclongDelay) {
|
TEST(rcTest, shortExeclongDelay) {
|
||||||
void *mgmt = NULL;
|
void *mgmt = NULL;
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
@ -1266,7 +1235,7 @@ TEST(rcTest, shortExeclongDelay) {
|
||||||
TdThreadAttr thattr;
|
TdThreadAttr thattr;
|
||||||
taosThreadAttrInit(&thattr);
|
taosThreadAttrInit(&thattr);
|
||||||
|
|
||||||
TdThread t1,t2,t3,t4,t5;
|
TdThread t1, t2, t3, t4, t5;
|
||||||
taosThreadCreate(&(t1), &thattr, qwtclientThread, mgmt);
|
taosThreadCreate(&(t1), &thattr, qwtclientThread, mgmt);
|
||||||
taosThreadCreate(&(t2), &thattr, queryQueueThread, mgmt);
|
taosThreadCreate(&(t2), &thattr, queryQueueThread, mgmt);
|
||||||
taosThreadCreate(&(t3), &thattr, fetchQueueThread, mgmt);
|
taosThreadCreate(&(t3), &thattr, fetchQueueThread, mgmt);
|
||||||
|
@ -1282,7 +1251,6 @@ TEST(rcTest, shortExeclongDelay) {
|
||||||
|
|
||||||
qwtTestStop = true;
|
qwtTestStop = true;
|
||||||
|
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
if (qwtTestQuitThreadNum == 3) {
|
if (qwtTestQuitThreadNum == 3) {
|
||||||
break;
|
break;
|
||||||
|
@ -1298,7 +1266,6 @@ TEST(rcTest, shortExeclongDelay) {
|
||||||
taosUsleep(10);
|
taosUsleep(10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
qwtTestQueryQueueNum = 0;
|
qwtTestQueryQueueNum = 0;
|
||||||
|
@ -1313,7 +1280,6 @@ TEST(rcTest, shortExeclongDelay) {
|
||||||
qWorkerDestroy(&mgmt);
|
qWorkerDestroy(&mgmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST(rcTest, dropTest) {
|
TEST(rcTest, dropTest) {
|
||||||
void *mgmt = NULL;
|
void *mgmt = NULL;
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
@ -1347,7 +1313,7 @@ TEST(rcTest, dropTest) {
|
||||||
TdThreadAttr thattr;
|
TdThreadAttr thattr;
|
||||||
taosThreadAttrInit(&thattr);
|
taosThreadAttrInit(&thattr);
|
||||||
|
|
||||||
TdThread t1,t2,t3,t4,t5;
|
TdThread t1, t2, t3, t4, t5;
|
||||||
taosThreadCreate(&(t1), &thattr, qwtclientThread, mgmt);
|
taosThreadCreate(&(t1), &thattr, qwtclientThread, mgmt);
|
||||||
taosThreadCreate(&(t2), &thattr, queryQueueThread, mgmt);
|
taosThreadCreate(&(t2), &thattr, queryQueueThread, mgmt);
|
||||||
taosThreadCreate(&(t3), &thattr, fetchQueueThread, mgmt);
|
taosThreadCreate(&(t3), &thattr, fetchQueueThread, mgmt);
|
||||||
|
@ -1367,8 +1333,7 @@ TEST(rcTest, dropTest) {
|
||||||
qWorkerDestroy(&mgmt);
|
qWorkerDestroy(&mgmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int main(int argc, char **argv) {
|
||||||
int main(int argc, char** argv) {
|
|
||||||
taosSeedRand(taosGetTimestampSec());
|
taosSeedRand(taosGetTimestampSec());
|
||||||
testing::InitGoogleTest(&argc, argv);
|
testing::InitGoogleTest(&argc, argv);
|
||||||
return RUN_ALL_TESTS();
|
return RUN_ALL_TESTS();
|
||||||
|
|
|
@ -22,8 +22,8 @@ FORMAT_DIR_LIST=(
|
||||||
"${PRJ_ROOT_DIR}/source/libs/nodes"
|
"${PRJ_ROOT_DIR}/source/libs/nodes"
|
||||||
# "${PRJ_ROOT_DIR}/source/libs/parser"
|
# "${PRJ_ROOT_DIR}/source/libs/parser"
|
||||||
"${PRJ_ROOT_DIR}/source/libs/planner"
|
"${PRJ_ROOT_DIR}/source/libs/planner"
|
||||||
# "${PRJ_ROOT_DIR}/source/libs/qcom"
|
"${PRJ_ROOT_DIR}/source/libs/qcom"
|
||||||
# "${PRJ_ROOT_DIR}/source/libs/qworker"
|
"${PRJ_ROOT_DIR}/source/libs/qworker"
|
||||||
"${PRJ_ROOT_DIR}/source/libs/scalar"
|
"${PRJ_ROOT_DIR}/source/libs/scalar"
|
||||||
"${PRJ_ROOT_DIR}/source/libs/stream"
|
"${PRJ_ROOT_DIR}/source/libs/stream"
|
||||||
"${PRJ_ROOT_DIR}/source/libs/sync"
|
"${PRJ_ROOT_DIR}/source/libs/sync"
|
||||||
|
|
Loading…
Reference in New Issue