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

taosdata / TDengine / #3621

22 Feb 2025 11:44AM UTC coverage: 2.037% (-61.5%) from 63.573%
#3621

push

travis-ci

web-flow
Merge pull request #29874 from taosdata/merge/mainto3.0

merge: from main to 3.0 branch

4357 of 287032 branches covered (1.52%)

Branch coverage included in aggregate %.

0 of 174 new or added lines in 18 files covered. (0.0%)

213359 existing lines in 469 files now uncovered.

7260 of 283369 relevant lines covered (2.56%)

23737.72 hits per line

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

0.0
/source/dnode/mgmt/mgmt_qnode/src/qmWorker.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
#define _DEFAULT_SOURCE
17
#include "qmInt.h"
18

19
static inline void qmSendRsp(SRpcMsg *pMsg, int32_t code) {
×
20
  SRpcMsg rsp = {
×
21
      .code = code,
22
      .pCont = pMsg->info.rsp,
×
23
      .contLen = pMsg->info.rspLen,
×
24
      .info = pMsg->info,
25
  };
26
  tmsgSendRsp(&rsp);
×
27
}
×
28

UNCOV
29
static void qmProcessQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
×
UNCOV
30
  SQnodeMgmt *pMgmt = pInfo->ahandle;
×
UNCOV
31
  dTrace("msg:%p, get from qnode queue", pMsg);
×
32

UNCOV
33
  int32_t code = qndProcessQueryMsg(pMgmt->pQnode, pInfo, pMsg);
×
UNCOV
34
  if (IsReq(pMsg) && code != TSDB_CODE_ACTION_IN_PROGRESS) {
×
35
    if (code != 0 && terrno != 0) code = terrno;
×
36
    qmSendRsp(pMsg, code);
×
37
  }
38

UNCOV
39
  dTrace("msg:%p, is freed, code:0x%x", pMsg, code);
×
UNCOV
40
  rpcFreeCont(pMsg->pCont);
×
UNCOV
41
  taosFreeQitem(pMsg);
×
UNCOV
42
}
×
43

UNCOV
44
static int32_t qmPutNodeMsgToWorker(SSingleWorker *pWorker, SRpcMsg *pMsg) {
×
UNCOV
45
  dTrace("msg:%p, put into worker %s, type:%s", pMsg, pWorker->name, TMSG_INFO(pMsg->msgType));
×
UNCOV
46
  return taosWriteQitem(pWorker->queue, pMsg);
×
47
}
48

UNCOV
49
int32_t qmPutNodeMsgToQueryQueue(SQnodeMgmt *pMgmt, SRpcMsg *pMsg) {
×
UNCOV
50
  int32_t code = qndPreprocessQueryMsg(pMgmt->pQnode, pMsg);
×
UNCOV
51
  if (code) return code;
×
UNCOV
52
  return qmPutNodeMsgToWorker(&pMgmt->queryWorker, pMsg);
×
53
}
54

UNCOV
55
int32_t qmPutNodeMsgToFetchQueue(SQnodeMgmt *pMgmt, SRpcMsg *pMsg) {
×
UNCOV
56
  return qmPutNodeMsgToWorker(&pMgmt->fetchWorker, pMsg);
×
57
}
58

UNCOV
59
int32_t qmPutRpcMsgToQueue(SQnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc) {
×
60
  int32_t  code;
61
  SRpcMsg *pMsg;
62

UNCOV
63
  code = taosAllocateQitem(sizeof(SRpcMsg), RPC_QITEM, pRpc->contLen, (void **)&pMsg);
×
UNCOV
64
  if (code) return code;
×
UNCOV
65
  memcpy(pMsg, pRpc, sizeof(SRpcMsg));
×
UNCOV
66
  pRpc->pCont = NULL;
×
67

UNCOV
68
  switch (qtype) {
×
UNCOV
69
    case QUERY_QUEUE:
×
UNCOV
70
      dTrace("msg:%p, is created and will put into qnode-query queue, len:%d", pMsg, pRpc->contLen);
×
UNCOV
71
      code = taosWriteQitem(pMgmt->queryWorker.queue, pMsg);
×
UNCOV
72
      return code;
×
73
    case READ_QUEUE:
×
74
    case FETCH_QUEUE:
75
      dTrace("msg:%p, is created and will put into qnode-fetch queue, len:%d", pMsg, pRpc->contLen);
×
76
      code = taosWriteQitem(pMgmt->fetchWorker.queue, pMsg);
×
77
      return code;
×
78
    default:
×
79
      terrno = TSDB_CODE_INVALID_PARA;
×
80
      rpcFreeCont(pMsg->pCont);
×
81
      taosFreeQitem(pMsg);
×
82
      return terrno;
×
83
  }
84
}
85

UNCOV
86
int32_t qmGetQueueSize(SQnodeMgmt *pMgmt, int32_t vgId, EQueueType qtype) {
×
UNCOV
87
  int32_t size = -1;
×
88

UNCOV
89
  switch (qtype) {
×
UNCOV
90
    case QUERY_QUEUE:
×
UNCOV
91
      size = taosQueueItemSize(pMgmt->queryWorker.queue);
×
UNCOV
92
      break;
×
UNCOV
93
    case FETCH_QUEUE:
×
UNCOV
94
      size = taosQueueItemSize(pMgmt->fetchWorker.queue);
×
UNCOV
95
      break;
×
96
    default:
×
97
      break;
×
98
  }
99

UNCOV
100
  return size;
×
101
}
102

UNCOV
103
int32_t qmStartWorker(SQnodeMgmt *pMgmt) {
×
UNCOV
104
  int32_t code = 0;
×
105

UNCOV
106
  SSingleWorkerCfg queryCfg = {
×
107
      .min = tsNumOfQnodeQueryThreads,
108
      .max = tsNumOfQnodeQueryThreads,
109
      .name = "qnode-query",
110
      .fp = (FItem)qmProcessQueue,
111
      .param = pMgmt,
112
      .poolType = QUERY_AUTO_QWORKER_POOL,
113
  };
114

UNCOV
115
  if ((code = tSingleWorkerInit(&pMgmt->queryWorker, &queryCfg)) != 0) {
×
116
    dError("failed to start qnode-query worker since %s", tstrerror(code));
×
117
    return code;
×
118
  }
119

UNCOV
120
  tsNumOfQueryThreads += tsNumOfQnodeQueryThreads;
×
121

UNCOV
122
  SSingleWorkerCfg fetchCfg = {
×
123
      .min = tsNumOfQnodeFetchThreads,
124
      .max = tsNumOfQnodeFetchThreads,
125
      .name = "qnode-fetch",
126
      .fp = (FItem)qmProcessQueue,
127
      .param = pMgmt,
128
  };
129

UNCOV
130
  if ((code = tSingleWorkerInit(&pMgmt->fetchWorker, &fetchCfg)) != 0) {
×
131
    dError("failed to start qnode-fetch worker since %s", tstrerror(code));
×
132
    return code;
×
133
  }
134

UNCOV
135
  dDebug("qnode workers are initialized");
×
UNCOV
136
  return code;
×
137
}
138

UNCOV
139
void qmStopWorker(SQnodeMgmt *pMgmt) {
×
UNCOV
140
  tSingleWorkerCleanup(&pMgmt->queryWorker);
×
UNCOV
141
  tSingleWorkerCleanup(&pMgmt->fetchWorker);
×
UNCOV
142
  dDebug("qnode workers are closed");
×
UNCOV
143
}
×
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