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

taosdata / TDengine / #3616

19 Feb 2025 11:22AM UTC coverage: 63.315% (+0.4%) from 62.953%
#3616

push

travis-ci

web-flow
Merge pull request #29823 from taosdata/feat/TS-5928

fix:[TS-5928]add consumer parameters

148228 of 300186 branches covered (49.38%)

Branch coverage included in aggregate %.

232358 of 300909 relevant lines covered (77.22%)

17990742.15 hits per line

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

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

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

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

35
int32_t fillTableColCmpr(SMetaReader *reader, SSchemaExt *pExt, int32_t numOfCol) {
1,334,329✔
36
  int8_t tblType = reader->me.type;
1,334,329✔
37
  if (useCompress(tblType)) {
1,334,329!
38
    SColCmprWrapper *p = &(reader->me.colCmpr);
1,334,272✔
39
    if (numOfCol != p->nCols) {
1,334,272!
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++) {
33,892,225✔
44
      SColCmpr *pCmpr = &p->pColCmpr[i];
32,557,953✔
45
      pExt[i].colId = pCmpr->id;
32,557,953✔
46
      pExt[i].compress = pCmpr->alg;
32,557,953✔
47
    }
48
  }
49
  return 0;
1,334,247✔
50
}
51

52
void vnodePrintTableMeta(STableMetaRsp* pMeta) {
1,334,316✔
53
  if (!(qDebugFlag & DEBUG_DEBUG)) {
1,334,316✔
54
    return;
1,329,682✔
55
  }
56

57
  qDebug("tbName:%s", pMeta->tbName);
4,634!
58
  qDebug("stbName:%s", pMeta->stbName);
4,634!
59
  qDebug("dbFName:%s", pMeta->dbFName);
4,634!
60
  qDebug("dbId:%" PRId64, pMeta->dbId);
4,634!
61
  qDebug("numOfTags:%d", pMeta->numOfTags);
4,634!
62
  qDebug("numOfColumns:%d", pMeta->numOfColumns);
4,634!
63
  qDebug("precision:%d", pMeta->precision);
4,634!
64
  qDebug("tableType:%d", pMeta->tableType);
4,634!
65
  qDebug("sversion:%d", pMeta->sversion);
4,634!
66
  qDebug("tversion:%d", pMeta->tversion);
4,634!
67
  qDebug("suid:%" PRIu64, pMeta->suid);
4,634!
68
  qDebug("tuid:%" PRIu64, pMeta->tuid);
4,634!
69
  qDebug("vgId:%d", pMeta->vgId);
4,634!
70
  qDebug("sysInfo:%d", pMeta->sysInfo);
4,634!
71
  if (pMeta->pSchemas) {
4,634!
72
    for (int32_t i = 0; i < (pMeta->numOfColumns + pMeta->numOfTags); ++i) {
201,588✔
73
      SSchema* pSchema = pMeta->pSchemas + i;
196,914✔
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);
196,914!
75
    }
76
  }
77

78
}
79

80

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

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

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

106
  if (!reqTbUid) {
1,346,668✔
107
    (void)tsnprintf(tableFName, TSDB_TABLE_FNAME_LEN, "%s.%s", infoReq.dbFName, infoReq.tbName);
1,345,309✔
108
    code = vnodeValidateTableHash(pVnode, tableFName);
1,346,080✔
109
    if (code) {
1,346,027!
110
      goto _exit4;
×
111
    }
112
  }
113

114
  // query meta
115
  metaReaderDoInit(&mer1, pVnode->pMeta, META_READER_LOCK);
1,347,386✔
116
  if (reqTbUid) {
1,346,499✔
117
    errno = 0;
528✔
118
    uint64_t tbUid = taosStr2UInt64(infoReq.tbName, NULL, 10);
528✔
119
    if (errno == ERANGE || tbUid == 0) {
528!
120
      code = TSDB_CODE_TDB_TABLE_NOT_EXIST;
×
121
      goto _exit3;
129✔
122
    }
123
    SMetaReader mr3 = {0};
528✔
124
    metaReaderDoInit(&mr3, ((SVnode *)pVnode)->pMeta, META_READER_NOLOCK);
528✔
125
    if ((code = metaReaderGetTableEntryByUid(&mr3, tbUid)) < 0) {
529✔
126
      metaReaderClear(&mr3);
129✔
127
      TAOS_CHECK_GOTO(code, NULL, _exit3);
129!
128
    }
129
    tstrncpy(metaRsp.tbName, mr3.me.name, TSDB_TABLE_NAME_LEN);
400✔
130
    metaReaderClear(&mr3);
400✔
131
    TAOS_CHECK_GOTO(metaGetTableEntryByName(&mer1, metaRsp.tbName), NULL, _exit3);
401!
132
  } else if (metaGetTableEntryByName(&mer1, infoReq.tbName) < 0) {
1,345,971✔
133
    code = terrno;
11,872✔
134
    goto _exit3;
12,059✔
135
  }
136

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

141
  if (mer1.me.type == TSDB_SUPER_TABLE) {
1,334,707✔
142
    tstrncpy(metaRsp.stbName, mer1.me.name, TSDB_TABLE_NAME_LEN);
709,312✔
143
    schema = mer1.me.stbEntry.schemaRow;
709,312✔
144
    schemaTag = mer1.me.stbEntry.schemaTag;
709,312✔
145
    metaRsp.suid = mer1.me.uid;
709,312✔
146
  } else if (mer1.me.type == TSDB_CHILD_TABLE) {
625,395✔
147
    metaReaderDoInit(&mer2, pVnode->pMeta, META_READER_NOLOCK);
601,264✔
148
    if (metaReaderGetTableEntryByUid(&mer2, mer1.me.ctbEntry.suid) < 0) goto _exit2;
601,262!
149

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

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

187
  vnodePrintTableMeta(&metaRsp);
1,334,338✔
188

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

196
  if (direct) {
1,334,160✔
197
    pRsp = rpcMallocCont(rspLen);
267✔
198
  } else {
199
    pRsp = taosMemoryCalloc(1, rspLen);
1,333,893!
200
  }
201

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

207
  rspLen = tSerializeSTableMetaRsp(pRsp, rspLen, &metaRsp);
1,333,778✔
208
  if (rspLen < 0) {
1,334,451!
209
    code = terrno;
×
210
    goto _exit;
×
211
  }
212

213
_exit:
1,334,451✔
214
  taosMemoryFree(metaRsp.pSchemas);
1,334,813!
215
  taosMemoryFree(metaRsp.pSchemaExt);
1,334,436!
216
_exit2:
1,334,520✔
217
  metaReaderClear(&mer2);
1,334,520✔
218
_exit3:
1,346,488✔
219
  metaReaderClear(&mer1);
1,346,488✔
220
_exit4:
1,346,724✔
221
  rpcMsg.info = pMsg->info;
1,346,724✔
222
  rpcMsg.pCont = pRsp;
1,346,724✔
223
  rpcMsg.contLen = rspLen;
1,346,724✔
224
  rpcMsg.code = code;
1,346,724✔
225
  rpcMsg.msgType = pMsg->msgType;
1,346,724✔
226

227
  if (code) {
1,346,724✔
228
    qError("get table %s meta with %" PRIu8 " failed cause of %s", infoReq.tbName, infoReq.option, tstrerror(code));
12,185!
229
  }
230

231
  if (direct) {
1,346,616✔
232
    tmsgSendRsp(&rpcMsg);
2,088✔
233
  } else {
234
    *pMsg = rpcMsg;
1,344,528✔
235
  }
236

237
  return code;
1,346,285✔
238
}
239

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

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

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

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

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

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

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

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

285
    tstrncpy(cfgRsp.stbName, mer2.me.name, TSDB_TABLE_NAME_LEN);
69✔
286
    schema = mer2.me.stbEntry.schemaRow;
69✔
287
    schemaTag = mer2.me.stbEntry.schemaTag;
69✔
288
    cfgRsp.ttl = mer1.me.ctbEntry.ttlDays;
69✔
289
    cfgRsp.commentLen = mer1.me.ctbEntry.commentLen;
69✔
290
    if (mer1.me.ctbEntry.commentLen > 0) {
69!
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;
69✔
298
    cfgRsp.tagsLen = pTag->len;
69✔
299
    cfgRsp.pTags = taosMemoryMalloc(cfgRsp.tagsLen);
69!
300
    if (NULL == cfgRsp.pTags) {
69!
301
      code = terrno;
×
302
      goto _exit;
×
303
    }
304
    (void)memcpy(cfgRsp.pTags, pTag, cfgRsp.tagsLen);
69✔
305
  } else if (mer1.me.type == TSDB_NORMAL_TABLE) {
17!
306
    schema = mer1.me.ntbEntry.schemaRow;
17✔
307
    cfgRsp.ttl = mer1.me.ntbEntry.ttlDays;
17✔
308
    cfgRsp.commentLen = mer1.me.ntbEntry.commentLen;
17✔
309
    if (mer1.me.ntbEntry.commentLen > 0) {
17!
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;
86✔
323
  cfgRsp.numOfColumns = schema.nCols;
86✔
324
  cfgRsp.pSchemas = (SSchema *)taosMemoryMalloc(sizeof(SSchema) * (cfgRsp.numOfColumns + cfgRsp.numOfTags));
86!
325
  cfgRsp.pSchemaExt = (SSchemaExt *)taosMemoryMalloc(cfgRsp.numOfColumns * sizeof(SSchemaExt));
86!
326

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

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

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

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

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

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

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

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

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

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

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

390
  tFreeSTableCfgRsp(&cfgRsp);
86✔
391
  metaReaderClear(&mer2);
86✔
392
  metaReaderClear(&mer1);
86✔
393
  return code;
86✔
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) {
1,147,415✔
406
  int32_t      code = 0;
1,147,415✔
407
  int32_t      rspSize = 0;
1,147,415✔
408
  SBatchReq    batchReq = {0};
1,147,415✔
409
  SBatchMsg   *req = NULL;
1,147,415✔
410
  SBatchRspMsg rsp = {0};
1,147,415✔
411
  SBatchRsp    batchRsp = {0};
1,147,415✔
412
  SRpcMsg      reqMsg = *pMsg;
1,147,415✔
413
  SRpcMsg      rspMsg = {0};
1,147,415✔
414
  void        *pRsp = NULL;
1,147,415✔
415

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

422
  int32_t msgNum = taosArrayGetSize(batchReq.pMsgs);
1,147,880✔
423
  if (msgNum >= MAX_META_MSG_IN_BATCH) {
1,147,303!
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));
1,147,303✔
430
  if (NULL == batchRsp.pRsps) {
1,147,775!
431
    code = terrno;
×
432
    qError("taosArrayInit %d SBatchRspMsg failed", msgNum);
×
433
    goto _exit;
×
434
  }
435

436
  for (int32_t i = 0; i < msgNum; ++i) {
2,497,139✔
437
    req = taosArrayGet(batchReq.pMsgs, i);
1,350,083✔
438
    if (req == NULL) {
1,349,523✔
439
      code = terrno;
58✔
440
      goto _exit;
×
441
    }
442

443
    reqMsg.msgType = req->msgType;
1,349,465✔
444
    reqMsg.pCont = req->msg;
1,349,465✔
445
    reqMsg.contLen = req->msgLen;
1,349,465✔
446

447
    switch (req->msgType) {
1,349,465!
448
      case TDMT_VND_TABLE_META:
1,342,948✔
449
        // error code has been set into reqMsg, no need to handle it here.
450
        if (TSDB_CODE_SUCCESS != vnodeGetTableMeta(pVnode, &reqMsg, false)) {
1,342,948✔
451
          qWarn("vnodeGetBatchMeta failed, msgType:%d", req->msgType);
10,238!
452
        }
453
        break;
1,343,604✔
454
      case TDMT_VND_TABLE_NAME:
530✔
455
        // error code has been set into reqMsg, no need to handle it here.
456
        if (TSDB_CODE_SUCCESS != vnodeGetTableMeta(pVnode, &reqMsg, false)) {
530✔
457
          qWarn("vnodeGetBatchName failed, msgType:%d", req->msgType);
129!
458
        }
459
        break;
530✔
460
      case TDMT_VND_TABLE_CFG:
86✔
461
        // error code has been set into reqMsg, no need to handle it here.
462
        if (TSDB_CODE_SUCCESS != vnodeGetTableCfg(pVnode, &reqMsg, false)) {
86!
463
          qWarn("vnodeGetBatchMeta failed, msgType:%d", req->msgType);
×
464
        }
465
        break;
86✔
466
      case TDMT_VND_GET_STREAM_PROGRESS:
5,901✔
467
        // error code has been set into reqMsg, no need to handle it here.
468
        if (TSDB_CODE_SUCCESS != vnodeGetStreamProgress(pVnode, &reqMsg, false)) {
5,901!
469
          qWarn("vnodeGetBatchMeta failed, msgType:%d", req->msgType);
×
470
        }
471
        break;
5,903✔
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;
1,350,123✔
481
    rsp.reqType = reqMsg.msgType;
1,350,123✔
482
    rsp.msgLen = reqMsg.contLen;
1,350,123✔
483
    rsp.rspCode = reqMsg.code;
1,350,123✔
484
    rsp.msg = reqMsg.pCont;
1,350,123✔
485

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

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

511
_exit:
1,147,967✔
512

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

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

523
  taosArrayDestroyEx(batchReq.pMsgs, tFreeSBatchReqMsg);
1,147,967✔
524
  taosArrayDestroyEx(batchRsp.pRsps, tFreeSBatchRspMsg);
1,147,712✔
525

526
  tmsgSendRsp(&rspMsg);
1,147,845✔
527

528
  return code;
1,147,758✔
529
}
530

531
int32_t vnodeGetLoad(SVnode *pVnode, SVnodeLoad *pLoad) {
933,513✔
532
  SSyncState state = syncGetState(pVnode->sync);
933,513✔
533
  pLoad->syncAppliedIndex = pVnode->state.applied;
933,513✔
534
  syncGetCommitIndex(pVnode->sync, &pLoad->syncCommitIndex);
933,513✔
535

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

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

582
void vnodeGetInfo(void *pVnode, const char **dbname, int32_t *vgId, int64_t *numOfTables, int64_t *numOfNormalTables) {
920,058✔
583
  SVnode    *pVnodeObj = pVnode;
920,058✔
584
  SVnodeCfg *pConf = &pVnodeObj->config;
920,058✔
585

586
  if (dbname) {
920,058!
587
    *dbname = pConf->dbname;
921,047✔
588
  }
589

590
  if (vgId) {
920,058!
591
    *vgId = TD_VID(pVnodeObj);
920,200✔
592
  }
593

594
  if (numOfTables) {
920,058!
595
    *numOfTables = pConf->vndStats.numOfNTables + pConf->vndStats.numOfCTables;
×
596
  }
597

598
  if (numOfNormalTables) {
920,058!
599
    *numOfNormalTables = pConf->vndStats.numOfNTables;
×
600
  }
601
}
920,058✔
602

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

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

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

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

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

641
int32_t vnodeGetCtbIdList(void *pVnode, int64_t suid, SArray *list) {
2,757,543✔
642
  int32_t      code = TSDB_CODE_SUCCESS;
2,757,543✔
643
  SVnode      *pVnodeObj = pVnode;
2,757,543✔
644
  SMCtbCursor *pCur = metaOpenCtbCursor(pVnodeObj, suid, 1);
2,757,543✔
645
  if (NULL == pCur) {
2,764,905!
646
    qError("vnode get all table list failed");
×
647
    return terrno;
×
648
  }
649

650
  while (1) {
9,014,334✔
651
    tb_uid_t id = metaCtbCursorNext(pCur);
11,779,239✔
652
    if (id == 0) {
11,778,357✔
653
      break;
2,766,751✔
654
    }
655

656
    if (NULL == taosArrayPush(list, &id)) {
9,014,334!
657
      qError("taosArrayPush failed");
×
658
      code = terrno;
×
659
      goto _exit;
×
660
    }
661
  }
662

663
_exit:
2,766,751✔
664
  metaCloseCtbCursor(pCur);
2,766,751✔
665
  return code;
2,765,962✔
666
}
667

668
int32_t vnodeGetStbIdList(SVnode *pVnode, int64_t suid, SArray *list) {
137,719✔
669
  int32_t      code = TSDB_CODE_SUCCESS;
137,719✔
670
  SMStbCursor *pCur = metaOpenStbCursor(pVnode->pMeta, suid);
137,719✔
671
  if (!pCur) {
137,721!
672
    return TSDB_CODE_OUT_OF_MEMORY;
×
673
  }
674

675
  while (1) {
123,893✔
676
    tb_uid_t id = metaStbCursorNext(pCur);
261,614✔
677
    if (id == 0) {
261,611✔
678
      break;
137,721✔
679
    }
680

681
    if (NULL == taosArrayPush(list, &id)) {
123,893!
682
      qError("taosArrayPush failed");
×
683
      code = terrno;
×
684
      goto _exit;
×
685
    }
686
  }
687

688
_exit:
137,721✔
689
  metaCloseStbCursor(pCur);
137,721✔
690
  return code;
137,719✔
691
}
692

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

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

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

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

718
_exit:
×
719
  metaCloseStbCursor(pCur);
×
720
  return code;
×
721
}
722

723
int32_t vnodeGetCtbNum(SVnode *pVnode, int64_t suid, int64_t *num) {
24,517✔
724
  SMCtbCursor *pCur = metaOpenCtbCursor(pVnode, suid, 0);
24,517✔
725
  if (!pCur) {
24,526!
726
    return terrno;
×
727
  }
728

729
  *num = 0;
24,526✔
730
  while (1) {
14,729✔
731
    tb_uid_t id = metaCtbCursorNext(pCur);
39,255✔
732
    if (id == 0) {
39,254✔
733
      break;
24,525✔
734
    }
735

736
    ++(*num);
14,729✔
737
  }
738

739
  metaCloseCtbCursor(pCur);
24,525✔
740
  return TSDB_CODE_SUCCESS;
24,526✔
741
}
742

743
int32_t vnodeGetStbColumnNum(SVnode *pVnode, tb_uid_t suid, int *num) {
24,523✔
744
  SSchemaWrapper *pSW = metaGetTableSchema(pVnode->pMeta, suid, -1, 0);
24,523✔
745
  if (pSW) {
24,524!
746
    *num = pSW->nCols;
24,524!
747
    tDeleteSchemaWrapper(pSW);
748
  } else {
749
    *num = 2;
×
750
  }
751

752
  return TSDB_CODE_SUCCESS;
24,527✔
753
}
754

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

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

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

811
  return code;
137,702✔
812
}
813
#endif
814

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

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

824
int32_t vnodeGetTimeSeriesNum(SVnode *pVnode, int64_t *num) {
137,702✔
825
  SArray *suidList = NULL;
137,702✔
826

827
  if (!(suidList = taosArrayInit(1, sizeof(tb_uid_t)))) {
137,702!
828
    return terrno;
×
829
  }
830

831
  int32_t tbFilterSize = 0;
137,704✔
832
  int32_t code = TSDB_CODE_SUCCESS;
137,704✔
833
#ifdef TD_ENTERPRISE
834
  code = vnodeGetTimeSeriesBlackList(pVnode, &tbFilterSize);
137,704✔
835
  if (TSDB_CODE_SUCCESS != code) {
137,703!
836
    goto _exit;
×
837
  }
838
#endif
839

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

847
  *num = 0;
137,704✔
848
  int64_t arrSize = taosArrayGetSize(suidList);
137,704✔
849
  for (int64_t i = 0; i < arrSize; ++i) {
261,626✔
850
    tb_uid_t suid = *(tb_uid_t *)taosArrayGet(suidList, i);
123,917✔
851

852
    int64_t ctbNum = 0;
123,917✔
853
    int32_t numOfCols = 0;
123,917✔
854
    code = metaGetStbStats(pVnode, suid, &ctbNum, &numOfCols);
123,917✔
855
    if (TSDB_CODE_SUCCESS != code) {
123,924!
856
      goto _exit;
×
857
    }
858
    *num += ctbNum * (numOfCols - 1);
123,924✔
859
  }
860

861
_exit:
137,709✔
862
  taosArrayDestroy(suidList);
137,709✔
863
  return TSDB_CODE_SUCCESS;
137,704✔
864
}
865

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

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

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

886
    *num += ctbNum;
×
887
  }
888

889
  metaCloseStbCursor(pCur);
×
890
  return TSDB_CODE_SUCCESS;
×
891
}
892

893
void *vnodeGetIdx(void *pVnode) {
69,241✔
894
  if (pVnode == NULL) {
69,241!
895
    return NULL;
×
896
  }
897

898
  return metaGetIdx(((SVnode *)pVnode)->pMeta);
69,241✔
899
}
900

901
void *vnodeGetIvtIdx(void *pVnode) {
69,144✔
902
  if (pVnode == NULL) {
69,144!
903
    return NULL;
×
904
  }
905
  return metaGetIvtIdx(((SVnode *)pVnode)->pMeta);
69,144✔
906
}
907

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

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

920
  char   *dirName[] = {VNODE_TSDB_DIR, VNODE_WAL_DIR, VNODE_META_DIR, VNODE_TSDB_CACHE_DIR};
22✔
921
  int64_t dirSize[4];
922

923
  vnodeGetPrimaryDir(pVnodeObj->path, pVnodeObj->diskPrimary, pVnodeObj->pTfs, path, TSDB_FILENAME_LEN);
22✔
924
  int32_t offset = strlen(path);
22✔
925

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

937
  pInfo->l1Size = dirSize[0] - dirSize[3];
22✔
938
  pInfo->walSize = dirSize[1];
22✔
939
  pInfo->metaSize = dirSize[2];
22✔
940
  pInfo->cacheSize = dirSize[3];
22✔
941

942
  code = tsdbGetS3Size(pVnodeObj->pTsdb, &pInfo->s3Size);
22✔
943

944
  return code;
22✔
945
}
946

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

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

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

998
_OVER:
×
999
  if (buf) {
5,902!
1000
    taosMemoryFree(buf);
×
1001
  }
1002
  return code;
5,903✔
1003
}
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