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

taosdata / TDengine / #3565

25 Dec 2024 05:34AM UTC coverage: 51.098% (-11.1%) from 62.21%
#3565

push

travis-ci

web-flow
Merge pull request #29316 from taosdata/enh/3.0/TD-33266

enh(ut):Add wal & config UT.

111558 of 284773 branches covered (39.17%)

Branch coverage included in aggregate %.

1 of 2 new or added lines in 2 files covered. (50.0%)

39015 existing lines in 102 files now uncovered.

177882 of 281666 relevant lines covered (63.15%)

15090998.35 hits per line

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

5.05
/source/dnode/vnode/src/vnd/vnodeQuery.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 "tsdb.h"
17
#include "vnd.h"
18

19
#define VNODE_GET_LOAD_RESET_VALS(pVar, oVal, vType, tags)                                                    \
20
  do {                                                                                                        \
21
    int##vType##_t newVal = atomic_sub_fetch_##vType(&(pVar), (oVal));                                        \
22
    if (newVal < 0) {                                                                                         \
23
      vWarn("vgId:%d, %s, abnormal val:%" PRIi64 ", old val:%" PRIi64, TD_VID(pVnode), tags, newVal, (oVal)); \
24
    }                                                                                                         \
25
  } while (0)
26

27
int vnodeQueryOpen(SVnode *pVnode) {
17✔
28
  return qWorkerInit(NODE_TYPE_VNODE, TD_VID(pVnode), (void **)&pVnode->pQuery, &pVnode->msgCb);
17✔
29
}
30

31
void vnodeQueryPreClose(SVnode *pVnode) { qWorkerStopAllTasks((void *)pVnode->pQuery); }
18✔
32

33
void vnodeQueryClose(SVnode *pVnode) { qWorkerDestroy((void **)&pVnode->pQuery); }
18✔
34

UNCOV
35
int32_t fillTableColCmpr(SMetaReader *reader, SSchemaExt *pExt, int32_t numOfCol) {
×
UNCOV
36
  int8_t tblType = reader->me.type;
×
UNCOV
37
  if (useCompress(tblType)) {
×
UNCOV
38
    SColCmprWrapper *p = &(reader->me.colCmpr);
×
UNCOV
39
    if (numOfCol != p->nCols) {
×
40
      vError("fillTableColCmpr table type:%d, col num:%d, col cmpr num:%d mismatch", tblType, numOfCol, p->nCols);
×
41
      return TSDB_CODE_APP_ERROR;
×
42
    }
UNCOV
43
    for (int i = 0; i < p->nCols; i++) {
×
UNCOV
44
      SColCmpr *pCmpr = &p->pColCmpr[i];
×
UNCOV
45
      pExt[i].colId = pCmpr->id;
×
UNCOV
46
      pExt[i].compress = pCmpr->alg;
×
47
    }
48
  }
UNCOV
49
  return 0;
×
50
}
51

