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

taosdata / TDengine / #3620

21 Feb 2025 09:00AM UTC coverage: 63.573% (+0.2%) from 63.423%
#3620

push

travis-ci

web-flow
ci: taosBenchmark add coverage cases branch 3.0 (#29788)

* fix: add unit test for taos-tools

* fix: only .cpp include

* fix: remove no use function

* fix: restore toolsSys.c

* fix: add toolsSys case

* fix: rebuild error fixed

* fix: fix build error

* fix: support get vgroups with core and memory limit

* fix: build error for strcasecmp

* fix: add insertBasic.py case

* fix: add command line set vgroups=3

* fix: change with ns database

* toolscJson read with int replace float and add insertPrecison.py

* fix: add insertBindVGroup.json case

* fix: remove public fun removeQuotation

* fix: vgroups change method

* fix: memory leak for runInsertLimitThread slot

* insertPrecision.py word write wrong

* fix: check isFloat number

* fix: vgroups change logic error

* fix: insertBasic.py real and expect error

* fix: adjust default vgroups

* fix: adjust default vgroups modify comment

148962 of 300203 branches covered (49.62%)

Branch coverage included in aggregate %.

15 of 16 new or added lines in 1 file covered. (93.75%)

2018 existing lines in 133 files now uncovered.

233201 of 300933 relevant lines covered (77.49%)

18174406.98 hits per line

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

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

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

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

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

52
void vnodePrintTableMeta(STableMetaRsp* pMeta) {
1,288,272✔
53
  if (!(qDebugFlag & DEBUG_DEBUG)) {
1,288,272✔
54
    return;
1,283,628✔
55
  }
56

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

78
}
79

80

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

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

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

106
  if (!reqTbUid) {
1,300,446✔
107
    (void)tsnprintf(tableFName, TSDB_TABLE_FNAME_LEN, "%s.%s", infoReq.dbFName, infoReq.tbName);
1,299,049✔
108
    code = vnodeValidateTableHash(pVnode, tableFName);
1,299,975✔
109
    if (code) {
1,299,967!
110
      goto _exit4;
×
111
    }
112
  }
113

114
  // query meta
115
  metaReaderDoInit(&mer1, pVnode->pMeta, META_READER_LOCK);
1,301,364✔
116
  if (reqTbUid) {
1,300,465✔
117
    errno = 0;
537✔
118
    uint64_t tbUid = taosStr2UInt64(infoReq.tbName, NULL, 10);
537✔
119
    if (errno == ERANGE || tbUid == 0) {
537!
120
      code = TSDB_CODE_TDB_TABLE_NOT_EXIST;
×
121
      goto _exit3;
137✔
122
    }
123
    SMetaReader mr3 = {0};
538✔
124
    metaReaderDoInit(&mr3, ((SVnode *)pVnode)->pMeta, META_READER_NOLOCK);
538✔
125
    if ((code = metaReaderGetTableEntryByUid(&mr3, tbUid)) < 0) {
538✔
126
      metaReaderClear(&mr3);
138✔
127
      TAOS_CHECK_GOTO(code, NULL, _exit3);
138!
128
    }
129
    tstrncpy(metaRsp.tbName, mr3.me.name, TSDB_TABLE_NAME_LEN);
399✔
130
    metaReaderClear(&mr3);
399✔
131
    TAOS_CHECK_GOTO(metaGetTableEntryByName(&mer1, metaRsp.tbName), NULL, _exit3);
400!
132
  } else if (metaGetTableEntryByName(&mer1, infoReq.tbName) < 0) {
1,299,928✔
133
    code = terrno;
11,953✔
134
    goto _exit3;
12,094✔
135
  }
136

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

141
  if (mer1.me.type == TSDB_SUPER_TABLE) {
1,288,549✔
142
    tstrncpy(metaRsp.stbName, mer1.me.name, TSDB_TABLE_NAME_LEN);
669,838✔
143
    schema = mer1.me.stbEntry.schemaRow;
669,838✔
144
    schemaTag = mer1.me.stbEntry.schemaTag;
669,838✔
145
    metaRsp.suid = mer1.me.uid;
669,838✔
146
  } else if (mer1.me.type == TSDB_CHILD_TABLE) {
618,711✔
147
    metaReaderDoInit(&mer2, pVnode->pMeta, META_READER_NOLOCK);
595,763✔
148
    if (metaReaderGetTableEntryByUid(&mer2, mer1.me.ctbEntry.suid) < 0) goto _exit2;
595,763!
149

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

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

187
  vnodePrintTableMeta(&metaRsp);
1,288,267✔
188

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

196
  if (direct) {
1,288,140✔
197
    pRsp = rpcMallocCont(rspLen);
261✔
198
  } else {
199
    pRsp = taosMemoryCalloc(1, rspLen);
1,287,879!
200
  }
201

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

207
  rspLen = tSerializeSTableMetaRsp(pRsp, rspLen, &metaRsp);
1,287,716✔
208
  if (rspLen < 0) {
1,288,370!
209
    code = terrno;
×
210
    goto _exit;
×
211
  }
212

213
_exit:
1,288,370✔
214
  taosMemoryFree(metaRsp.pSchemas);
1,288,669!
215
  taosMemoryFree(metaRsp.pSchemaExt);
1,288,317!
216
_exit2:
1,288,406✔
217
  metaReaderClear(&mer2);
1,288,406✔
218
_exit3:
1,300,489✔
219
  metaReaderClear(&mer1);
1,300,489✔
220
_exit4:
1,300,626✔
221
  rpcMsg.info = pMsg->info;
1,300,626✔
222
  rpcMsg.pCont = pRsp;
1,300,626✔
223
  rpcMsg.contLen = rspLen;
1,300,626✔
224
  rpcMsg.code = code;
1,300,626✔
225
  rpcMsg.msgType = pMsg->msgType;
1,300,626✔
226

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

231
  if (direct) {
1,300,528✔
232
    tmsgSendRsp(&rpcMsg);
2,082✔
233
  } else {
234
    *pMsg = rpcMsg;
1,298,446✔
235
  }
236

237
  return code;
1,300,411✔
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,079,765✔
406
  int32_t      code = 0;
1,079,765✔
407
  int32_t      rspSize = 0;
1,079,765✔
408
  SBatchReq    batchReq = {0};
1,079,765✔
409
  SBatchMsg   *req = NULL;
1,079,765✔
410
  SBatchRspMsg rsp = {0};
1,079,765✔
411
  SBatchRsp    batchRsp = {0};
1,079,765✔
412
  SRpcMsg      reqMsg = *pMsg;
1,079,765✔
413
  SRpcMsg      rspMsg = {0};
1,079,765✔
414
  void        *pRsp = NULL;
1,079,765✔
415

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

422
  int32_t msgNum = taosArrayGetSize(batchReq.pMsgs);
1,080,318✔
423
  if (msgNum >= MAX_META_MSG_IN_BATCH) {
1,079,699!
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,079,699✔
430
  if (NULL == batchRsp.pRsps) {
1,080,516!
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,384,152✔
437
    req = taosArrayGet(batchReq.pMsgs, i);
1,304,173✔
438
    if (req == NULL) {
1,303,610✔
439
      code = terrno;
115✔
440
      goto _exit;
×
441
    }
442

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

447
    switch (req->msgType) {
1,303,495!
448
      case TDMT_VND_TABLE_META:
1,296,922✔
449
        // error code has been set into reqMsg, no need to handle it here.
450
        if (TSDB_CODE_SUCCESS != vnodeGetTableMeta(pVnode, &reqMsg, false)) {
1,296,922✔
451
          qWarn("vnodeGetBatchMeta failed, msgType:%d", req->msgType);
10,273!
452
        }
453
        break;
1,297,582✔
454
      case TDMT_VND_TABLE_NAME:
537✔
455
        // error code has been set into reqMsg, no need to handle it here.
456
        if (TSDB_CODE_SUCCESS != vnodeGetTableMeta(pVnode, &reqMsg, false)) {
537✔
457
          qWarn("vnodeGetBatchName failed, msgType:%d", req->msgType);
138!
458
        }
459
        break;
537✔
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,950✔
467
        // error code has been set into reqMsg, no need to handle it here.
468
        if (TSDB_CODE_SUCCESS != vnodeGetStreamProgress(pVnode, &reqMsg, false)) {
5,950!
469
          qWarn("vnodeGetBatchMeta failed, msgType:%d", req->msgType);
×
470
        }
471
        break;
5,950✔
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,304,155✔
481
    rsp.reqType = reqMsg.msgType;
1,304,155✔
482
    rsp.msgLen = reqMsg.contLen;
1,304,155✔
483
    rsp.rspCode = reqMsg.code;
1,304,155✔
484
    rsp.msg = reqMsg.pCont;
1,304,155✔
485

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

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

511
_exit:
1,080,216✔
512

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

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

523
  taosArrayDestroyEx(batchReq.pMsgs, tFreeSBatchReqMsg);
1,080,216✔
524
  taosArrayDestroyEx(batchRsp.pRsps, tFreeSBatchRspMsg);
1,080,333✔
525

526
  tmsgSendRsp(&rspMsg);
1,080,435✔
527

528
  return code;
1,080,148✔
529
}
530

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

536
  pLoad->vgId = TD_VID(pVnode);
1,044,953✔
537
  pLoad->syncState = state.state;
1,044,953✔
538
  pLoad->syncRestore = state.restored;
1,044,953✔
539
  pLoad->syncTerm = state.term;
1,044,953✔
540
  pLoad->roleTimeMs = state.roleTimeMs;
1,044,953✔
541
  pLoad->startTimeMs = state.startTimeMs;
1,044,953✔
542
  pLoad->syncCanRead = state.canRead;
1,044,953✔
543
  pLoad->learnerProgress = state.progress;
1,044,953✔
544
  pLoad->cacheUsage = tsdbCacheGetUsage(pVnode);
1,044,953✔
545
  pLoad->numOfCachedTables = tsdbCacheGetElems(pVnode);
1,044,953✔
546
  pLoad->numOfTables = metaGetTbNum(pVnode->pMeta);
1,044,953✔
547
  pLoad->numOfTimeSeries = metaGetTimeSeriesNum(pVnode->pMeta, 1);
1,044,953✔
548
  pLoad->totalStorage = (int64_t)3 * 1073741824;
1,044,953✔
549
  pLoad->compStorage = (int64_t)2 * 1073741824;
1,044,953✔
550
  pLoad->pointsWritten = 100;
1,044,953✔
551
  pLoad->numOfSelectReqs = 1;
1,044,953✔
552
  pLoad->numOfInsertReqs = atomic_load_64(&pVnode->statis.nInsert);
1,044,953✔
553
  pLoad->numOfInsertSuccessReqs = atomic_load_64(&pVnode->statis.nInsertSuccess);
1,044,953✔
554
  pLoad->numOfBatchInsertReqs = atomic_load_64(&pVnode->statis.nBatchInsert);
1,044,953✔
555
  pLoad->numOfBatchInsertSuccessReqs = atomic_load_64(&pVnode->statis.nBatchInsertSuccess);
1,044,953✔
556
  return 0;
1,044,953✔
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,907✔
583
  SVnode    *pVnodeObj = pVnode;
920,907✔
584
  SVnodeCfg *pConf = &pVnodeObj->config;
920,907✔
585

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

590
  if (vgId) {
920,907✔
591
    *vgId = TD_VID(pVnodeObj);
920,594✔
592
  }
593

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

598
  if (numOfNormalTables) {
920,907!
599
    *numOfNormalTables = pConf->vndStats.numOfNTables;
×
600
  }
601
}
920,907✔
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,890,110✔
642
  int32_t      code = TSDB_CODE_SUCCESS;
2,890,110✔
643
  SVnode      *pVnodeObj = pVnode;
2,890,110✔
644
  SMCtbCursor *pCur = metaOpenCtbCursor(pVnodeObj, suid, 1);
2,890,110✔
645
  if (NULL == pCur) {
2,897,753!
646
    qError("vnode get all table list failed");
×
647
    return terrno;
×
648
  }
649

650
  while (1) {
9,214,681✔
651
    tb_uid_t id = metaCtbCursorNext(pCur);
12,112,434✔
652
    if (id == 0) {
12,110,230✔
653
      break;
2,899,019✔
654
    }
655

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

663
_exit:
2,899,019✔
664
  metaCloseCtbCursor(pCur);
2,899,019✔
665
  return code;
2,897,800✔
666
}
667

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

675
  while (1) {
145,098✔
676
    tb_uid_t id = metaStbCursorNext(pCur);
304,063✔
677
    if (id == 0) {
304,063✔
678
      break;
158,967✔
679
    }
680

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

688
_exit:
158,967✔
689
  metaCloseStbCursor(pCur);
158,967✔
690
  return code;
158,965✔
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) {
22,615✔
724
  SMCtbCursor *pCur = metaOpenCtbCursor(pVnode, suid, 0);
22,615✔
725
  if (!pCur) {
22,628!
726
    return terrno;
×
727
  }
728

729
  *num = 0;
22,628✔
730
  while (1) {
13,411✔
731
    tb_uid_t id = metaCtbCursorNext(pCur);
36,039✔
732
    if (id == 0) {
36,040✔
733
      break;
22,629✔
734
    }
735

736
    ++(*num);
13,411✔
737
  }
738

739
  metaCloseCtbCursor(pCur);
22,629✔
740
  return TSDB_CODE_SUCCESS;
22,629✔
741
}
742

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

752
  return TSDB_CODE_SUCCESS;
22,630✔
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) {
158,947✔
781
  int32_t      code = TSDB_CODE_SUCCESS;
158,947✔
782
  int32_t      tbNum = 0;
158,947✔
783
  const char **pTbArr = NULL;
158,947✔
784
  const char  *dbName = NULL;
158,947✔
785
  *tbSize = 0;
158,947✔
786

787
  if (!(dbName = strchr(pVnode->config.dbname, '.'))) return 0;
158,947!
788
  if (0 == strncmp(++dbName, "log", TSDB_DB_NAME_LEN)) {
158,947!
789
    tbNum = tkLogStbNum;
×
790
    pTbArr = (const char **)&tkLogStb;
×
791
  } else if (0 == strncmp(dbName, "audit", TSDB_DB_NAME_LEN)) {
158,947!
792
    tbNum = tkAuditStbNum;
×
793
    pTbArr = (const char **)&tkAuditStb;
×
794
  }
795
  if (tbNum && pTbArr) {
158,947!
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;
158,947✔
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) {
158,948✔
825
  SArray *suidList = NULL;
158,948✔
826

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

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

840
  if ((!tbFilterSize && vnodeGetStbIdList(pVnode, 0, suidList) < 0) ||
158,947!
841
      (tbFilterSize && vnodeGetStbIdListByFilter(pVnode, 0, suidList, vnodeTimeSeriesFilter, pVnode) < 0)) {
158,947!
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;
158,949✔
848
  int64_t arrSize = taosArrayGetSize(suidList);
158,949✔
849
  for (int64_t i = 0; i < arrSize; ++i) {
304,032✔
850
    tb_uid_t suid = *(tb_uid_t *)taosArrayGet(suidList, i);
145,082✔
851

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

861
_exit:
158,950✔
862
  taosArrayDestroy(suidList);
158,950✔
863
  return TSDB_CODE_SUCCESS;
158,950✔
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) {
75,146✔
894
  if (pVnode == NULL) {
75,146!
895
    return NULL;
×
896
  }
897

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

901
void *vnodeGetIvtIdx(void *pVnode) {
74,988✔
902
  if (pVnode == NULL) {
74,988!
903
    return NULL;
×
904
  }
905
  return metaGetIvtIdx(((SVnode *)pVnode)->pMeta);
74,988✔
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,950✔
948
  int32_t            code = 0;
5,950✔
949
  SStreamProgressReq req;
950
  SStreamProgressRsp rsp = {0};
5,950✔
951
  SRpcMsg            rpcMsg = {.info = pMsg->info, .code = 0};
5,950✔
952
  char              *buf = NULL;
5,950✔
953
  int32_t            rspLen = 0;
5,950✔
954
  code = tDeserializeStreamProgressReq(pMsg->pCont, pMsg->contLen, &req);
5,950✔
955

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

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

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