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

taosdata / TDengine / #3533

20 Nov 2024 07:11AM UTC coverage: 58.848% (-1.9%) from 60.78%
#3533

push

travis-ci

web-flow
Merge pull request #28823 from taosdata/fix/3.0/TD-32587

fix:[TD-32587]fix stmt segmentation fault

115578 of 252434 branches covered (45.79%)

Branch coverage included in aggregate %.

1 of 4 new or added lines in 1 file covered. (25.0%)

8038 existing lines in 233 files now uncovered.

194926 of 275199 relevant lines covered (70.83%)

1494459.59 hits per line

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

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

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

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

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

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

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

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

68
  return 0;
9,282✔
69
}
70

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

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

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

85
  switch (pMsg->msgType) {
180,778!
86
    case TDMT_SCH_QUERY:
48,113✔
87
    case TDMT_SCH_MERGE_QUERY:
88
      code = qWorkerProcessQueryMsg(&handle, pQnode->pQuery, pMsg, ts);
48,113✔
89
      break;
48,113✔
UNCOV
90
    case TDMT_SCH_QUERY_CONTINUE:
×
UNCOV
91
      code = qWorkerProcessCQueryMsg(&handle, pQnode->pQuery, pMsg, ts);
×
UNCOV
92
      break;
×
93
    case TDMT_SCH_FETCH:
50,174✔
94
    case TDMT_SCH_MERGE_FETCH:
95
      code = qWorkerProcessFetchMsg(pQnode, pQnode->pQuery, pMsg, ts);
50,174✔
96
      break;
50,174✔
97
    case TDMT_SCH_CANCEL_TASK:
×
98
      // code = qWorkerProcessCancelMsg(pQnode, pQnode->pQuery, pMsg, ts);
99
      break;
×
100
    case TDMT_SCH_DROP_TASK:
48,132✔
101
      code = qWorkerProcessDropMsg(pQnode, pQnode->pQuery, pMsg, ts);
48,132✔
102
      break;
48,132✔
103
    case TDMT_VND_TMQ_CONSUME:
34,358✔
104
      // code =  tqProcessConsumeReq(pQnode->pTq, pMsg);
105
      // break;
106
    case TDMT_SCH_QUERY_HEARTBEAT:
107
      code = qWorkerProcessHbMsg(pQnode, pQnode->pQuery, pMsg, ts);
34,358✔
108
      break;
34,358✔
109
    case TDMT_SCH_TASK_NOTIFY:
1✔
110
      code = qWorkerProcessNotifyMsg(pQnode, pQnode->pQuery, pMsg, ts);
1✔
111
      break;
1✔
112
    default:
×
113
      qError("unknown msg type:%d in qnode queue", pMsg->msgType);
×
114
      terrno = TSDB_CODE_APP_ERROR;
×
115
  }
116

117
  if (code == 0) {
180,778!
118
    return TSDB_CODE_ACTION_IN_PROGRESS;
180,778✔
119
  } else {
UNCOV
120
    return code;
×
121
  }
122
}
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