UNCOV
52
int32_t vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg, bool direct) {
×
UNCOV
53
  STableInfoReq  infoReq = {0};
×
UNCOV
54
  STableMetaRsp  metaRsp = {0};
×
UNCOV
55
  SMetaReader    mer1 = {0};
×
UNCOV
56
  SMetaReader    mer2 = {0};
×
57
  char           tableFName[TSDB_TABLE_FNAME_LEN];
UNCOV
58
  bool           reqTbUid = false;
×
UNCOV
59
  SRpcMsg        rpcMsg = {0};
×
UNCOV
60
  int32_t        code = 0;
×
UNCOV
61
  int32_t        rspLen = 0;
×
UNCOV
62
  void          *pRsp = NULL;
×
UNCOV
63
  SSchemaWrapper schema = {0};
×
UNCOV
64
  SSchemaWrapper schemaTag = {0};
×
65

66
  // decode req
UNCOV
67
  if (tDeserializeSTableInfoReq(pMsg->pCont, pMsg->contLen, &infoReq) != 0) {
×
68
    code = terrno;
×
69
    goto _exit4;
×
70
  }
71

UNCOV
72
  if (infoReq.option == REQ_OPT_TBUID) reqTbUid = true;
×
UNCOV
73
  metaRsp.dbId = pVnode->config.dbId;
×
UNCOV
74
  tstrncpy(metaRsp.tbName, infoReq.tbName, TSDB_TABLE_NAME_LEN);
×
UNCOV
75
  (void)memcpy(metaRsp.dbFName, infoReq.dbFName, sizeof(metaRsp.dbFName));
×
76

UNCOV
77
  if (!reqTbUid) {
×
UNCOV
78
    (void)tsnprintf(tableFName, TSDB_TABLE_FNAME_LEN, "%s.%s", infoReq.dbFName, infoReq.tbName);
×
UNCOV
79
    code = vnodeValidateTableHash(pVnode, tableFName);
×
UNCOV
80
    if (code) {
×
81
      goto _exit4;
×
82
    }
83
  }
84

85
  // query meta
UNCOV
86
  metaReaderDoInit(&mer1, pVnode->pMeta, META_READER_LOCK);
×
UNCOV
87
  if (reqTbUid) {
×
UNCOV
88
    errno = 0;
×
UNCOV
89
    uint64_t tbUid = taosStr2UInt64(infoReq.tbName, NULL, 10);
×
UNCOV
90
    if (errno == ERANGE || tbUid == 0) {
×
91
      code = TSDB_CODE_TDB_TABLE_NOT_EXIST;
×
UNCOV
92
      goto _exit3;
×
93
    }
UNCOV
94
    char tbName[TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE] = {0};
×
UNCOV
95
    TAOS_CHECK_GOTO(metaGetTableNameByUid(pVnode, tbUid, tbName), NULL, _exit3);
×
UNCOV
96
    tstrncpy(metaRsp.tbName, varDataVal(tbName), TSDB_TABLE_NAME_LEN);
×
UNCOV
97
    TAOS_CHECK_GOTO(metaGetTableEntryByName(&mer1, varDataVal(tbName)), NULL, _exit3);
×
UNCOV
98
  } else if (metaGetTableEntryByName(&mer1, infoReq.tbName) < 0) {
×
UNCOV
99
    code = terrno;
×
UNCOV
100
    goto _exit3;
×
101
  }
102

UNCOV
103
  metaRsp.tableType = mer1.me.type;
×
UNCOV
104
  metaRsp.vgId = TD_VID(pVnode);
×
UNCOV
105
  metaRsp.tuid = mer1.me.uid;
×
106

UNCOV
107
  if (mer1.me.type == TSDB_SUPER_TABLE) {
×
UNCOV
108
    tstrncpy(metaRsp.stbName, mer1.me.name, TSDB_TABLE_NAME_LEN);
×
UNCOV
109
    schema = mer1.me.stbEntry.schemaRow;
×
UNCOV
110
    schemaTag = mer1.me.stbEntry.schemaTag;
×
UNCOV
111
    metaRsp.suid = mer1.me.uid;
×
UNCOV
112
  } else if (mer1.me.type == TSDB_CHILD_TABLE) {
×
UNCOV
113
    metaReaderDoInit(&mer2, pVnode->pMeta, META_READER_NOLOCK);
×
UNCOV
114
    if (metaReaderGetTableEntryByUid(&mer2, mer1.me.ctbEntry.suid) < 0) goto _exit2;
×
115

UNCOV
116
    tstrncpy(metaRsp.stbName, mer2.me.name, TSDB_TABLE_NAME_LEN);
×
UNCOV
117
    metaRsp.suid = mer2.me.uid;
×
UNCOV
118
    schema = mer2.me.stbEntry.schemaRow;
×
UNCOV
119
    schemaTag = mer2.me.stbEntry.schemaTag;
×
UNCOV
120
  } else if (mer1.me.type == TSDB_NORMAL_TABLE) {
×
UNCOV
121
    schema = mer1.me.ntbEntry.schemaRow;
×
122
  } else {
123
    vError("vnodeGetTableMeta get invalid table type:%d", mer1.me.type);
×
124
    goto _exit3;
×
125
  }
126

UNCOV
127
  metaRsp.numOfTags = schemaTag.nCols;
×
UNCOV
128
  metaRsp.numOfColumns = schema.nCols;
×
UNCOV
129
  metaRsp.precision = pVnode->config.tsdbCfg.precision;
×
UNCOV
130
  metaRsp.sversion = schema.version;
×
UNCOV
131
  metaRsp.tversion = schemaTag.version;
×
UNCOV
132
  metaRsp.pSchemas = (SSchema *)taosMemoryMalloc(sizeof(SSchema) * (metaRsp.numOfColumns + metaRsp.numOfTags));
×
UNCOV
133
  metaRsp.pSchemaExt = (SSchemaExt *)taosMemoryCalloc(metaRsp.numOfColumns, sizeof(SSchemaExt));
×
UNCOV
134
  if (NULL == metaRsp.pSchemas || NULL == metaRsp.pSchemaExt) {
×
135
    code = terrno;
×
136
    goto _exit;
×
137
  }
UNCOV
138
  (void)memcpy(metaRsp.pSchemas, schema.pSchema, sizeof(SSchema) * schema.nCols);
×
UNCOV
139
  if (schemaTag.nCols) {
×
UNCOV
140
    (void)memcpy(metaRsp.pSchemas + schema.nCols, schemaTag.pSchema, sizeof(SSchema) * schemaTag.nCols);
×
141
  }
UNCOV
142
  if (metaRsp.pSchemaExt) {
×
UNCOV
143
    SMetaReader *pReader = mer1.me.type == TSDB_CHILD_TABLE ? &mer2 : &mer1;
×
UNCOV
144
    code = fillTableColCmpr(pReader, metaRsp.pSchemaExt, metaRsp.numOfColumns);
×
UNCOV
145
    if (code < 0) {
×
146
      goto _exit;
×
147
    }
148
  } else {
UNCOV
149
    code = TSDB_CODE_OUT_OF_MEMORY;
×
UNCOV
150
    goto _exit;
×
151
  }
152

153
  // encode and send response
UNCOV
154
  rspLen = tSerializeSTableMetaRsp(NULL, 0, &metaRsp);
×
UNCOV
155
  if (rspLen < 0) {
×
156
    code = terrno;
×
157
    goto _exit;
×
158
  }
159

UNCOV
160
  if (direct) {
×
UNCOV
161
    pRsp = rpcMallocCont(rspLen);
×
162
  } else {
UNCOV
163
    pRsp = taosMemoryCalloc(1, rspLen);
×
164
  }
165

UNCOV
166
  if (pRsp == NULL) {
×
167
    code = terrno;
×
168
    goto _exit;
×
169
  }
170

UNCOV
171
  rspLen = tSerializeSTableMetaRsp(pRsp, rspLen, &metaRsp);
×
UNCOV
172
  if (rspLen < 0) {
×
173
    code = terrno;
×
174
    goto _exit;
×
175
  }
176

UNCOV
177
_exit:
×
UNCOV
178
  taosMemoryFree(metaRsp.pSchemas);
×
UNCOV
179
  taosMemoryFree(metaRsp.pSchemaExt);
×
UNCOV
180
_exit2:
×
UNCOV
181
  metaReaderClear(&mer2);
×
UNCOV
182
_exit3:
×
UNCOV
183
  metaReaderClear(&mer1);
×
UNCOV
184
_exit4:
×
UNCOV
185
  rpcMsg.info = pMsg->info;
×
UNCOV
186
  rpcMsg.pCont = pRsp;
×
UNCOV
187
  rpcMsg.contLen = rspLen;
×
UNCOV
188
  rpcMsg.code = code;
×
UNCOV
189
  rpcMsg.msgType = pMsg->msgType;
×
190

UNCOV
191
  if (code) {
×
UNCOV
192
    qError("get table %s meta with %" PRIu8 " failed cause of %s", infoReq.tbName, infoReq.option, tstrerror(code));
×
193
  }
194

UNCOV
195
  if (direct) {
×
UNCOV
196
    tmsgSendRsp(&rpcMsg);
×
197
  } else {
UNCOV
198
    *pMsg = rpcMsg;
×
199
  }
200

UNCOV
201
  return code;
×
202
}
203

UNCOV
204
int32_t vnodeGetTableCfg(SVnode *pVnode, SRpcMsg *pMsg, bool direct) {
×
UNCOV
205
  STableCfgReq   cfgReq = {0};
×
UNCOV
206
  STableCfgRsp   cfgRsp = {0};
×
UNCOV
207
  SMetaReader    mer1 = {0};
×
UNCOV
208
  SMetaReader    mer2 = {0};
×
209
  char           tableFName[TSDB_TABLE_FNAME_LEN];
UNCOV
210
  SRpcMsg        rpcMsg = {0};
×
UNCOV
211
  int32_t        code = 0;
×
UNCOV
212
  int32_t        rspLen = 0;
×
UNCOV
213
  void          *pRsp = NULL;
×
UNCOV
214
  SSchemaWrapper schema = {0};
×
UNCOV
215
  SSchemaWrapper schemaTag = {0};
×
216

217
  // decode req
UNCOV
218
  if (tDeserializeSTableCfgReq(pMsg->pCont, pMsg->contLen, &cfgReq) != 0) {
×
219
    code = terrno;
×
220
    goto _exit;
×
221
  }
222

UNCOV
223
  tstrncpy(cfgRsp.tbName, cfgReq.tbName, TSDB_TABLE_NAME_LEN);
×
UNCOV
224
  (void)memcpy(cfgRsp.dbFName, cfgReq.dbFName, sizeof(cfgRsp.dbFName));
×
225

UNCOV
226
  (void)tsnprintf(tableFName, TSDB_TABLE_FNAME_LEN, "%s.%s", cfgReq.dbFName, cfgReq.tbName);
×
UNCOV
227
  code = vnodeValidateTableHash(pVnode, tableFName);
×
UNCOV
228
  if (code) {
×
229
    goto _exit;
×
230
  }
231

232
  // query meta
UNCOV
233
  metaReaderDoInit(&mer1, pVnode->pMeta, META_READER_LOCK);
×
234

UNCOV
235
  if (metaGetTableEntryByName(&mer1, cfgReq.tbName) < 0) {
×
236
    code = terrno;
×
237
    goto _exit;
×
238
  }
239

UNCOV
240
  cfgRsp.tableType = mer1.me.type;
×
241

UNCOV
242
  if (mer1.me.type == TSDB_SUPER_TABLE) {
×
243
    code = TSDB_CODE_VND_HASH_MISMATCH;
×
244
    goto _exit;
×
UNCOV
245
  } else if (mer1.me.type == TSDB_CHILD_TABLE) {
×
UNCOV
246
    metaReaderDoInit(&mer2, pVnode->pMeta, META_READER_LOCK);
×
UNCOV
247
    if (metaReaderGetTableEntryByUid(&mer2, mer1.me.ctbEntry.suid) < 0) goto _exit;
×
248

UNCOV
249
    tstrncpy(cfgRsp.stbName, mer2.me.name, TSDB_TABLE_NAME_LEN);
×
UNCOV
250
    schema = mer2.me.stbEntry.schemaRow;
×
UNCOV
251
    schemaTag = mer2.me.stbEntry.schemaTag;
×
UNCOV
252
    cfgRsp.ttl = mer1.me.ctbEntry.ttlDays;
×
UNCOV
253
    cfgRsp.commentLen = mer1.me.ctbEntry.commentLen;
×
UNCOV
254
    if (mer1.me.ctbEntry.commentLen > 0) {
×
255
      cfgRsp.pComment = taosStrdup(mer1.me.ctbEntry.comment);
×
256
      if (NULL == cfgRsp.pComment) {
×
257
        code = terrno;
×
258
        goto _exit;
×
259
      }
260
    }
UNCOV
261
    STag *pTag = (STag *)mer1.me.ctbEntry.pTags;
×
UNCOV
262
    cfgRsp.tagsLen = pTag->len;
×
UNCOV
263
    cfgRsp.pTags = taosMemoryMalloc(cfgRsp.tagsLen);
×
UNCOV
264
    if (NULL == cfgRsp.pTags) {
×
265
      code = terrno;
×
266
      goto _exit;
×
267
    }
UNCOV
268
    (void)memcpy(cfgRsp.pTags, pTag, cfgRsp.tagsLen);
×
UNCOV
269
  } else if (mer1.me.type == TSDB_NORMAL_TABLE) {
×
UNCOV
270
    schema = mer1.me.ntbEntry.schemaRow;
×
UNCOV
271
    cfgRsp.ttl = mer1.me.ntbEntry.ttlDays;
×
UNCOV
272
    cfgRsp.commentLen = mer1.me.ntbEntry.commentLen;
×
UNCOV
273
    if (mer1.me.ntbEntry.commentLen > 0) {
×
274
      cfgRsp.pComment = taosStrdup(mer1.me.ntbEntry.comment);
×
275
      if (NULL == cfgRsp.pComment) {
×
276
        code = terrno;
×
277
        goto _exit;
×
278
      }
279
    }
280
  } else {
281
    vError("vnodeGetTableCfg get invalid table type:%d", mer1.me.type);
×
282
    return TSDB_CODE_APP_ERROR;
×
283
  }
284

UNCOV
285
  cfgRsp.numOfTags = schemaTag.nCols;
×
UNCOV
286
  cfgRsp.numOfColumns = schema.nCols;
×
UNCOV
287
  cfgRsp.pSchemas = (SSchema *)taosMemoryMalloc(sizeof(SSchema) * (cfgRsp.numOfColumns + cfgRsp.numOfTags));
×
UNCOV
288
  cfgRsp.pSchemaExt = (SSchemaExt *)taosMemoryMalloc(cfgRsp.numOfColumns * sizeof(SSchemaExt));
×
289

UNCOV
290
  if (NULL == cfgRsp.pSchemas || NULL == cfgRsp.pSchemaExt) {
×
291
    code = terrno;
×
292
    goto _exit;
×
293
  }
UNCOV
294
  (void)memcpy(cfgRsp.pSchemas, schema.pSchema, sizeof(SSchema) * schema.nCols);
×
UNCOV
295
  if (schemaTag.nCols) {
×
UNCOV
296
    (void)memcpy(cfgRsp.pSchemas + schema.nCols, schemaTag.pSchema, sizeof(SSchema) * schemaTag.nCols);
×
297
  }
298

299
  // if (useCompress(cfgRsp.tableType)) {
300

UNCOV
301
  SMetaReader     *pReader = mer1.me.type == TSDB_CHILD_TABLE ? &mer2 : &mer1;
×
UNCOV
302
  SColCmprWrapper *pColCmpr = &pReader->me.colCmpr;
×
303

UNCOV
304
  for (int32_t i = 0; i < cfgRsp.numOfColumns; i++) {
×
UNCOV
305
    SColCmpr   *pCmpr = &pColCmpr->pColCmpr[i];
×
UNCOV
306
    SSchemaExt *pSchExt = cfgRsp.pSchemaExt + i;
×
UNCOV
307
    pSchExt->colId = pCmpr->id;
×
UNCOV
308
    pSchExt->compress = pCmpr->alg;
×
309
  }
310
  //}
311

312
  // encode and send response
UNCOV
313
  rspLen = tSerializeSTableCfgRsp(NULL, 0, &cfgRsp);
×
UNCOV
314
  if (rspLen < 0) {
×
315
    code = terrno;
×
316
    goto _exit;
×
317
  }
318

UNCOV
319
  if (direct) {
×
320
    pRsp = rpcMallocCont(rspLen);
×
321
  } else {
UNCOV
322
    pRsp = taosMemoryCalloc(1, rspLen);
×
323
  }
324

UNCOV
325
  if (pRsp == NULL) {
×
326
    code = terrno;
×
327
    goto _exit;
×
328
  }
329

UNCOV
330
  rspLen = tSerializeSTableCfgRsp(pRsp, rspLen, &cfgRsp);
×
UNCOV
331
  if (rspLen < 0) {
×
332
    code = terrno;
×
333
    goto _exit;
×
334
  }
335

UNCOV
336
_exit:
×
UNCOV
337
  rpcMsg.info = pMsg->info;
×
UNCOV
338
  rpcMsg.pCont = pRsp;
×
UNCOV
339
  rpcMsg.contLen = rspLen;
×
UNCOV
340
  rpcMsg.code = code;
×
UNCOV
341
  rpcMsg.msgType = pMsg->msgType;
×
342

UNCOV
343
  if (code) {
×
344
    qError("get table %s cfg failed cause of %s", cfgReq.tbName, tstrerror(code));
×
345
  }
346

UNCOV
347
  if (direct) {
×
348
    tmsgSendRsp(&rpcMsg);
×
349
  } else {
UNCOV
350
    *pMsg = rpcMsg;
×
351
  }
352

UNCOV
353
  tFreeSTableCfgRsp(&cfgRsp);
×
UNCOV
354
  metaReaderClear(&mer2);
×
UNCOV
355
  metaReaderClear(&mer1);
×
UNCOV
356
  return code;
×
357
}
358

359
static FORCE_INLINE void vnodeFreeSBatchRspMsg(void *p) {
360
  if (NULL == p) {
361
    return;
362
  }
363

364
  SBatchRspMsg *pRsp = (SBatchRspMsg *)p;
365
  rpcFreeCont(pRsp->msg);
366
}
367

UNCOV
368
int32_t vnodeGetBatchMeta(SVnode *pVnode, SRpcMsg *pMsg) {
×
UNCOV
369
  int32_t      code = 0;
×
UNCOV
370
  int32_t      rspSize = 0;
×
UNCOV
371
  SBatchReq    batchReq = {0};
×
UNCOV
372
  SBatchMsg   *req = NULL;
×
UNCOV
373
  SBatchRspMsg rsp = {0};
×
UNCOV
374
  SBatchRsp    batchRsp = {0};
×
UNCOV
375
  SRpcMsg      reqMsg = *pMsg;
×
UNCOV
376
  SRpcMsg      rspMsg = {0};
×
UNCOV
377
  void        *pRsp = NULL;
×
378

UNCOV
379
  if (tDeserializeSBatchReq(pMsg->pCont, pMsg->contLen, &batchReq)) {
×
380
    code = terrno;
×
381
    qError("tDeserializeSBatchReq failed");
×
382
    goto _exit;
×
383
  }
384

UNCOV
385
  int32_t msgNum = taosArrayGetSize(batchReq.pMsgs);
×
UNCOV
386
  if (msgNum >= MAX_META_MSG_IN_BATCH) {
×
387
    code = TSDB_CODE_INVALID_MSG;
×
388
    qError("too many msgs %d in vnode batch meta req", msgNum);
×
389
    goto _exit;
×
390
  }
391

UNCOV
392
  batchRsp.pRsps = taosArrayInit(msgNum, sizeof(SBatchRspMsg));
×
UNCOV
393
  if (NULL == batchRsp.pRsps) {
×
UNCOV
394
    code = terrno;
×
395
    qError("taosArrayInit %d SBatchRspMsg failed", msgNum);
×
396
    goto _exit;
×
397
  }
398

UNCOV
399
  for (int32_t i = 0; i < msgNum; ++i) {
×
UNCOV
400
    req = taosArrayGet(batchReq.pMsgs, i);
×
UNCOV
401
    if (req == NULL) {
×
402
      code = terrno;
×
403
      goto _exit;
×
404
    }
405

UNCOV
406
    reqMsg.msgType = req->msgType;
×
UNCOV
407
    reqMsg.pCont = req->msg;
×
UNCOV
408
    reqMsg.contLen = req->msgLen;
×
409

UNCOV
410
    switch (req->msgType) {
×
UNCOV
411
      case TDMT_VND_TABLE_META:
×
412
        // error code has been set into reqMsg, no need to handle it here.
UNCOV
413
        if (TSDB_CODE_SUCCESS != vnodeGetTableMeta(pVnode, &reqMsg, false)) {
×
UNCOV
414
          qWarn("vnodeGetBatchMeta failed, msgType:%d", req->msgType);
×
415
        }
UNCOV
416
        break;
×
UNCOV
417
      case TDMT_VND_TABLE_NAME:
×
418
        // error code has been set into reqMsg, no need to handle it here.
UNCOV
419
        if (TSDB_CODE_SUCCESS != vnodeGetTableMeta(pVnode, &reqMsg, false)) {
×
UNCOV
420
          qWarn("vnodeGetBatchName failed, msgType:%d", req->msgType);
×
421
        }
UNCOV
422
        break;
×
UNCOV
423
      case TDMT_VND_TABLE_CFG:
×
424
        // error code has been set into reqMsg, no need to handle it here.
UNCOV
425
        if (TSDB_CODE_SUCCESS != vnodeGetTableCfg(pVnode, &reqMsg, false)) {
×
426
          qWarn("vnodeGetBatchMeta failed, msgType:%d", req->msgType);
×
427
        }
UNCOV
428
        break;
×
UNCOV
429
      case TDMT_VND_GET_STREAM_PROGRESS:
×
430
        // error code has been set into reqMsg, no need to handle it here.
UNCOV
431
        if (TSDB_CODE_SUCCESS != vnodeGetStreamProgress(pVnode, &reqMsg, false)) {
×
432
          qWarn("vnodeGetBatchMeta failed, msgType:%d", req->msgType);
×
433
        }
UNCOV
434
        break;
×
435
      default:
×
436
        qError("invalid req msgType %d", req->msgType);
×
437
        reqMsg.code = TSDB_CODE_INVALID_MSG;
×
438
        reqMsg.pCont = NULL;
×
439
        reqMsg.contLen = 0;
×
440
        break;
×
441
    }
442

UNCOV
443
    rsp.msgIdx = req->msgIdx;
×
UNCOV
444
    rsp.reqType = reqMsg.msgType;
×
UNCOV
445
    rsp.msgLen = reqMsg.contLen;
×
UNCOV
446
    rsp.rspCode = reqMsg.code;
×
UNCOV
447
    rsp.msg = reqMsg.pCont;
×
448

UNCOV
449
    if (NULL == taosArrayPush(batchRsp.pRsps, &rsp)) {
×
450
      qError("taosArrayPush failed");
×
451
      code = terrno;
×
452
      goto _exit;
×
453
    }
454
  }
455

UNCOV
456
  rspSize = tSerializeSBatchRsp(NULL, 0, &batchRsp);
×
UNCOV
457
  if (rspSize < 0) {
×
458
    qError("tSerializeSBatchRsp failed");
×
459
    code = terrno;
×
460
    goto _exit;
×
461
  }
UNCOV
462
  pRsp = rpcMallocCont(rspSize);
×
UNCOV
463
  if (pRsp == NULL) {
×
464
    qError("rpcMallocCont %d failed", rspSize);
×
465
    code = terrno;
×
466
    goto _exit;
×
467
  }
UNCOV
468
  if (tSerializeSBatchRsp(pRsp, rspSize, &batchRsp) < 0) {
×
469
    qError("tSerializeSBatchRsp %d failed", rspSize);
×
470
    code = terrno;
×
471
    goto _exit;
×
472
  }
473

UNCOV
474
_exit:
×
475

UNCOV
476
  rspMsg.info = pMsg->info;
×
UNCOV
477
  rspMsg.pCont = pRsp;
×
UNCOV
478
  rspMsg.contLen = rspSize;
×
UNCOV
479
  rspMsg.code = code;
×
UNCOV
480
  rspMsg.msgType = pMsg->msgType;
×
481

UNCOV
482
  if (code) {
×
483
    qError("vnd get batch meta failed cause of %s", tstrerror(code));
×
484
  }
485

UNCOV
486
  taosArrayDestroyEx(batchReq.pMsgs, tFreeSBatchReqMsg);
×
UNCOV
487
  taosArrayDestroyEx(batchRsp.pRsps, tFreeSBatchRspMsg);
×
488

UNCOV
489
  tmsgSendRsp(&rspMsg);
×
490

UNCOV
491
  return code;
×
492
}
493

