• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

taosdata / TDengine / #5119

16 Sep 2026 01:31AM UTC coverage: 73.081% (-0.7%) from 73.739%
#5119

push

travis-ci

jbjia
test(coverage): sync from gitlab

309337 of 423280 relevant lines covered (73.08%)

67769626.34 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

76.0
/source/dnode/qnode/src/qnode.c
1
/*
2
 * Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
3
 *
4
 * This program is free software: you can use, redistribute, and/or modify
5
 * it under the terms of the GNU Affero General Public License, version 3
6
 * or later ("AGPL"), as published by the Free Software Foundation.
7
 *
8
 * This program is distributed in the hope that it will be useful, but WITHOUT
9
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
 * FITNESS FOR A PARTICULAR PURPOSE.
11
 *
12
 * You should have received a copy of the GNU Affero General Public License
13
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14
 */
15

16
#include "tqueue.h"
17

18
#include "executor.h"
19
#include "qndInt.h"
20
#include "query.h"
21
#include "qworker.h"
22

23
int32_t qndOpen(const SQnodeOpt *pOption, SQnode **pQnode) {
34,908✔
24
  *pQnode = taosMemoryCalloc(1, sizeof(SQnode));
34,908✔
25
  if (NULL == *pQnode) {
34,908✔
26
    qError("calloc SQnode failed");
×
27
    return terrno;
×
28
  }
29
  (*pQnode)->qndId = QNODE_HANDLE;
34,908✔
30

31
  int32_t code = qWorkerInit(NODE_TYPE_QNODE, (*pQnode)->qndId, (void **)&(*pQnode)->pQuery, &pOption->msgCb);
34,908✔
32
  if (TSDB_CODE_SUCCESS != code) {
34,908✔
33
    taosMemoryFreeClear(pQnode);
×
34
    return code;
×
35
  }
36

37
  (*pQnode)->msgCb = pOption->msgCb;
34,908✔
38
  return TSDB_CODE_SUCCESS;
34,908✔
39
}
40

41
void qndClose(SQnode *pQnode) {
34,908✔
42
  qWorkerDestroy((void **)&pQnode->pQuery);
34,908✔
43
  taosMemoryFree(pQnode);
34,908✔
44
}
34,908✔
45

46
int32_t qndGetLoad(SQnode *pQnode, SQnodeLoad *pLoad) {
2,671,633✔
47
  SReadHandle  handle = {.pMsgCb = &pQnode->msgCb};
2,671,633✔
48
  SQWorkerStat stat = {0};
2,671,633✔
49

50
  int32_t code = qWorkerGetStat(&handle, pQnode->pQuery, &stat);
2,671,633✔
51
  if (code) {
2,671,633✔
52
    return code;
×
53
  }
54

55
  pLoad->numOfQueryInQueue = stat.numOfQueryInQueue;
2,671,633✔
56
  pLoad->numOfFetchInQueue = stat.numOfFetchInQueue;
2,671,633✔
57
  pLoad->timeInQueryQueue = stat.timeInQueryQueue;
2,671,633✔
58
  pLoad->timeInFetchQueue = stat.timeInFetchQueue;
2,671,633✔
59
  pLoad->cacheDataSize = stat.cacheDataSize;
2,671,633✔
60
  pLoad->numOfProcessedQuery = stat.queryProcessed;
2,671,633✔
61
  pLoad->numOfProcessedCQuery = stat.cqueryProcessed;
2,671,633✔
62
  pLoad->numOfProcessedFetch = stat.fetchProcessed;
2,671,633✔
63
  pLoad->numOfProcessedDrop = stat.dropProcessed;
2,671,633✔
64
  pLoad->numOfProcessedNotify = stat.notifyProcessed;
2,671,633✔
65
  pLoad->numOfProcessedHb = stat.hbProcessed;
2,671,633✔
66
  pLoad->numOfProcessedDelete = stat.deleteProcessed;
2,671,633✔
67

68
  return 0;
2,671,633✔
69
}
70

71
int32_t qndPreprocessQueryMsg(SQnode *pQnode, SRpcMsg *pMsg) {
571,104✔
72
  int32_t qType = 0;
571,104✔
73
  if (TDMT_SCH_QUERY != pMsg->msgType && TDMT_SCH_MERGE_QUERY != pMsg->msgType) {
571,104✔
74
    return 0;
×
75
  }
76

77
  return qWorkerPreprocessQueryMsg(pQnode->pQuery, pMsg, false, &qType);
571,104✔
78
}
79

80
int32_t qndProcessQueryMsg(SQnode *pQnode, SQueueInfo *pInfo, SRpcMsg *pMsg) {
2,204,590✔
81
  int32_t     code = -1;
2,204,590✔
82
  int64_t     ts = pInfo->timestamp;
2,204,590✔
83
  SReadHandle handle = {0};
2,204,590✔
84
  handle.pMsgCb = &pQnode->msgCb;
2,204,590✔
85
  handle.pWorkerCb = pInfo->workerCb;
2,204,590✔
86
  
87
  const STraceId *trace = &pMsg->info.traceId;
2,204,590✔
88
  qDebug("qnodeId:%d, msg:%s, %p in qnode queue is processing, %" PRIx64 ":%" PRIx64, 
2,204,590✔
89
    pQnode->qndId, TMSG_INFO(pMsg->msgType), pMsg, TRACE_GET_ROOTID(trace), TRACE_GET_MSGID(trace));
90

91
  switch (pMsg->msgType) {
2,204,590✔
92
    case TDMT_SCH_QUERY:
571,104✔
93
    case TDMT_SCH_MERGE_QUERY:
94
      code = qWorkerProcessQueryMsg(&handle, pQnode->pQuery, pMsg, ts);
571,104✔
95
      break;
571,104✔
96
    case TDMT_SCH_QUERY_CONTINUE:
×
97
      code = qWorkerProcessCQueryMsg(&handle, pQnode->pQuery, pMsg, ts);
×
98
      break;
×
99
    case TDMT_SCH_FETCH:
561,618✔
100
    case TDMT_SCH_MERGE_FETCH:
101
      code = qWorkerProcessFetchMsg(pQnode, pQnode->pQuery, pMsg, ts);
561,618✔
102
      break;
561,618✔
103
    case TDMT_SCH_CANCEL_TASK:
×
104
      // code = qWorkerProcessCancelMsg(pQnode, pQnode->pQuery, pMsg, ts);
105
      break;
×
106
    case TDMT_SCH_DROP_TASK:
571,104✔
107
      code = qWorkerProcessDropMsg(pQnode, pQnode->pQuery, pMsg, ts);
571,104✔
108
      break;
571,104✔
109
    case TDMT_VND_TMQ_CONSUME:
500,764✔
110
      // code =  tqProcessConsumeReq(pQnode->pTq, pMsg);
111
      // break;
112
    case TDMT_SCH_QUERY_HEARTBEAT:
113
      code = qWorkerProcessHbMsg(pQnode, pQnode->pQuery, pMsg, ts);
500,764✔
114
      break;
500,764✔
115
    case TDMT_SCH_TASK_NOTIFY:
×
116
      code = qWorkerProcessNotifyMsg(pQnode, pQnode->pQuery, pMsg, ts);
×
117
      break;
×
118
    default:
×
119
      qError("unknown msg type:%d in qnode queue", pMsg->msgType);
×
120
      terrno = TSDB_CODE_APP_ERROR;
×
121
  }
122

123
  if (code == 0) {
2,204,590✔
124
    return TSDB_CODE_ACTION_IN_PROGRESS;
2,204,590✔
125
  } else {
126
    return code;
×
127
  }
128
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc