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

taosdata / TDengine / #3610

12 Feb 2025 09:54AM UTC coverage: 54.713% (-8.4%) from 63.066%
#3610

push

travis-ci

web-flow
Merge pull request #29745 from taosdata/fix/TD33664-3.0

fix: --version show information check for 3.0

120957 of 286549 branches covered (42.21%)

Branch coverage included in aggregate %.

190849 of 283342 relevant lines covered (67.36%)

4969786.97 hits per line

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

54.39
/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) {
6,736✔
28
  return qWorkerInit(NODE_TYPE_VNODE, TD_VID(pVnode), (void **)&pVnode->pQuery, &pVnode->msgCb);
6,736✔
29
}
30

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

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

35
int32_t fillTableColCmpr(SMetaReader *reader, SSchemaExt *pExt, int32_t numOfCol) {
16,328✔
36
  int8_t tblType = reader->me.type;
16,328✔
37
  if (useCompress(tblType)) {
16,328!
38
    SColCmprWrapper *p = &(reader->me.colCmpr);
16,328✔
39
    if (numOfCol != p->nCols) {
16,328!
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
    }
43
    for (int i = 0; i < p->nCols; i++) {
354,737✔
44
      SColCmpr *pCmpr = &p->pColCmpr[i];
338,409✔
45
      pExt[i].colId = pCmpr->id;
338,409✔
46
      pExt[i].compress = pCmpr->alg;
338,409✔
47
    }
48
  }
49
  return 0;
16,328✔
50
}
51

52
void vnodePrintTableMeta(STableMetaRsp* pMeta) {
16,328✔
53
  if (!(qDebugFlag & DEBUG_DEBUG)) {
16,328✔
54
    return;
13,308✔
55
  }
56

57
  qDebug("tbName:%s", pMeta->tbName);
3,020!
58
  qDebug("stbName:%s", pMeta->stbName);
3,020!
59
  qDebug("dbFName:%s", pMeta->dbFName);
3,020!
60
  qDebug("dbId:%" PRId64, pMeta->dbId);
3,020!
61
  qDebug("numOfTags:%d", pMeta->numOfTags);
3,020!
62
  qDebug("numOfColumns:%d", pMeta->numOfColumns);
3,020!
63
  qDebug("precision:%d", pMeta->precision);
3,020!
64
  qDebug("tableType:%d", pMeta->tableType);
3,020!
65
  qDebug("sversion:%d", pMeta->sversion);
3,020!
66
  qDebug("tversion:%d", pMeta->tversion);
3,020!
67
  qDebug("suid:%" PRIu64, pMeta->suid);
3,020!
68
  qDebug("tuid:%" PRIu64, pMeta->tuid);
3,020!
69
  qDebug("vgId:%d", pMeta->vgId);
3,020!
70
  qDebug("sysInfo:%d", pMeta->sysInfo);
3,020!
71
  if (pMeta->pSchemas) {
3,020!
72
    for (int32_t i = 0; i < (pMeta->numOfColumns + pMeta->numOfTags); ++i) {
187,859✔
73
      SSchema* pSchema = pMeta->pSchemas + i;
184,838✔
74
      qDebug("%d col/tag: type:%d, flags:%d, colId:%d, bytes:%d, name:%s", i, pSchema->type, pSchema->flags, pSchema->colId, pSchema->bytes, pSchema->name);
184,838!
75
    }
76
  }
77

78
}
79

80

81
int32_t vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg, bool direct) {
24,929✔
82
  STableInfoReq  infoReq = {0};
24,929✔
83
  STableMetaRsp  metaRsp = {0};
24,929✔
84
  SMetaReader    mer1 = {0};
24,929✔
85
  SMetaReader    mer2 = {0};
24,929✔
86
  char           tableFName[TSDB_TABLE_FNAME_LEN];
87
  bool           reqTbUid = false;
24,929✔
88
  SRpcMsg        rpcMsg = {0};
24,929✔
89
  int32_t        code = 0;
24,929✔
90
  int32_t        rspLen = 0;
24,929✔
91
  void          *pRsp = NULL;
24,929✔
92
  SSchemaWrapper schema = {0};
24,929✔
93
  SSchemaWrapper schemaTag = {0};
24,929✔
94

95
  // decode req
96
  if (tDeserializeSTableInfoReq(pMsg->pCont, pMsg->contLen, &infoReq) != 0) {
24,929!
97
    code = terrno;
×
98
    goto _exit4;
×
99
  }
100

101
  if (infoReq.option == REQ_OPT_TBUID) reqTbUid = true;
24,931✔
102
  metaRsp.dbId = pVnode->config.dbId;
24,931✔
103
  tstrncpy(metaRsp.tbName, infoReq.tbName, TSDB_TABLE_NAME_LEN);
24,931✔
104
  (void)memcpy(metaRsp.dbFName, infoReq.dbFName, sizeof(metaRsp.dbFName));
24,931✔
105

106
  if (!reqTbUid) {
24,931✔
107
    (void)tsnprintf(tableFName, TSDB_TABLE_FNAME_LEN, "%s.%s", infoReq.dbFName, infoReq.tbName);
24,395✔
108
    code = vnodeValidateTableHash(pVnode, tableFName);
24,397✔
109
    if (code) {
24,395!
110
      goto _exit4;
×
111
    }
112
  }
113

114
  // query meta
115
  metaReaderDoInit(&mer1, pVnode->pMeta, META_READER_LOCK);
24,931✔
116
  if (reqTbUid) {
24,930✔
117
    errno = 0;
534✔
118
    uint64_t tbUid = taosStr2UInt64(infoReq.tbName, NULL, 10);
534✔
119
    if (errno == ERANGE || tbUid == 0) {
534!
120
      code = TSDB_CODE_TDB_TABLE_NOT_EXIST;
×
121
      goto _exit3;
131✔
122
    }
123
    SMetaReader mr3 = {0};
534✔
124
    metaReaderDoInit(&mr3, ((SVnode *)pVnode)->pMeta, META_READER_NOLOCK);
534✔
125
    if ((code = metaReaderGetTableEntryByUid(&mr3, tbUid)) < 0) {
534✔
126
      metaReaderClear(&mr3);
131✔
127
      TAOS_CHECK_GOTO(code, NULL, _exit3);
131!
128
    }
129
    tstrncpy(metaRsp.tbName, mr3.me.name, TSDB_TABLE_NAME_LEN);
403✔
130
    metaReaderClear(&mr3);
403✔
131
    TAOS_CHECK_GOTO(metaGetTableEntryByName(&mer1, metaRsp.tbName), NULL, _exit3);
403!
132
  } else if (metaGetTableEntryByName(&mer1, infoReq.tbName) < 0) {
24,396✔
133
    code = terrno;
8,470✔
134
    goto _exit3;
8,471✔
135
  }
136

137
  metaRsp.tableType = mer1.me.type;
16,328✔
138
  metaRsp.vgId = TD_VID(pVnode);
16,328✔
139
  metaRsp.tuid = mer1.me.uid;
16,328✔
140

141
  if (mer1.me.type == TSDB_SUPER_TABLE) {
16,328✔
142
    tstrncpy(metaRsp.stbName, mer1.me.name, TSDB_TABLE_NAME_LEN);
5,313✔
143
    schema = mer1.me.stbEntry.schemaRow;
5,313✔
144
    schemaTag = mer1.me.stbEntry.schemaTag;
5,313✔
145
    metaRsp.suid = mer1.me.uid;
5,313✔
146
  } else if (mer1.me.type == TSDB_CHILD_TABLE) {
11,015✔
147
    metaReaderDoInit(&mer2, pVnode->pMeta, META_READER_NOLOCK);
6,777✔
148
    if (metaReaderGetTableEntryByUid(&mer2, mer1.me.ctbEntry.suid) < 0) goto _exit2;
6,776!
149

150
    tstrncpy(metaRsp.stbName, mer2.me.name, TSDB_TABLE_NAME_LEN);
6,778✔
151
    metaRsp.suid = mer2.me.uid;
6,778✔
152
    schema = mer2.me.stbEntry.schemaRow;
6,778✔
153
    schemaTag = mer2.me.stbEntry.schemaTag;
6,778✔
154
  } else if (mer1.me.type == TSDB_NORMAL_TABLE) {
4,238!
155
    schema = mer1.me.ntbEntry.schemaRow;
4,238✔
156
  } else {
157
    vError("vnodeGetTableMeta get invalid table type:%d", mer1.me.type);
×
158
    goto _exit3;
×
159
  }
160

161
  metaRsp.numOfTags = schemaTag.nCols;
16,329✔
162
  metaRsp.numOfColumns = schema.nCols;
16,329✔
163
  metaRsp.precision = pVnode->config.tsdbCfg.precision;
16,329✔
164
  metaRsp.sversion = schema.version;
16,329✔
165
  metaRsp.tversion = schemaTag.version;
16,329✔
166
  metaRsp.pSchemas = (SSchema *)taosMemoryMalloc(sizeof(SSchema) * (metaRsp.numOfColumns + metaRsp.numOfTags));
16,329!
167
  metaRsp.pSchemaExt = (SSchemaExt *)taosMemoryCalloc(metaRsp.numOfColumns, sizeof(SSchemaExt));
16,329!
168
  if (NULL == metaRsp.pSchemas || NULL == metaRsp.pSchemaExt) {
16,329!
169
    code = terrno;
×
170
    goto _exit;
×
171
  }
172
  (void)memcpy(metaRsp.pSchemas, schema.pSchema, sizeof(SSchema) * schema.nCols);
16,329✔
173
  if (schemaTag.nCols) {
16,329✔
174
    (void)memcpy(metaRsp.pSchemas + schema.nCols, schemaTag.pSchema, sizeof(SSchema) * schemaTag.nCols);
12,090✔
175
  }
176
  if (metaRsp.pSchemaExt) {
16,329✔
177
    SMetaReader *pReader = mer1.me.type == TSDB_CHILD_TABLE ? &mer2 : &mer1;
16,328✔
178
    code = fillTableColCmpr(pReader, metaRsp.pSchemaExt, metaRsp.numOfColumns);
16,328✔
179
    if (code < 0) {
16,329!
180
      goto _exit;
×
181
    }
182
  } else {
183
    code = TSDB_CODE_OUT_OF_MEMORY;
1✔
184
    goto _exit;
1✔
185
  }
186

187
  vnodePrintTableMeta(&metaRsp);
16,329✔
188

189
  // encode and send response
190
  rspLen = tSerializeSTableMetaRsp(NULL, 0, &metaRsp);
16,329✔
191
  if (rspLen < 0) {
16,327!
192
    code = terrno;
×
193
    goto _exit;
×
194
  }
195

196
  if (direct) {
16,327✔
197
    pRsp = rpcMallocCont(rspLen);
183✔
198
  } else {
199
    pRsp = taosMemoryCalloc(1, rspLen);
16,144!
200
  }
201

202
  if (pRsp == NULL) {
16,328!
203
    code = terrno;
×
204
    goto _exit;
×
205
  }
206

207
  rspLen = tSerializeSTableMetaRsp(pRsp, rspLen, &metaRsp);
16,328✔
208
  if (rspLen < 0) {
16,327!
209
    code = terrno;
×
210
    goto _exit;
×
211
  }
212

213
_exit:
16,327✔
214
  taosMemoryFree(metaRsp.pSchemas);
16,328!
215
  taosMemoryFree(metaRsp.pSchemaExt);
16,326!
216
_exit2:
16,328✔
217
  metaReaderClear(&mer2);
16,328✔
218
_exit3:
24,929✔
219
  metaReaderClear(&mer1);
24,929✔
220
_exit4:
24,931✔
221
  rpcMsg.info = pMsg->info;
24,931✔
222
  rpcMsg.pCont = pRsp;
24,931✔
223
  rpcMsg.contLen = rspLen;
24,931✔
224
  rpcMsg.code = code;
24,931✔
225
  rpcMsg.msgType = pMsg->msgType;
24,931✔
226

227
  if (code) {
24,931✔
228
    qError("get table %s meta with %" PRIu8 " failed cause of %s", infoReq.tbName, infoReq.option, tstrerror(code));
8,602!
229
  }
230

231
  if (direct) {
24,930✔
232
    tmsgSendRsp(&rpcMsg);
771✔
233
  } else {
234
    *pMsg = rpcMsg;
24,159✔
235
  }
236

237
  return code;
24,930✔
238
}
239

240
int32_t vnodeGetTableCfg(SVnode *pVnode, SRpcMsg *pMsg, bool direct) {
4✔
241
  STableCfgReq   cfgReq = {0};
4✔
242
  STableCfgRsp   cfgRsp = {0};
4✔
243
  SMetaReader    mer1 = {0};
4✔
244
  SMetaReader    mer2 = {0};
4✔
245
  char           tableFName[TSDB_TABLE_FNAME_LEN];
246
  SRpcMsg        rpcMsg = {0};
4✔
247
  int32_t        code = 0;
4✔
248
  int32_t        rspLen = 0;
4✔
249
  void          *pRsp = NULL;
4✔
250
  SSchemaWrapper schema = {0};
4✔
251
  SSchemaWrapper schemaTag = {0};
4✔
252

253
  // decode req
254
  if (tDeserializeSTableCfgReq(pMsg->pCont, pMsg->contLen, &cfgReq) != 0) {
4!
255
    code = terrno;
×
256
    goto _exit;
×
257
  }
258

259
  tstrncpy(cfgRsp.tbName, cfgReq.tbName, TSDB_TABLE_NAME_LEN);
4✔
260
  (void)memcpy(cfgRsp.dbFName, cfgReq.dbFName, sizeof(cfgRsp.dbFName));
4✔
261

262
  (void)tsnprintf(tableFName, TSDB_TABLE_FNAME_LEN, "%s.%s", cfgReq.dbFName, cfgReq.tbName);
4✔
263
  code = vnodeValidateTableHash(pVnode, tableFName);
4✔
264
  if (code) {
4!
265
    goto _exit;
×
266
  }
267

268
  // query meta
269
  metaReaderDoInit(&mer1, pVnode->pMeta, META_READER_LOCK);
4✔
270

271
  if (metaGetTableEntryByName(&mer1, cfgReq.tbName) < 0) {
4!
272
    code = terrno;
×
273
    goto _exit;
×
274
  }
275

276
  cfgRsp.tableType = mer1.me.type;
4✔
277

278
  if (mer1.me.type == TSDB_SUPER_TABLE) {
4!
279
    code = TSDB_CODE_VND_HASH_MISMATCH;
×
280
    goto _exit;
×
281
  } else if (mer1.me.type == TSDB_CHILD_TABLE) {
4!
282
    metaReaderDoInit(&mer2, pVnode->pMeta, META_READER_NOLOCK);
4✔
283
    if (metaReaderGetTableEntryByUid(&mer2, mer1.me.ctbEntry.suid) < 0) goto _exit;
4!
284

285
    tstrncpy(cfgRsp.stbName, mer2.me.name, TSDB_TABLE_NAME_LEN);
4✔
286
    schema = mer2.me.stbEntry.schemaRow;
4✔
287
    schemaTag = mer2.me.stbEntry.schemaTag;
4✔
288
    cfgRsp.ttl = mer1.me.ctbEntry.ttlDays;
4✔
289
    cfgRsp.commentLen = mer1.me.ctbEntry.commentLen;
4✔
290
    if (mer1.me.ctbEntry.commentLen > 0) {
4!
291
      cfgRsp.pComment = taosStrdup(mer1.me.ctbEntry.comment);
×
292
      if (NULL == cfgRsp.pComment) {
×
293
        code = terrno;
×
294
        goto _exit;
×
295
      }
296
    }
297
    STag *pTag = (STag *)mer1.me.ctbEntry.pTags;
4✔
298
    cfgRsp.tagsLen = pTag->len;
4✔
299
    cfgRsp.pTags = taosMemoryMalloc(cfgRsp.tagsLen);
4!
300
    if (NULL == cfgRsp.pTags) {
4!
301
      code = terrno;
×
302
      goto _exit;
×
303
    }
304
    (void)memcpy(cfgRsp.pTags, pTag, cfgRsp.tagsLen);
4✔
305
  } else if (mer1.me.type == TSDB_NORMAL_TABLE) {
×
306
    schema = mer1.me.ntbEntry.schemaRow;
×
307
    cfgRsp.ttl = mer1.me.ntbEntry.ttlDays;
×
308
    cfgRsp.commentLen = mer1.me.ntbEntry.commentLen;
×
309
    if (mer1.me.ntbEntry.commentLen > 0) {
×
310
      cfgRsp.pComment = taosStrdup(mer1.me.ntbEntry.comment);
×
311
      if (NULL == cfgRsp.pComment) {
×
312
        code = terrno;
×
313
        goto _exit;
×
314
      }
315
    }
316
  } else {
317
    vError("vnodeGetTableCfg get invalid table type:%d", mer1.me.type);
×
318
    code = TSDB_CODE_APP_ERROR;
×
319
    goto _exit;
×
320
  }
321

322
  cfgRsp.numOfTags = schemaTag.nCols;
4✔
323
  cfgRsp.numOfColumns = schema.nCols;
4✔
324
  cfgRsp.pSchemas = (SSchema *)taosMemoryMalloc(sizeof(SSchema) * (cfgRsp.numOfColumns + cfgRsp.numOfTags));
4!
325
  cfgRsp.pSchemaExt = (SSchemaExt *)taosMemoryMalloc(cfgRsp.numOfColumns * sizeof(SSchemaExt));
4!
326

327
  if (NULL == cfgRsp.pSchemas || NULL == cfgRsp.pSchemaExt) {
4!
328
    code = terrno;
×
329
    goto _exit;
×
330
  }
331
  (void)memcpy(cfgRsp.pSchemas, schema.pSchema, sizeof(SSchema) * schema.nCols);
4✔
332
  if (schemaTag.nCols) {
4!
333
    (void)memcpy(cfgRsp.pSchemas + schema.nCols, schemaTag.pSchema, sizeof(SSchema) * schemaTag.nCols);
4✔
334
  }
335

336
  // if (useCompress(cfgRsp.tableType)) {
337

338
  SMetaReader     *pReader = mer1.me.type == TSDB_CHILD_TABLE ? &mer2 : &mer1;
4!
339
  SColCmprWrapper *pColCmpr = &pReader->me.colCmpr;
4✔
340

341
  for (int32_t i = 0; i < cfgRsp.numOfColumns; i++) {
24✔
342
    SColCmpr   *pCmpr = &pColCmpr->pColCmpr[i];
20✔
343
    SSchemaExt *pSchExt = cfgRsp.pSchemaExt + i;
20✔
344
    pSchExt->colId = pCmpr->id;
20✔
345
    pSchExt->compress = pCmpr->alg;
20✔
346
  }
347
  //}
348

349
  // encode and send response
350
  rspLen = tSerializeSTableCfgRsp(NULL, 0, &cfgRsp);
4✔
351
  if (rspLen < 0) {
4!
352
    code = terrno;
×
353
    goto _exit;
×
354
  }
355

356
  if (direct) {
4!
357
    pRsp = rpcMallocCont(rspLen);
×
358
  } else {
359
    pRsp = taosMemoryCalloc(1, rspLen);
4!
360
  }
361

362
  if (pRsp == NULL) {
4!
363
    code = terrno;
×
364
    goto _exit;
×
365
  }
366

367
  rspLen = tSerializeSTableCfgRsp(pRsp, rspLen, &cfgRsp);
4✔
368
  if (rspLen < 0) {
4!
369
    code = terrno;
×
370
    goto _exit;
×
371
  }
372

373
_exit:
4✔
374
  rpcMsg.info = pMsg->info;
4✔
375
  rpcMsg.pCont = pRsp;
4✔
376
  rpcMsg.contLen = rspLen;
4✔
377
  rpcMsg.code = code;
4✔
378
  rpcMsg.msgType = pMsg->msgType;
4✔
379

380
  if (code) {
4!
381
    qError("get table %s cfg failed cause of %s", cfgReq.tbName, tstrerror(code));
×
382
  }
383

384
  if (direct) {
4!
385
    tmsgSendRsp(&rpcMsg);
×
386
  } else {
387
    *pMsg = rpcMsg;
4✔
388
  }
389

390
  tFreeSTableCfgRsp(&cfgRsp);
4✔
391
  metaReaderClear(&mer2);
4✔
392
  metaReaderClear(&mer1);
4✔
393
  return code;
4✔
394
}
395

396
static FORCE_INLINE void vnodeFreeSBatchRspMsg(void *p) {
397
  if (NULL == p) {
398
    return;
399
  }
400

401
  SBatchRspMsg *pRsp = (SBatchRspMsg *)p;
402
  rpcFreeCont(pRsp->msg);
403
}
404

405
int32_t vnodeGetBatchMeta(SVnode *pVnode, SRpcMsg *pMsg) {
27,083✔
406
  int32_t      code = 0;
27,083✔
407
  int32_t      rspSize = 0;
27,083✔
408
  SBatchReq    batchReq = {0};
27,083✔
409
  SBatchMsg   *req = NULL;
27,083✔
410
  SBatchRspMsg rsp = {0};
27,083✔
411
  SBatchRsp    batchRsp = {0};
27,083✔
412
  SRpcMsg      reqMsg = *pMsg;
27,083✔
413
  SRpcMsg      rspMsg = {0};
27,083✔
414
  void        *pRsp = NULL;
27,083✔
415

416
  if (tDeserializeSBatchReq(pMsg->pCont, pMsg->contLen, &batchReq)) {
27,083!
417
    code = terrno;
×
418
    qError("tDeserializeSBatchReq failed");
×
419
    goto _exit;
×
420
  }
421

422
  int32_t msgNum = taosArrayGetSize(batchReq.pMsgs);
27,085✔
423
  if (msgNum >= MAX_META_MSG_IN_BATCH) {
27,083!
424
    code = TSDB_CODE_INVALID_MSG;
×
425
    qError("too many msgs %d in vnode batch meta req", msgNum);
×
426
    goto _exit;
×
427
  }
428

429
  batchRsp.pRsps = taosArrayInit(msgNum, sizeof(SBatchRspMsg));
27,083✔
430
  if (NULL == batchRsp.pRsps) {
27,085!
431
    code = terrno;
×
432
    qError("taosArrayInit %d SBatchRspMsg failed", msgNum);
×
433
    goto _exit;
×
434
  }
435

436
  for (int32_t i = 0; i < msgNum; ++i) {
57,729✔
437
    req = taosArrayGet(batchReq.pMsgs, i);
30,644✔
438
    if (req == NULL) {
30,644!
439
      code = terrno;
×
440
      goto _exit;
×
441
    }
442

443
    reqMsg.msgType = req->msgType;
30,644✔
444
    reqMsg.pCont = req->msg;
30,644✔
445
    reqMsg.contLen = req->msgLen;
30,644✔
446

447
    switch (req->msgType) {
30,644!
448
      case TDMT_VND_TABLE_META:
23,625✔
449
        // error code has been set into reqMsg, no need to handle it here.
450
        if (TSDB_CODE_SUCCESS != vnodeGetTableMeta(pVnode, &reqMsg, false)) {
23,625✔
451
          qWarn("vnodeGetBatchMeta failed, msgType:%d", req->msgType);
7,883!
452
        }
453
        break;
23,623✔
454
      case TDMT_VND_TABLE_NAME:
534✔
455
        // error code has been set into reqMsg, no need to handle it here.
456
        if (TSDB_CODE_SUCCESS != vnodeGetTableMeta(pVnode, &reqMsg, false)) {
534✔
457
          qWarn("vnodeGetBatchName failed, msgType:%d", req->msgType);
131!
458
        }
459
        break;
534✔
460
      case TDMT_VND_TABLE_CFG:
4✔
461
        // error code has been set into reqMsg, no need to handle it here.
462
        if (TSDB_CODE_SUCCESS != vnodeGetTableCfg(pVnode, &reqMsg, false)) {
4!
463
          qWarn("vnodeGetBatchMeta failed, msgType:%d", req->msgType);
×
464
        }
465
        break;
4✔
466
      case TDMT_VND_GET_STREAM_PROGRESS:
6,481✔
467
        // error code has been set into reqMsg, no need to handle it here.
468
        if (TSDB_CODE_SUCCESS != vnodeGetStreamProgress(pVnode, &reqMsg, false)) {
6,481!
469
          qWarn("vnodeGetBatchMeta failed, msgType:%d", req->msgType);
×
470
        }
471
        break;
6,481✔
472
      default:
×
473
        qError("invalid req msgType %d", req->msgType);
×
474
        reqMsg.code = TSDB_CODE_INVALID_MSG;
×
475
        reqMsg.pCont = NULL;
×
476
        reqMsg.contLen = 0;
×
477
        break;
×
478
    }
479

480
    rsp.msgIdx = req->msgIdx;
30,642✔
481
    rsp.reqType = reqMsg.msgType;
30,642✔
482
    rsp.msgLen = reqMsg.contLen;
30,642✔
483
    rsp.rspCode = reqMsg.code;
30,642✔
484
    rsp.msg = reqMsg.pCont;
30,642✔
485

486
    if (NULL == taosArrayPush(batchRsp.pRsps, &rsp)) {
61,286!
487
      qError("taosArrayPush failed");
×
488
      code = terrno;
×
489
      goto _exit;
×
490
    }
491
  }
492

493
  rspSize = tSerializeSBatchRsp(NULL, 0, &batchRsp);
27,085✔
494
  if (rspSize < 0) {
27,085!
495
    qError("tSerializeSBatchRsp failed");
×
496
    code = terrno;
×
497
    goto _exit;
×
498
  }
499
  pRsp = rpcMallocCont(rspSize);
27,085✔
500
  if (pRsp == NULL) {
27,085!
501
    qError("rpcMallocCont %d failed", rspSize);
×
502
    code = terrno;
×
503
    goto _exit;
×
504
  }
505
  if (tSerializeSBatchRsp(pRsp, rspSize, &batchRsp) < 0) {
27,085!
506
    qError("tSerializeSBatchRsp %d failed", rspSize);
×
507
    code = terrno;
×
508
    goto _exit;
×
509
  }
510

511
_exit:
27,085✔
512

513
  rspMsg.info = pMsg->info;
27,085✔
514
  rspMsg.pCont = pRsp;
27,085✔
515
  rspMsg.contLen = rspSize;
27,085✔
516
  rspMsg.code = code;
27,085✔
517
  rspMsg.msgType = pMsg->msgType;
27,085✔
518

519
  if (code) {
27,085!
520
    qError("vnd get batch meta failed cause of %s", tstrerror(code));
×
521
  }
522

523
  taosArrayDestroyEx(batchReq.pMsgs, tFreeSBatchReqMsg);
27,085✔
524
  taosArrayDestroyEx(batchRsp.pRsps, tFreeSBatchRspMsg);
27,085✔
525

526
  tmsgSendRsp(&rspMsg);
27,084✔
527

528
  return code;
27,085✔
529
}
530

531
int32_t vnodeGetLoad(SVnode *pVnode, SVnodeLoad *pLoad) {
165,996✔
532
  SSyncState state = syncGetState(pVnode->sync);
165,996✔
533

534
  pLoad->vgId = TD_VID(pVnode);
165,996✔
535
  pLoad->syncState = state.state;
165,996✔
536
  pLoad->syncRestore = state.restored;
165,996✔
537
  pLoad->syncTerm = state.term;
165,996✔
538
  pLoad->roleTimeMs = state.roleTimeMs;
165,996✔
539
  pLoad->startTimeMs = state.startTimeMs;
165,996✔
540
  pLoad->syncCanRead = state.canRead;
165,996✔
541
  pLoad->learnerProgress = state.progress;
165,996✔
542
  pLoad->cacheUsage = tsdbCacheGetUsage(pVnode);
165,996✔
543
  pLoad->numOfCachedTables = tsdbCacheGetElems(pVnode);
165,996✔
544
  pLoad->numOfTables = metaGetTbNum(pVnode->pMeta);
165,996✔
545
  pLoad->numOfTimeSeries = metaGetTimeSeriesNum(pVnode->pMeta, 1);
165,996✔
546
  pLoad->totalStorage = (int64_t)3 * 1073741824;
165,996✔
547
  pLoad->compStorage = (int64_t)2 * 1073741824;
165,996✔
548
  pLoad->pointsWritten = 100;
165,996✔
549
  pLoad->numOfSelectReqs = 1;
165,996✔
550
  pLoad->numOfInsertReqs = atomic_load_64(&pVnode->statis.nInsert);
165,996✔
551
  pLoad->numOfInsertSuccessReqs = atomic_load_64(&pVnode->statis.nInsertSuccess);
165,996✔
552
  pLoad->numOfBatchInsertReqs = atomic_load_64(&pVnode->statis.nBatchInsert);
165,996✔
553
  pLoad->numOfBatchInsertSuccessReqs = atomic_load_64(&pVnode->statis.nBatchInsertSuccess);
165,996✔
554
  return 0;
165,996✔
555
}
556

557
int32_t vnodeGetLoadLite(SVnode *pVnode, SVnodeLoadLite *pLoad) {
×
558
  SSyncState syncState = syncGetState(pVnode->sync);
×
559
  if (syncState.state == TAOS_SYNC_STATE_LEADER || syncState.state == TAOS_SYNC_STATE_ASSIGNED_LEADER) {
×
560
    pLoad->vgId = TD_VID(pVnode);
×
561
    pLoad->nTimeSeries = metaGetTimeSeriesNum(pVnode->pMeta, 1);
×
562
    return 0;
×
563
  }
564
  return -1;
×
565
}
566
/**
567
 * @brief Reset the statistics value by monitor interval
568
 *
569
 * @param pVnode
570
 * @param pLoad
571
 */
572
void vnodeResetLoad(SVnode *pVnode, SVnodeLoad *pLoad) {
16✔
573
  VNODE_GET_LOAD_RESET_VALS(pVnode->statis.nInsert, pLoad->numOfInsertReqs, 64, "nInsert");
16!
574
  VNODE_GET_LOAD_RESET_VALS(pVnode->statis.nInsertSuccess, pLoad->numOfInsertSuccessReqs, 64, "nInsertSuccess");
16!
575
  VNODE_GET_LOAD_RESET_VALS(pVnode->statis.nBatchInsert, pLoad->numOfBatchInsertReqs, 64, "nBatchInsert");
16!
576
  VNODE_GET_LOAD_RESET_VALS(pVnode->statis.nBatchInsertSuccess, pLoad->numOfBatchInsertSuccessReqs, 64,
16!
577
                            "nBatchInsertSuccess");
578
}
16✔
579

580
void vnodeGetInfo(void *pVnode, const char **dbname, int32_t *vgId, int64_t *numOfTables, int64_t *numOfNormalTables) {
47,696✔
581
  SVnode    *pVnodeObj = pVnode;
47,696✔
582
  SVnodeCfg *pConf = &pVnodeObj->config;
47,696✔
583

584
  if (dbname) {
47,696!
585
    *dbname = pConf->dbname;
47,702✔
586
  }
587

588
  if (vgId) {
47,696✔
589
    *vgId = TD_VID(pVnodeObj);
46,457✔
590
  }
591

592
  if (numOfTables) {
47,696!
593
    *numOfTables = pConf->vndStats.numOfNTables + pConf->vndStats.numOfCTables;
×
594
  }
595

596
  if (numOfNormalTables) {
47,696!
597
    *numOfNormalTables = pConf->vndStats.numOfNTables;
×
598
  }
599
}
47,696✔
600

601
int32_t vnodeGetTableList(void *pVnode, int8_t type, SArray *pList) {
×
602
  if (type == TSDB_SUPER_TABLE) {
×
603
    return vnodeGetStbIdList(pVnode, 0, pList);
×
604
  } else {
605
    return TSDB_CODE_INVALID_PARA;
×
606
  }
607
}
608

609
int32_t vnodeGetAllTableList(SVnode *pVnode, uint64_t uid, SArray *list) {
×
610
  int32_t      code = TSDB_CODE_SUCCESS;
×
611
  SMCtbCursor *pCur = metaOpenCtbCursor(pVnode, uid, 1);
×
612
  if (NULL == pCur) {
×
613
    qError("vnode get all table list failed");
×
614
    return terrno;
×
615
  }
616

617
  while (1) {
×
618
    tb_uid_t id = metaCtbCursorNext(pCur);
×
619
    if (id == 0) {
×
620
      break;
×
621
    }
622

623
    STableKeyInfo info = {uid = id};
×
624
    if (NULL == taosArrayPush(list, &info)) {
×
625
      qError("taosArrayPush failed");
×
626
      code = terrno;
×
627
      goto _exit;
×
628
    }
629
  }
630
_exit:
×
631
  metaCloseCtbCursor(pCur);
×
632
  return code;
×
633
}
634

635
int32_t vnodeGetCtbIdListByFilter(SVnode *pVnode, int64_t suid, SArray *list, bool (*filter)(void *arg), void *arg) {
×
636
  return 0;
×
637
}
638

639
int32_t vnodeGetCtbIdList(void *pVnode, int64_t suid, SArray *list) {
533,840✔
640
  int32_t      code = TSDB_CODE_SUCCESS;
533,840✔
641
  SVnode      *pVnodeObj = pVnode;
533,840✔
642
  SMCtbCursor *pCur = metaOpenCtbCursor(pVnodeObj, suid, 1);
533,840✔
643
  if (NULL == pCur) {
535,000!
644
    qError("vnode get all table list failed");
×
645
    return terrno;
×
646
  }
647

648
  while (1) {
2,272,406✔
649
    tb_uid_t id = metaCtbCursorNext(pCur);
2,807,406✔
650
    if (id == 0) {
2,806,320✔
651
      break;
535,372✔
652
    }
653

654
    if (NULL == taosArrayPush(list, &id)) {
2,272,406!
655
      qError("taosArrayPush failed");
×
656
      code = terrno;
×
657
      goto _exit;
×
658
    }
659
  }
660

661
_exit:
535,372✔
662
  metaCloseCtbCursor(pCur);
535,372✔
663
  return code;
535,611✔
664
}
665

666
int32_t vnodeGetStbIdList(SVnode *pVnode, int64_t suid, SArray *list) {
79,597✔
667
  int32_t      code = TSDB_CODE_SUCCESS;
79,597✔
668
  SMStbCursor *pCur = metaOpenStbCursor(pVnode->pMeta, suid);
79,597✔
669
  if (!pCur) {
79,598!
670
    return TSDB_CODE_OUT_OF_MEMORY;
×
671
  }
672

673
  while (1) {
119,171✔
674
    tb_uid_t id = metaStbCursorNext(pCur);
198,769✔
675
    if (id == 0) {
198,769✔
676
      break;
79,598✔
677
    }
678

679
    if (NULL == taosArrayPush(list, &id)) {
119,171!
680
      qError("taosArrayPush failed");
×
681
      code = terrno;
×
682
      goto _exit;
×
683
    }
684
  }
685

686
_exit:
79,598✔
687
  metaCloseStbCursor(pCur);
79,598✔
688
  return code;
79,598✔
689
}
690

691
int32_t vnodeGetStbIdListByFilter(SVnode *pVnode, int64_t suid, SArray *list, bool (*filter)(void *arg, void *arg1),
×
692
                                  void *arg) {
693
  int32_t      code = TSDB_CODE_SUCCESS;
×
694
  SMStbCursor *pCur = metaOpenStbCursor(pVnode->pMeta, suid);
×
695
  if (!pCur) {
×
696
    return terrno;
×
697
  }
698

699
  while (1) {
×
700
    tb_uid_t id = metaStbCursorNext(pCur);
×
701
    if (id == 0) {
×
702
      break;
×
703
    }
704

705
    if ((*filter) && (*filter)(arg, &id)) {
×
706
      continue;
×
707
    }
708

709
    if (NULL == taosArrayPush(list, &id)) {
×
710
      qError("taosArrayPush failed");
×
711
      code = terrno;
×
712
      goto _exit;
×
713
    }
714
  }
715

716
_exit:
×
717
  metaCloseStbCursor(pCur);
×
718
  return code;
×
719
}
720

721
int32_t vnodeGetCtbNum(SVnode *pVnode, int64_t suid, int64_t *num) {
14,936✔
722
  SMCtbCursor *pCur = metaOpenCtbCursor(pVnode, suid, 0);
14,936✔
723
  if (!pCur) {
14,935✔
724
    return terrno;
1✔
725
  }
726

727
  *num = 0;
14,934✔
728
  while (1) {
7,152✔
729
    tb_uid_t id = metaCtbCursorNext(pCur);
22,086✔
730
    if (id == 0) {
22,088✔
731
      break;
14,936✔
732
    }
733

734
    ++(*num);
7,152✔
735
  }
736

737
  metaCloseCtbCursor(pCur);
14,936✔
738
  return TSDB_CODE_SUCCESS;
14,940✔
739
}
740

741
int32_t vnodeGetStbColumnNum(SVnode *pVnode, tb_uid_t suid, int *num) {
14,937✔
742
  SSchemaWrapper *pSW = metaGetTableSchema(pVnode->pMeta, suid, -1, 0, NULL);
14,937✔
743
  if (pSW) {
14,936!
744
    *num = pSW->nCols;
14,936!
745
    tDeleteSchemaWrapper(pSW);
746
  } else {
747
    *num = 2;
×
748
  }
749

750
  return TSDB_CODE_SUCCESS;
14,939✔
751
}
752

753
#ifdef TD_ENTERPRISE
754
const char *tkLogStb[] = {"cluster_info",
755
                          "data_dir",
756
                          "dnodes_info",
757
                          "d_info",
758
                          "grants_info",
759
                          "keeper_monitor",
760
                          "logs",
761
                          "log_dir",
762
                          "log_summary",
763
                          "m_info",
764
                          "taosadapter_restful_http_request_fail",
765
                          "taosadapter_restful_http_request_in_flight",
766
                          "taosadapter_restful_http_request_summary_milliseconds",
767
                          "taosadapter_restful_http_request_total",
768
                          "taosadapter_system_cpu_percent",
769
                          "taosadapter_system_mem_percent",
770
                          "temp_dir",
771
                          "vgroups_info",
772
                          "vnodes_role"};
773
const char *tkAuditStb[] = {"operations"};
774
const int   tkLogStbNum = ARRAY_SIZE(tkLogStb);
775
const int   tkAuditStbNum = ARRAY_SIZE(tkAuditStb);
776

777
// exclude stbs of taoskeeper log
778
static int32_t vnodeGetTimeSeriesBlackList(SVnode *pVnode, int32_t *tbSize) {
79,597✔
779
  int32_t      code = TSDB_CODE_SUCCESS;
79,597✔
780
  int32_t      tbNum = 0;
79,597✔
781
  const char **pTbArr = NULL;
79,597✔
782
  const char  *dbName = NULL;
79,597✔
783
  *tbSize = 0;
79,597✔
784

785
  if (!(dbName = strchr(pVnode->config.dbname, '.'))) return 0;
79,597!
786
  if (0 == strncmp(++dbName, "log", TSDB_DB_NAME_LEN)) {
79,597!
787
    tbNum = tkLogStbNum;
×
788
    pTbArr = (const char **)&tkLogStb;
×
789
  } else if (0 == strncmp(dbName, "audit", TSDB_DB_NAME_LEN)) {
79,597!
790
    tbNum = tkAuditStbNum;
×
791
    pTbArr = (const char **)&tkAuditStb;
×
792
  }
793
  if (tbNum && pTbArr) {
79,597!
794
    *tbSize = metaSizeOfTbFilterCache(pVnode->pMeta, 0);
×
795
    if (*tbSize < tbNum) {
×
796
      for (int32_t i = 0; i < tbNum; ++i) {
×
797
        tb_uid_t suid = metaGetTableEntryUidByName(pVnode->pMeta, pTbArr[i]);
×
798
        if (suid != 0) {
×
799
          code = metaPutTbToFilterCache(pVnode->pMeta, &suid, 0);
×
800
          if (TSDB_CODE_SUCCESS != code) {
×
801
            return code;
×
802
          }
803
        }
804
      }
805
      *tbSize = metaSizeOfTbFilterCache(pVnode->pMeta, 0);
×
806
    }
807
  }
808

809
  return code;
79,597✔
810
}
811
#endif
812

813
static bool vnodeTimeSeriesFilter(void *arg1, void *arg2) {
×
814
  SVnode *pVnode = (SVnode *)arg1;
×
815

816
  if (metaTbInFilterCache(pVnode->pMeta, arg2, 0)) {
×
817
    return true;
×
818
  }
819
  return false;
×
820
}
821

822
int32_t vnodeGetTimeSeriesNum(SVnode *pVnode, int64_t *num) {
79,597✔
823
  SArray *suidList = NULL;
79,597✔
824

825
  if (!(suidList = taosArrayInit(1, sizeof(tb_uid_t)))) {
79,597!
826
    return terrno;
×
827
  }
828

829
  int32_t tbFilterSize = 0;
79,598✔
830
  int32_t code = TSDB_CODE_SUCCESS;
79,598✔
831
#ifdef TD_ENTERPRISE
832
  code = vnodeGetTimeSeriesBlackList(pVnode, &tbFilterSize);
79,598✔
833
  if (TSDB_CODE_SUCCESS != code) {
79,597!
834
    goto _exit;
×
835
  }
836
#endif
837

838
  if ((!tbFilterSize && vnodeGetStbIdList(pVnode, 0, suidList) < 0) ||
79,597!
839
      (tbFilterSize && vnodeGetStbIdListByFilter(pVnode, 0, suidList, vnodeTimeSeriesFilter, pVnode) < 0)) {
79,597!
840
    qError("vgId:%d, failed to get stb id list error: %s", TD_VID(pVnode), terrstr());
×
841
    taosArrayDestroy(suidList);
×
842
    return terrno;
×
843
  }
844

845
  *num = 0;
79,598✔
846
  int64_t arrSize = taosArrayGetSize(suidList);
79,598✔
847
  for (int64_t i = 0; i < arrSize; ++i) {
198,768✔
848
    tb_uid_t suid = *(tb_uid_t *)taosArrayGet(suidList, i);
119,170✔
849

850
    int64_t ctbNum = 0;
119,170✔
851
    int32_t numOfCols = 0;
119,170✔
852
    code = metaGetStbStats(pVnode, suid, &ctbNum, &numOfCols);
119,170✔
853
    if (TSDB_CODE_SUCCESS != code) {
119,171!
854
      goto _exit;
×
855
    }
856
    *num += ctbNum * (numOfCols - 1);
119,171✔
857
  }
858

859
_exit:
79,598✔
860
  taosArrayDestroy(suidList);
79,598✔
861
  return TSDB_CODE_SUCCESS;
79,598✔
862
}
863