UNCOV
494
int32_t vnodeGetLoad(SVnode *pVnode, SVnodeLoad *pLoad) {
×
UNCOV
495
  SSyncState state = syncGetState(pVnode->sync);
×
496

UNCOV
497
  pLoad->vgId = TD_VID(pVnode);
×
UNCOV
498
  pLoad->syncState = state.state;
×
UNCOV
499
  pLoad->syncRestore = state.restored;
×
UNCOV
500
  pLoad->syncTerm = state.term;
×
UNCOV
501
  pLoad->roleTimeMs = state.roleTimeMs;
×
UNCOV
502
  pLoad->startTimeMs = state.startTimeMs;
×
UNCOV
503
  pLoad->syncCanRead = state.canRead;
×
UNCOV
504
  pLoad->learnerProgress = state.progress;
×
UNCOV
505
  pLoad->cacheUsage = tsdbCacheGetUsage(pVnode);
×
UNCOV
506
  pLoad->numOfCachedTables = tsdbCacheGetElems(pVnode);
×
UNCOV
507
  pLoad->numOfTables = metaGetTbNum(pVnode->pMeta);
×
UNCOV
508
  pLoad->numOfTimeSeries = metaGetTimeSeriesNum(pVnode->pMeta, 1);
×
UNCOV
509
  pLoad->totalStorage = (int64_t)3 * 1073741824;
×
UNCOV
510
  pLoad->compStorage = (int64_t)2 * 1073741824;
×
UNCOV
511
  pLoad->pointsWritten = 100;
×
UNCOV
512
  pLoad->numOfSelectReqs = 1;
×
UNCOV
513
  pLoad->numOfInsertReqs = atomic_load_64(&pVnode->statis.nInsert);
×
UNCOV
514
  pLoad->numOfInsertSuccessReqs = atomic_load_64(&pVnode->statis.nInsertSuccess);
×
UNCOV
515
  pLoad->numOfBatchInsertReqs = atomic_load_64(&pVnode->statis.nBatchInsert);
×
UNCOV
516
  pLoad->numOfBatchInsertSuccessReqs = atomic_load_64(&pVnode->statis.nBatchInsertSuccess);
×
UNCOV
517
  return 0;
×
518
}
519

520
int32_t vnodeGetLoadLite(SVnode *pVnode, SVnodeLoadLite *pLoad) {
×
521
  SSyncState syncState = syncGetState(pVnode->sync);
×
522
  if (syncState.state == TAOS_SYNC_STATE_LEADER || syncState.state == TAOS_SYNC_STATE_ASSIGNED_LEADER) {
×
523
    pLoad->vgId = TD_VID(pVnode);
×
524
    pLoad->nTimeSeries = metaGetTimeSeriesNum(pVnode->pMeta, 1);
×
525
    return 0;
×
526
  }
527
  return -1;
×
528
}
529
/**
530
 * @brief Reset the statistics value by monitor interval
531
 *
532
 * @param pVnode
533
 * @param pLoad
534
 */
UNCOV
535
void vnodeResetLoad(SVnode *pVnode, SVnodeLoad *pLoad) {
×
UNCOV
536
  VNODE_GET_LOAD_RESET_VALS(pVnode->statis.nInsert, pLoad->numOfInsertReqs, 64, "nInsert");
×
UNCOV
537
  VNODE_GET_LOAD_RESET_VALS(pVnode->statis.nInsertSuccess, pLoad->numOfInsertSuccessReqs, 64, "nInsertSuccess");
×
UNCOV
538
  VNODE_GET_LOAD_RESET_VALS(pVnode->statis.nBatchInsert, pLoad->numOfBatchInsertReqs, 64, "nBatchInsert");
×
UNCOV
539
  VNODE_GET_LOAD_RESET_VALS(pVnode->statis.nBatchInsertSuccess, pLoad->numOfBatchInsertSuccessReqs, 64,
×
540
                            "nBatchInsertSuccess");
UNCOV
541
}
×
542

UNCOV
543
void vnodeGetInfo(void *pVnode, const char **dbname, int32_t *vgId, int64_t *numOfTables, int64_t *numOfNormalTables) {
×
UNCOV
544
  SVnode    *pVnodeObj = pVnode;
×
UNCOV
545
  SVnodeCfg *pConf = &pVnodeObj->config;
×
546

UNCOV
547
  if (dbname) {
×
UNCOV
548
    *dbname = pConf->dbname;
×
549
  }
550

UNCOV
551
  if (vgId) {
×
UNCOV
552
    *vgId = TD_VID(pVnodeObj);
×
553
  }
554

UNCOV
555
  if (numOfTables) {
×
556
    *numOfTables = pConf->vndStats.numOfNTables + pConf->vndStats.numOfCTables;
×
557
  }
558

UNCOV
559
  if (numOfNormalTables) {
×
560
    *numOfNormalTables = pConf->vndStats.numOfNTables;
×
561
  }
UNCOV
562
}
×
563

564
int32_t vnodeGetTableList(void *pVnode, int8_t type, SArray *pList) {
×
565
  if (type == TSDB_SUPER_TABLE) {
×
566
    return vnodeGetStbIdList(pVnode, 0, pList);
×
567
  } else {
568
    return TSDB_CODE_INVALID_PARA;
×
569
  }
570
}
571

572
int32_t vnodeGetAllTableList(SVnode *pVnode, uint64_t uid, SArray *list) {
×
573
  int32_t      code = TSDB_CODE_SUCCESS;
×
574
  SMCtbCursor *pCur = metaOpenCtbCursor(pVnode, uid, 1);
×
575
  if (NULL == pCur) {
×
576
    qError("vnode get all table list failed");
×
577
    return terrno;
×
578
  }
579

580
  while (1) {
×
581
    tb_uid_t id = metaCtbCursorNext(pCur);
×
582
    if (id == 0) {
×
583
      break;
×
584
    }
585

586
    STableKeyInfo info = {uid = id};
×
587
    if (NULL == taosArrayPush(list, &info)) {
×
588
      qError("taosArrayPush failed");
×
589
      code = terrno;
×
590
      goto _exit;
×
591
    }
592
  }
593
_exit:
×
594
  metaCloseCtbCursor(pCur);
×
595
  return code;
×
596
}
597

598
int32_t vnodeGetCtbIdListByFilter(SVnode *pVnode, int64_t suid, SArray *list, bool (*filter)(void *arg), void *arg) {
×
599
  return 0;
×
600
}
601

UNCOV
602
int32_t vnodeGetCtbIdList(void *pVnode, int64_t suid, SArray *list) {
×
UNCOV
603
  int32_t      code = TSDB_CODE_SUCCESS;
×
UNCOV
604
  SVnode      *pVnodeObj = pVnode;
×
UNCOV
605
  SMCtbCursor *pCur = metaOpenCtbCursor(pVnodeObj, suid, 1);
×
UNCOV
606
  if (NULL == pCur) {
×
607
    qError("vnode get all table list failed");
×
608
    return terrno;
×
609
  }
610

UNCOV
611
  while (1) {
×
UNCOV
612
    tb_uid_t id = metaCtbCursorNext(pCur);
×
UNCOV
613
    if (id == 0) {
×
UNCOV
614
      break;
×
615
    }
616

UNCOV
617
    if (NULL == taosArrayPush(list, &id)) {
×
618
      qError("taosArrayPush failed");
×
619
      code = terrno;
×
620
      goto _exit;
×
621
    }
622
  }
623

UNCOV
624
_exit:
×
UNCOV
625
  metaCloseCtbCursor(pCur);
×
UNCOV
626
  return code;
×
627
}
628

629
int32_t vnodeGetStbIdList(SVnode *pVnode, int64_t suid, SArray *list) {
4✔
630
  int32_t      code = TSDB_CODE_SUCCESS;
4✔
631
  SMStbCursor *pCur = metaOpenStbCursor(pVnode->pMeta, suid);
4✔
632
  if (!pCur) {
4!
633
    return TSDB_CODE_OUT_OF_MEMORY;
×
634
  }
635

UNCOV
636
  while (1) {
×
637
    tb_uid_t id = metaStbCursorNext(pCur);
4✔
638
    if (id == 0) {
4!
639
      break;
4✔
640
    }
641

UNCOV
642
    if (NULL == taosArrayPush(list, &id)) {
×
643
      qError("taosArrayPush failed");
×
644
      code = terrno;
×
645
      goto _exit;
×
646
    }
647
  }
648

649
_exit:
4✔
650
  metaCloseStbCursor(pCur);
4✔
651
  return code;
4✔
652
}
653

654
int32_t vnodeGetStbIdListByFilter(SVnode *pVnode, int64_t suid, SArray *list, bool (*filter)(void *arg, void *arg1),
×
655
                                  void *arg) {
656
  int32_t      code = TSDB_CODE_SUCCESS;
×
657
  SMStbCursor *pCur = metaOpenStbCursor(pVnode->pMeta, suid);
×
658
  if (!pCur) {
×
659
    return terrno;
×
660
  }
661

662
  while (1) {
×
663
    tb_uid_t id = metaStbCursorNext(pCur);
×
664
    if (id == 0) {
×
665
      break;
×
666
    }
667

668
    if ((*filter) && (*filter)(arg, &id)) {
×
669
      continue;
×
670
    }
671

672
    if (NULL == taosArrayPush(list, &id)) {
×
673
      qError("taosArrayPush failed");
×
674
      code = terrno;
×
675
      goto _exit;
×
676
    }
677
  }
678

679
_exit:
×
680
  metaCloseStbCursor(pCur);
×
681
  return code;
×
682
}
683

UNCOV
684
int32_t vnodeGetCtbNum(SVnode *pVnode, int64_t suid, int64_t *num) {
×
UNCOV
685
  SMCtbCursor *pCur = metaOpenCtbCursor(pVnode, suid, 0);
×
UNCOV
686
  if (!pCur) {
×
687
    return terrno;
×
688
  }
689

UNCOV
690
  *num = 0;
×
UNCOV
691
  while (1) {
×
UNCOV
692
    tb_uid_t id = metaCtbCursorNext(pCur);
×
UNCOV
693
    if (id == 0) {
×
UNCOV
694
      break;
×
695
    }
696

UNCOV
697
    ++(*num);
×
698
  }
699

UNCOV
700
  metaCloseCtbCursor(pCur);
×
UNCOV
701
  return TSDB_CODE_SUCCESS;
×
702
}
703

