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

taosdata / TDengine / #4768

01 Oct 2025 04:06AM UTC coverage: 57.85% (-0.8%) from 58.606%
#4768

push

travis-ci

web-flow
Merge pull request #33171 from taosdata/merge/3.3.6tomain

merge: from 3.3.6 to main branch

137167 of 302743 branches covered (45.31%)

Branch coverage included in aggregate %.

15 of 20 new or added lines in 2 files covered. (75.0%)

12125 existing lines in 175 files now uncovered.

208282 of 294403 relevant lines covered (70.75%)

5618137.93 hits per line

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

63.56
/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) {
495✔
24
  *pQnode = taosMemoryCalloc(1, sizeof(SQnode));
495!
25
  if (NULL == *pQnode) {
495!
26
    qError("calloc SQnode failed");
×
27
    return terrno;
×
28
  }
29
  (*pQnode)->qndId = QNODE_HANDLE;
495✔
30

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

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

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

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

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

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

68
  return 0;
18,474✔
69
}
70

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

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

80
int32_t qndProcessQueryMsg(SQnode *pQnode, SQueueInfo *pInfo, SRpcMsg *pMsg) {
962,848✔
81
  int32_t     code = -1;
962,848✔
82
  int64_t     ts = pInfo->timestamp;
962,848✔
83
  SReadHandle handle = {0};
962,848✔
84
  handle.pMsgCb = &pQnode->msgCb;
962,848✔
85
  handle.pWorkerCb = pInfo->workerCb;
962,848✔
86
  qTrace("message in qnode queue is processing");
962,848!
87

88
  switch (pMsg->msgType) {
962,851!
89
    case TDMT_SCH_QUERY:
272,085✔
90
    case TDMT_SCH_MERGE_QUERY:
91
      code = qWorkerProcessQueryMsg(&handle, pQnode->pQuery, pMsg, ts);
272,085✔
92
      break;
272,086✔
93
    case TDMT_SCH_QUERY_CONTINUE:
1,902✔
94
      code = qWorkerProcessCQueryMsg(&handle, pQnode->pQuery, pMsg, ts);
1,902✔
95
      break;
1,902✔
96
    case TDMT_SCH_FETCH:
287,529✔
97
    case TDMT_SCH_MERGE_FETCH:
98
      code = qWorkerProcessFetchMsg(pQnode, pQnode->pQuery, pMsg, ts);
287,529✔
99
      break;
287,529✔
UNCOV
100
    case TDMT_SCH_CANCEL_TASK:
×
101
      // code = qWorkerProcessCancelMsg(pQnode, pQnode->pQuery, pMsg, ts);
UNCOV
102
      break;
×
103
    case TDMT_SCH_DROP_TASK:
272,045✔
104
      code = qWorkerProcessDropMsg(pQnode, pQnode->pQuery, pMsg, ts);
272,045✔
105
      break;
272,045✔
106
    case TDMT_VND_TMQ_CONSUME:
129,290✔
107
      // code =  tqProcessConsumeReq(pQnode->pTq, pMsg);
108
      // break;
109
    case TDMT_SCH_QUERY_HEARTBEAT:
110
      code = qWorkerProcessHbMsg(pQnode, pQnode->pQuery, pMsg, ts);
129,290✔
111
      break;
129,290✔
112
    case TDMT_SCH_TASK_NOTIFY:
×
113
      code = qWorkerProcessNotifyMsg(pQnode, pQnode->pQuery, pMsg, ts);
×
114
      break;
×
115
    default:
×
116
      qError("unknown msg type:%d in qnode queue", pMsg->msgType);
×
UNCOV
117
      terrno = TSDB_CODE_APP_ERROR;
×
118
  }
119

120
  if (code == 0) {
962,852!
121
    return TSDB_CODE_ACTION_IN_PROGRESS;
962,852✔
122
  } else {
UNCOV
123
    return code;
×
124
  }
125
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc