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

taosdata / TDengine / #4087

17 May 2025 01:40AM UTC coverage: 62.757% (-0.3%) from 63.048%
#4087

push

travis-ci

GitHub
fix: double close wal meta file. (#31059)

156587 of 317922 branches covered (49.25%)

Branch coverage included in aggregate %.

241845 of 316955 relevant lines covered (76.3%)

6570724.62 hits per line

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

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

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

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

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

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

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

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

68
  return 0;
66,673✔
69
}
70

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

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

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

85
  switch (pMsg->msgType) {
1,058,417!
86
    case TDMT_SCH_QUERY:
297,899✔
87
    case TDMT_SCH_MERGE_QUERY:
88
      code = qWorkerProcessQueryMsg(&handle, pQnode->pQuery, pMsg, ts);
297,899✔
89
      break;
297,860✔
90
    case TDMT_SCH_QUERY_CONTINUE:
2,059✔
91
      code = qWorkerProcessCQueryMsg(&handle, pQnode->pQuery, pMsg, ts);
2,059✔
92
      break;
2,059✔
93
    case TDMT_SCH_FETCH:
357,440✔
94
    case TDMT_SCH_MERGE_FETCH:
95
      code = qWorkerProcessFetchMsg(pQnode, pQnode->pQuery, pMsg, ts);
357,440✔
96
      break;
357,440✔
97
    case TDMT_SCH_CANCEL_TASK:
×
98
      // code = qWorkerProcessCancelMsg(pQnode, pQnode->pQuery, pMsg, ts);
99
      break;
×
100
    case TDMT_SCH_DROP_TASK:
297,865✔
101
      code = qWorkerProcessDropMsg(pQnode, pQnode->pQuery, pMsg, ts);
297,865✔
102
      break;
297,865✔
103
    case TDMT_VND_TMQ_CONSUME:
103,154✔
104
      // code =  tqProcessConsumeReq(pQnode->pTq, pMsg);
105
      // break;
106
    case TDMT_SCH_QUERY_HEARTBEAT:
107
      code = qWorkerProcessHbMsg(pQnode, pQnode->pQuery, pMsg, ts);
103,154✔
108
      break;
103,154✔
109
    case TDMT_SCH_TASK_NOTIFY:
×
110
      code = qWorkerProcessNotifyMsg(pQnode, pQnode->pQuery, pMsg, ts);
×
111
      break;
×
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) {
1,058,378!
118
    return TSDB_CODE_ACTION_IN_PROGRESS;
1,058,380✔
119
  } else {
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