UNCOV
704
int32_t vnodeGetStbColumnNum(SVnode *pVnode, tb_uid_t suid, int *num) {
×
UNCOV
705
  SSchemaWrapper *pSW = metaGetTableSchema(pVnode->pMeta, suid, -1, 0, NULL);
×
UNCOV
706
  if (pSW) {
×
UNCOV
707
    *num = pSW->nCols;
×
708
    tDeleteSchemaWrapper(pSW);
709
  } else {
UNCOV
710
    *num = 2;
×
711
  }
712

UNCOV
713
  return TSDB_CODE_SUCCESS;
×
714
}
715

716
#ifdef TD_ENTERPRISE
717
const char *tkLogStb[] = {"cluster_info",
718
                          "data_dir",
719
                          "dnodes_info",
720
                          "d_info",
721
                          "grants_info",
722
                          "keeper_monitor",
723
                          "logs",
724
                          "log_dir",
725
                          "log_summary",
726
                          "m_info",
727
                          "taosadapter_restful_http_request_fail",
728
                          "taosadapter_restful_http_request_in_flight",
729
                          "taosadapter_restful_http_request_summary_milliseconds",
730
                          "taosadapter_restful_http_request_total",
731
                          "taosadapter_system_cpu_percent",
732
                          "taosadapter_system_mem_percent",
733
                          "temp_dir",
734
                          "vgroups_info",
735
                          "vnodes_role"};
736
const char *tkAuditStb[] = {"operations"};
737
const int   tkLogStbNum = ARRAY_SIZE(tkLogStb);
738
const int   tkAuditStbNum = ARRAY_SIZE(tkAuditStb);
739

740
// exclude stbs of taoskeeper log
741
static int32_t vnodeGetTimeSeriesBlackList(SVnode *pVnode, int32_t *tbSize) {
4✔
742
  int32_t      code = TSDB_CODE_SUCCESS;
4✔
743
  int32_t      tbNum = 0;
4✔
744
  const char **pTbArr = NULL;
4✔
745
  const char  *dbName = NULL;
4✔
746
  *tbSize = 0;
4✔
747

748
  if (!(dbName = strchr(pVnode->config.dbname, '.'))) return 0;
4!
749
  if (0 == strncmp(++dbName, "log", TSDB_DB_NAME_LEN)) {
4!
750
    tbNum = tkLogStbNum;
×
751
    pTbArr = (const char **)&tkLogStb;
×
752
  } else if (0 == strncmp(dbName, "audit", TSDB_DB_NAME_LEN)) {
4!
753
    tbNum = tkAuditStbNum;
×
754
    pTbArr = (const char **)&tkAuditStb;
×
755
  }
756
  if (tbNum && pTbArr) {
4!
757
    *tbSize = metaSizeOfTbFilterCache(pVnode->pMeta, 0);
×
758
    if (*tbSize < tbNum) {
×
759
      for (int32_t i = 0; i < tbNum; ++i) {
×
760
        tb_uid_t suid = metaGetTableEntryUidByName(pVnode->pMeta, pTbArr[i]);
×
761
        if (suid != 0) {
×
762
          code = metaPutTbToFilterCache(pVnode->pMeta, &suid, 0);
×
763
          if (TSDB_CODE_SUCCESS != code) {
×
764
            return code;
×
765
          }
766
        }
767
      }
768
      *tbSize = metaSizeOfTbFilterCache(pVnode->pMeta, 0);
×
769
    }
770
  }
771

772
  return code;
4✔
773
}
774
#endif
775

776
static bool vnodeTimeSeriesFilter(void *arg1, void *arg2) {
×
777
  SVnode *pVnode = (SVnode *)arg1;
×
778

779
  if (metaTbInFilterCache(pVnode->pMeta, arg2, 0)) {
×
780
    return true;
×
781
  }
782
  return false;
×
783
}
784

785
int32_t vnodeGetTimeSeriesNum(SVnode *pVnode, int64_t *num) {
4✔
786
  SArray *suidList = NULL;
4✔
787

788
  if (!(suidList = taosArrayInit(1, sizeof(tb_uid_t)))) {
4!
789
    return terrno;
×
790
  }
791

792
  int32_t tbFilterSize = 0;
4✔
793
  int32_t code = TSDB_CODE_SUCCESS;
4✔
794
#ifdef TD_ENTERPRISE
795
  code = vnodeGetTimeSeriesBlackList(pVnode, &tbFilterSize);
4✔
796
  if (TSDB_CODE_SUCCESS != code) {
4!
797
    goto _exit;
×
798
  }
799
#endif
800

801
  if ((!tbFilterSize && vnodeGetStbIdList(pVnode, 0, suidList) < 0) ||
4!
802
      (tbFilterSize && vnodeGetStbIdListByFilter(pVnode, 0, suidList, vnodeTimeSeriesFilter, pVnode) < 0)) {
4!
803
    qError("vgId:%d, failed to get stb id list error: %s", TD_VID(pVnode), terrstr());
×
804
    taosArrayDestroy(suidList);
×
805
    return terrno;
×
806
  }
807

808
  *num = 0;
4✔
809
  int64_t arrSize = taosArrayGetSize(suidList);
4✔
810
  for (int64_t i = 0; i < arrSize; ++i) {
4!
UNCOV
811
    tb_uid_t suid = *(tb_uid_t *)taosArrayGet(suidList, i);
×
812

UNCOV
813
    int64_t ctbNum = 0;
×
UNCOV
814
    int32_t numOfCols = 0;
×
UNCOV
815
    code = metaGetStbStats(pVnode, suid, &ctbNum, &numOfCols);
×
UNCOV
816
    if (TSDB_CODE_SUCCESS != code) {
×
817
      goto _exit;
×
818
    }
UNCOV
819
    *num += ctbNum * (numOfCols - 1);
×
820
  }
821

822
_exit:
4✔
823
  taosArrayDestroy(suidList);
4✔
824
  return TSDB_CODE_SUCCESS;
4✔
825
}
826