864
int32_t vnodeGetAllCtbNum(SVnode *pVnode, int64_t *num) {
×
865
  SMStbCursor *pCur = metaOpenStbCursor(pVnode->pMeta, 0);
×
866
  if (!pCur) {
×
867
    return terrno;
×
868
  }
869

870
  *num = 0;
×
871
  while (1) {
×
872
    tb_uid_t id = metaStbCursorNext(pCur);
×
873
    if (id == 0) {
×
874
      break;
×
875
    }
876

877
    int64_t ctbNum = 0;
×
878
    int32_t code = vnodeGetCtbNum(pVnode, id, &ctbNum);
×
879
    if (TSDB_CODE_SUCCESS != code) {
×
880
      metaCloseStbCursor(pCur);
×
881
      return code;
×
882
    }
883

884
    *num += ctbNum;
×
885
  }
886

887
  metaCloseStbCursor(pCur);
×
888
  return TSDB_CODE_SUCCESS;
×
889
}
890

891
void *vnodeGetIdx(void *pVnode) {
3,703✔
892
  if (pVnode == NULL) {
3,703!
893
    return NULL;
×
894
  }
895

896
  return metaGetIdx(((SVnode *)pVnode)->pMeta);
3,703✔
897
}
898

899
void *vnodeGetIvtIdx(void *pVnode) {
3,705✔
900
  if (pVnode == NULL) {
3,705!
901
    return NULL;
×
902
  }
903
  return metaGetIvtIdx(((SVnode *)pVnode)->pMeta);
3,705✔
904
}
905

906
int32_t vnodeGetTableSchema(void *pVnode, int64_t uid, STSchema **pSchema, int64_t *suid) {
93✔
907
  return tsdbGetTableSchema(((SVnode *)pVnode)->pMeta, uid, pSchema, suid);
93✔
908
}
909

910
int32_t vnodeGetDBSize(void *pVnode, SDbSizeStatisInfo *pInfo) {
×
911
  SVnode *pVnodeObj = pVnode;
×
912
  if (pVnodeObj == NULL) {
×
913
    return TSDB_CODE_VND_NOT_EXIST;
×
914
  }
915
  int32_t code = 0;
×
916
  char    path[TSDB_FILENAME_LEN] = {0};
×
917

918
  char   *dirName[] = {VNODE_TSDB_DIR, VNODE_WAL_DIR, VNODE_META_DIR, VNODE_TSDB_CACHE_DIR};
×
919
  int64_t dirSize[4];
920

921
  vnodeGetPrimaryDir(pVnodeObj->path, pVnodeObj->diskPrimary, pVnodeObj->pTfs, path, TSDB_FILENAME_LEN);
×
922
  int32_t offset = strlen(path);
×
923

924
  for (int i = 0; i < sizeof(dirName) / sizeof(dirName[0]); i++) {
×
925
    int64_t size = {0};
×
926
    (void)snprintf(path + offset, TSDB_FILENAME_LEN, "%s%s", TD_DIRSEP, dirName[i]);
×
927
    code = taosGetDirSize(path, &size);
×
928
    if (code != 0) {
×
929
      return code;
×
930
    }
931
    path[offset] = 0;
×
932
    dirSize[i] = size;
×
933
  }
934

935
  pInfo->l1Size = dirSize[0] - dirSize[3];
×
936
  pInfo->walSize = dirSize[1];
×
937
  pInfo->metaSize = dirSize[2];
×
938
  pInfo->cacheSize = dirSize[3];
×
939

940
  code = tsdbGetS3Size(pVnodeObj->pTsdb, &pInfo->s3Size);
×
941

942
  return code;
×
943
}
944

945
int32_t vnodeGetStreamProgress(SVnode *pVnode, SRpcMsg *pMsg, bool direct) {
6,481✔
946
  int32_t            code = 0;
6,481✔
947
  SStreamProgressReq req;
948
  SStreamProgressRsp rsp = {0};
6,481✔
949
  SRpcMsg            rpcMsg = {.info = pMsg->info, .code = 0};
6,481✔
950
  char              *buf = NULL;
6,481✔
951
  int32_t            rspLen = 0;
6,481✔
952
  code = tDeserializeStreamProgressReq(pMsg->pCont, pMsg->contLen, &req);
6,481✔
953

954
  if (code == TSDB_CODE_SUCCESS) {
6,482!
955
    rsp.fetchIdx = req.fetchIdx;
6,482✔
956
    rsp.subFetchIdx = req.subFetchIdx;
6,482✔
957
    rsp.vgId = req.vgId;
6,482✔
958
    rsp.streamId = req.streamId;
6,482✔
959
    rspLen = tSerializeStreamProgressRsp(0, 0, &rsp);
6,482✔
960
    if (rspLen < 0) {
6,481!
961
      code = terrno;
×
962
      goto _OVER;
×
963
    }
964
    if (direct) {
6,481!
965
      buf = rpcMallocCont(rspLen);
×
966
    } else {
967
      buf = taosMemoryCalloc(1, rspLen);
6,481!
968
    }
969
    if (!buf) {
6,482!
970
      code = terrno;
×
971
      goto _OVER;
×
972
    }
973
  }
974

975
  if (code == TSDB_CODE_SUCCESS) {
6,482!
976
    code = tqGetStreamExecInfo(pVnode, req.streamId, &rsp.progressDelay, &rsp.fillHisFinished);
6,482✔
977
  }
978
  if (code == TSDB_CODE_SUCCESS) {
6,482!
979
    rspLen = tSerializeStreamProgressRsp(buf, rspLen, &rsp);
6,482✔
980
    if (rspLen < 0) {
6,481!
981
      code = terrno;
×
982
      goto _OVER;
×
983
    }
984
    rpcMsg.pCont = buf;
6,481✔
985
    buf = NULL;
6,481✔
986
    rpcMsg.contLen = rspLen;
6,481✔
987
    rpcMsg.code = code;
6,481✔
988
    rpcMsg.msgType = pMsg->msgType;
6,481✔
989
    if (direct) {
6,481!
990
      tmsgSendRsp(&rpcMsg);
×
991
    } else {
992
      *pMsg = rpcMsg;
6,481✔
993
    }
994
  }
995

996
_OVER:
×
997
  if (buf) {
6,481!
998
    taosMemoryFree(buf);
×
999
  }
1000
  return code;
6,481✔
1001
}
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