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

taosdata / TDengine / #4693

29 Aug 2025 06:36AM UTC coverage: 58.007% (-1.1%) from 59.151%
#4693

push

travis-ci

web-flow
fix(gpt): fix race-condition in preparing tmp files (#32800)

132676 of 291873 branches covered (45.46%)

Branch coverage included in aggregate %.

5 of 34 new or added lines in 6 files covered. (14.71%)

4288 existing lines in 199 files now uncovered.

201114 of 283561 relevant lines covered (70.92%)

5433357.08 hits per line

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

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

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

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

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

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

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

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

68
  return 0;
18,073✔
69
}
70

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

76
  return qWorkerPreprocessQueryMsg(pQnode->pQuery, pMsg, false);
271,054✔
77
}
78

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

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

119
  if (code == 0) {
972,337!
120
    return TSDB_CODE_ACTION_IN_PROGRESS;
972,337✔
121
  } else {
UNCOV
122
    return code;
×
123
  }
124
}
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