827
int32_t vnodeGetAllCtbNum(SVnode *pVnode, int64_t *num) {
×
828
  SMStbCursor *pCur = metaOpenStbCursor(pVnode->pMeta, 0);
×
829
  if (!pCur) {
×
830
    return terrno;
×
831
  }
832

833
  *num = 0;
×
834
  while (1) {
×
835
    tb_uid_t id = metaStbCursorNext(pCur);
×
836
    if (id == 0) {
×
837
      break;
×
838
    }
839

840
    int64_t ctbNum = 0;
×
841
    int32_t code = vnodeGetCtbNum(pVnode, id, &ctbNum);
×
842
    if (TSDB_CODE_SUCCESS != code) {
×
843
      metaCloseStbCursor(pCur);
×
844
      return code;
×
845
    }
846

847
    *num += ctbNum;
×
848
  }
849

850
  metaCloseStbCursor(pCur);
×
851
  return TSDB_CODE_SUCCESS;
×
852
}
853

UNCOV
854
void *vnodeGetIdx(void *pVnode) {
×
UNCOV
855
  if (pVnode == NULL) {
×
856
    return NULL;
×
857
  }
858

UNCOV
859
  return metaGetIdx(((SVnode *)pVnode)->pMeta);
×
860
}
861

UNCOV
862
void *vnodeGetIvtIdx(void *pVnode) {
×
UNCOV
863
  if (pVnode == NULL) {
×
864
    return NULL;
×
865
  }
UNCOV
866
  return metaGetIvtIdx(((SVnode *)pVnode)->pMeta);
×
867
}
868

UNCOV
869
int32_t vnodeGetTableSchema(void *pVnode, int64_t uid, STSchema **pSchema, int64_t *suid) {
×
UNCOV
870
  return tsdbGetTableSchema(((SVnode *)pVnode)->pMeta, uid, pSchema, suid);
×
871
}
872

UNCOV
873
int32_t vnodeGetDBSize(void *pVnode, SDbSizeStatisInfo *pInfo) {
×
UNCOV
874
  SVnode *pVnodeObj = pVnode;
×
UNCOV
875
  if (pVnodeObj == NULL) {
×
876
    return TSDB_CODE_VND_NOT_EXIST;
×
877
  }
UNCOV
878
  int32_t code = 0;
×
UNCOV
879
  char    path[TSDB_FILENAME_LEN] = {0};
×
880

UNCOV
881
  char   *dirName[] = {VNODE_TSDB_DIR, VNODE_WAL_DIR, VNODE_META_DIR, VNODE_TSDB_CACHE_DIR};
×
882
  int64_t dirSize[4];
883

UNCOV
884
  vnodeGetPrimaryDir(pVnodeObj->path, pVnodeObj->diskPrimary, pVnodeObj->pTfs, path, TSDB_FILENAME_LEN);
×
UNCOV
885
  int32_t offset = strlen(path);
×
886

UNCOV
887
  for (int i = 0; i < sizeof(dirName) / sizeof(dirName[0]); i++) {
×
UNCOV
888
    int64_t size = {0};
×
UNCOV
889
    (void)snprintf(path + offset, TSDB_FILENAME_LEN, "%s%s", TD_DIRSEP, dirName[i]);
×
UNCOV
890
    code = taosGetDirSize(path, &size);
×
UNCOV
891
    if (code != 0) {
×
892
      return code;
×
893
    }
UNCOV
894
    path[offset] = 0;
×
UNCOV
895
    dirSize[i] = size;
×
896
  }
897

UNCOV
898
  pInfo->l1Size = dirSize[0] - dirSize[3];
×
UNCOV
899
  pInfo->walSize = dirSize[1];
×
UNCOV
900
  pInfo->metaSize = dirSize[2];
×
UNCOV
901
  pInfo->cacheSize = dirSize[3];
×
902

UNCOV
903
  code = tsdbGetS3Size(pVnodeObj->pTsdb, &pInfo->s3Size);
×
904

UNCOV
905
  return code;
×
906
}
907

UNCOV
908
int32_t vnodeGetStreamProgress(SVnode *pVnode, SRpcMsg *pMsg, bool direct) {
×
UNCOV
909
  int32_t            code = 0;
×
910
  SStreamProgressReq req;
UNCOV
911
  SStreamProgressRsp rsp = {0};
×
UNCOV
912
  SRpcMsg            rpcMsg = {.info = pMsg->info, .code = 0};
×
UNCOV
913
  char              *buf = NULL;
×
UNCOV
914
  int32_t            rspLen = 0;
×
UNCOV
915
  code = tDeserializeStreamProgressReq(pMsg->pCont, pMsg->contLen, &req);
×
916

UNCOV
917
  if (code == TSDB_CODE_SUCCESS) {
×
UNCOV
918
    rsp.fetchIdx = req.fetchIdx;
×
UNCOV
919
    rsp.subFetchIdx = req.subFetchIdx;
×
UNCOV
920
    rsp.vgId = req.vgId;
×
UNCOV
921
    rsp.streamId = req.streamId;
×
UNCOV
922
    rspLen = tSerializeStreamProgressRsp(0, 0, &rsp);
×
UNCOV
923
    if (rspLen < 0) {
×
924
      code = terrno;
×
925
      goto _OVER;
×
926
    }
UNCOV
927
    if (direct) {
×
928
      buf = rpcMallocCont(rspLen);
×
929
    } else {
UNCOV
930
      buf = taosMemoryCalloc(1, rspLen);
×
931
    }
UNCOV
932
    if (!buf) {
×
933
      code = terrno;
×
934
      goto _OVER;
×
935
    }
936
  }
937

UNCOV
938
  if (code == TSDB_CODE_SUCCESS) {
×
UNCOV
939
    code = tqGetStreamExecInfo(pVnode, req.streamId, &rsp.progressDelay, &rsp.fillHisFinished);
×
940
  }
UNCOV
941
  if (code == TSDB_CODE_SUCCESS) {
×
UNCOV
942
    rspLen = tSerializeStreamProgressRsp(buf, rspLen, &rsp);
×
UNCOV
943
    if (rspLen < 0) {
×
944
      code = terrno;
×
945
      goto _OVER;
×
946
    }
UNCOV
947
    rpcMsg.pCont = buf;
×
UNCOV
948
    buf = NULL;
×
UNCOV
949
    rpcMsg.contLen = rspLen;
×
UNCOV
950
    rpcMsg.code = code;
×
UNCOV
951
    rpcMsg.msgType = pMsg->msgType;
×
UNCOV
952
    if (direct) {
×
953
      tmsgSendRsp(&rpcMsg);
×
954
    } else {
UNCOV
955
      *pMsg = rpcMsg;
×
956
    }
957
  }
958

959
_OVER:
×
UNCOV
960
  if (buf) {
×
961
    taosMemoryFree(buf);
×
962
  }
UNCOV
963
  return code;
×
964
}
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