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

taosdata / TDengine / #3548

04 Dec 2024 01:03PM UTC coverage: 59.846% (-0.8%) from 60.691%
#3548

push

travis-ci

web-flow
Merge pull request #29033 from taosdata/fix/calculate-vnode-memory-used

fix/calculate-vnode-memory-used

118484 of 254183 branches covered (46.61%)

Branch coverage included in aggregate %.

199691 of 277471 relevant lines covered (71.97%)

18794141.86 hits per line

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

78.48
/source/dnode/mnode/impl/src/mndShow.c
1
/*
2
 * Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
3
 *
4
 * This program is free software: you can use, redistribute, and/or modify
5
 * it under the terms of the GNU Affero General Public License, version 3
6
 * or later ("AGPL"), as published by the Free Software Foundation.
7
 *
8
 * This program is distributed in the hope that it will be useful, but WITHOUT
9
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
 * FITNESS FOR A PARTICULAR PURPOSE.
11
 *
12
 * You should have received a copy of the GNU Affero General Public License
13
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14
 */
15

16
#define _DEFAULT_SOURCE
17
#include "mndShow.h"
18
#include "mndPrivilege.h"
19
#include "mndUser.h"
20
#include "systable.h"
21

22
#define SHOW_STEP_SIZE            100
23
#define SHOW_COLS_STEP_SIZE       4096
24
#define SHOW_PRIVILEGES_STEP_SIZE 2048
25

26
static SShowObj *mndCreateShowObj(SMnode *pMnode, SRetrieveTableReq *pReq);
27
static void      mndFreeShowObj(SShowObj *pShow);
28
static SShowObj *mndAcquireShowObj(SMnode *pMnode, int64_t showId);
29
static void      mndReleaseShowObj(SShowObj *pShow, bool forceRemove);
30
static bool      mndCheckRetrieveFinished(SShowObj *pShow);
31
static int32_t   mndProcessRetrieveSysTableReq(SRpcMsg *pReq);
32

33
int32_t mndInitShow(SMnode *pMnode) {
1,701✔
34
  int32_t    code = 0;
1,701✔
35
  SShowMgmt *pMgmt = &pMnode->showMgmt;
1,701✔
36

37
  pMgmt->cache = taosCacheInit(TSDB_DATA_TYPE_INT, 5000, true, (__cache_free_fn_t)mndFreeShowObj, "show");
1,701✔
38
  if (pMgmt->cache == NULL) {
1,701!
39
    code = TSDB_CODE_OUT_OF_MEMORY;
×
40
    mError("failed to alloc show cache since %s", tstrerror(code));
×
41
    TAOS_RETURN(code);
×
42
  }
43

44
  mndSetMsgHandle(pMnode, TDMT_MND_SYSTABLE_RETRIEVE, mndProcessRetrieveSysTableReq);
1,701✔
45
  TAOS_RETURN(code);
1,701✔
46
}
47

48
void mndCleanupShow(SMnode *pMnode) {
1,701✔
49
  SShowMgmt *pMgmt = &pMnode->showMgmt;
1,701✔
50
  if (pMgmt->cache != NULL) {
1,701!
51
    taosCacheCleanup(pMgmt->cache);
1,701✔
52
    pMgmt->cache = NULL;
1,701✔
53
  }
54
}
1,701✔
55

56
static int32_t convertToRetrieveType(char *name, int32_t len) {
209,398✔
57
  int32_t type = -1;
209,398✔
58

59
  if (strncasecmp(name, TSDB_INS_TABLE_DNODES, len) == 0) {
209,398✔
60
    type = TSDB_MGMT_TABLE_DNODE;
7,266✔
61
  } else if (strncasecmp(name, TSDB_INS_TABLE_MNODES, len) == 0) {
202,132✔
62
    type = TSDB_MGMT_TABLE_MNODE;
4,483✔
63
    /*
64
      } else if (strncasecmp(name, TSDB_INS_TABLE_MODULES, len) == 0) {
65
        type = TSDB_MGMT_TABLE_MODULE;
66
    */
67
  } else if (strncasecmp(name, TSDB_INS_TABLE_QNODES, len) == 0) {
197,649✔
68
    type = TSDB_MGMT_TABLE_QNODE;
2,189✔
69
  } else if (strncasecmp(name, TSDB_INS_TABLE_SNODES, len) == 0) {
195,460✔
70
    type = TSDB_MGMT_TABLE_SNODE;
2,179✔
71
  } else if (strncasecmp(name, TSDB_INS_TABLE_ANODES, len) == 0) {
193,281!
72
    type = TSDB_MGMT_TABLE_ANODE;
×
73
  } else if (strncasecmp(name, TSDB_INS_TABLE_ANODES_FULL, len) == 0) {
193,281!
74
    type = TSDB_MGMT_TABLE_ANODE_FULL;
×
75
  } else if (strncasecmp(name, TSDB_INS_TABLE_ARBGROUPS, len) == 0) {
193,281!
76
    type = TSDB_MGMT_TABLE_ARBGROUP;
×
77
  } else if (strncasecmp(name, TSDB_INS_TABLE_CLUSTER, len) == 0) {
193,281✔
78
    type = TSDB_MGMT_TABLE_CLUSTER;
4,331✔
79
  } else if (strncasecmp(name, TSDB_INS_TABLE_DATABASES, len) == 0) {
188,950✔
80
    type = TSDB_MGMT_TABLE_DB;
25,334✔
81
  } else if (strncasecmp(name, TSDB_INS_TABLE_FUNCTIONS, len) == 0) {
163,616✔
82
    type = TSDB_MGMT_TABLE_FUNC;
7,208✔
83
  } else if (strncasecmp(name, TSDB_INS_TABLE_INDEXES, len) == 0) {
156,408✔
84
    type = TSDB_MGMT_TABLE_INDEX;
6,738✔
85
  } else if (strncasecmp(name, TSDB_INS_TABLE_STABLES, len) == 0) {
149,670✔
86
    type = TSDB_MGMT_TABLE_STB;
8,406✔
87
  } else if (strncasecmp(name, TSDB_INS_TABLE_TABLES, len) == 0) {
141,264!
88
    type = TSDB_MGMT_TABLE_TABLE;
×
89
  } else if (strncasecmp(name, TSDB_INS_TABLE_TAGS, len) == 0) {
141,264!
90
    type = TSDB_MGMT_TABLE_TAG;
×
91
  } else if (strncasecmp(name, TSDB_INS_TABLE_COLS, len) == 0) {
141,264✔
92
    type = TSDB_MGMT_TABLE_COL;
13,315✔
93
  } else if (strncasecmp(name, TSDB_INS_TABLE_TABLE_DISTRIBUTED, len) == 0) {
127,949!
94
    //    type = TSDB_MGMT_TABLE_DIST;
95
  } else if (strncasecmp(name, TSDB_INS_TABLE_USERS, len) == 0) {
128,055✔
96
    type = TSDB_MGMT_TABLE_USER;
5,074✔
97
  } else if (strncasecmp(name, TSDB_INS_TABLE_USERS_FULL, len) == 0) {
122,981!
98
    type = TSDB_MGMT_TABLE_USER_FULL;
×
99
  } else if (strncasecmp(name, TSDB_INS_TABLE_LICENCES, len) == 0) {
122,981✔
100
    type = TSDB_MGMT_TABLE_GRANTS;
5,757✔
101
  } else if (strncasecmp(name, TSDB_INS_TABLE_VGROUPS, len) == 0) {
117,224✔
102
    type = TSDB_MGMT_TABLE_VGROUP;
10,614✔
103
  } else if (strncasecmp(name, TSDB_PERFS_TABLE_CONSUMERS, len) == 0) {
106,610✔
104
    type = TSDB_MGMT_TABLE_CONSUMERS;
7,988✔
105
  } else if (strncasecmp(name, TSDB_INS_TABLE_SUBSCRIPTIONS, len) == 0) {
98,622✔
106
    type = TSDB_MGMT_TABLE_SUBSCRIPTIONS;
5,846✔
107
  } else if (strncasecmp(name, TSDB_PERFS_TABLE_TRANS, len) == 0) {
92,776✔
108
    type = TSDB_MGMT_TABLE_TRANS;
6,762✔
109
  } else if (strncasecmp(name, TSDB_PERFS_TABLE_SMAS, len) == 0) {
86,014!
110
    type = TSDB_MGMT_TABLE_SMAS;
×
111
  } else if (strncasecmp(name, TSDB_INS_TABLE_CONFIGS, len) == 0) {
86,014✔
112
    type = TSDB_MGMT_TABLE_CONFIGS;
1,443✔
113
  } else if (strncasecmp(name, TSDB_PERFS_TABLE_CONNECTIONS, len) == 0) {
84,571✔
114
    type = TSDB_MGMT_TABLE_CONNS;
5,060✔
115
  } else if (strncasecmp(name, TSDB_PERFS_TABLE_QUERIES, len) == 0) {
79,511✔
116
    type = TSDB_MGMT_TABLE_QUERIES;
10,066✔
117
  } else if (strncasecmp(name, TSDB_INS_TABLE_VNODES, len) == 0) {
69,445✔
118
    type = TSDB_MGMT_TABLE_VNODES;
5,166✔
119
  } else if (strncasecmp(name, TSDB_INS_TABLE_TOPICS, len) == 0) {
64,279✔
120
    type = TSDB_MGMT_TABLE_TOPICS;
5,068✔
121
  } else if (strncasecmp(name, TSDB_INS_TABLE_STREAMS, len) == 0) {
59,211✔
122
    type = TSDB_MGMT_TABLE_STREAMS;
11,237✔
123
  } else if (strncasecmp(name, TSDB_PERFS_TABLE_APPS, len) == 0) {
47,974✔
124
    type = TSDB_MGMT_TABLE_APPS;
10,778✔
125
  } else if (strncasecmp(name, TSDB_INS_TABLE_STREAM_TASKS, len) == 0) {
37,196✔
126
    type = TSDB_MGMT_TABLE_STREAM_TASKS;
19,594✔
127
  } else if (strncasecmp(name, TSDB_INS_TABLE_USER_PRIVILEGES, len) == 0) {
17,602✔
128
    type = TSDB_MGMT_TABLE_PRIVILEGES;
4,332✔
129
  } else if (strncasecmp(name, TSDB_INS_TABLE_VIEWS, len) == 0) {
13,270✔
130
    type = TSDB_MGMT_TABLE_VIEWS;
6,505✔
131
  } else if (strncasecmp(name, TSDB_INS_TABLE_COMPACTS, len) == 0) {
6,765✔
132
    type = TSDB_MGMT_TABLE_COMPACT;
2,236✔
133
  } else if (strncasecmp(name, TSDB_INS_TABLE_COMPACT_DETAILS, len) == 0) {
4,529✔
134
    type = TSDB_MGMT_TABLE_COMPACT_DETAIL;
4,311✔
135
  } else if (strncasecmp(name, TSDB_INS_TABLE_GRANTS_FULL, len) == 0) {
218✔
136
    type = TSDB_MGMT_TABLE_GRANTS_FULL;
6✔
137
  } else if (strncasecmp(name, TSDB_INS_TABLE_GRANTS_LOGS, len) == 0) {
212✔
138
    type = TSDB_MGMT_TABLE_GRANTS_LOGS;
6✔
139
  } else if (strncasecmp(name, TSDB_INS_TABLE_MACHINES, len) == 0) {
206✔
140
    type = TSDB_MGMT_TABLE_MACHINES;
6✔
141
  } else if (strncasecmp(name, TSDB_INS_TABLE_ENCRYPTIONS, len) == 0) {
200!
142
    type = TSDB_MGMT_TABLE_ENCRYPTIONS;
×
143
  } else if (strncasecmp(name, TSDB_INS_TABLE_TSMAS, len) == 0) {
200✔
144
    type = TSDB_MGMT_TABLE_TSMAS;
6✔
145
  } else if (strncasecmp(name, TSDB_INS_DISK_USAGE, len) == 0) {
194!
146
    type = TSDB_MGMT_TABLE_USAGE;
×
147
  } else {
148
    mError("invalid show name:%s len:%d", name, len);
194!
149
  }
150

151
  return type;
209,322✔
152
}
153

154
static SShowObj *mndCreateShowObj(SMnode *pMnode, SRetrieveTableReq *pReq) {
209,330✔
155
  SShowMgmt *pMgmt = &pMnode->showMgmt;
209,330✔
156

157
  int64_t showId = atomic_add_fetch_64(&pMgmt->showId, 1);
209,330✔
158
  if (showId == 0) atomic_add_fetch_64(&pMgmt->showId, 1);
209,653!
159

160
  int32_t size = sizeof(SShowObj);
209,653✔
161

162
  SShowObj showObj = {0};
209,653✔
163

164
  showObj.id = showId;
209,653✔
165
  showObj.pMnode = pMnode;
209,653✔
166
  showObj.type = convertToRetrieveType(pReq->tb, tListLen(pReq->tb));
209,653✔
167
  (void)memcpy(showObj.db, pReq->db, TSDB_DB_FNAME_LEN);
209,367✔
168
  tstrncpy(showObj.filterTb, pReq->filterTb, TSDB_TABLE_NAME_LEN);
209,367✔
169

170
  int32_t   keepTime = tsShellActivityTimer * 6 * 1000;
209,367✔
171
  SShowObj *pShow = taosCachePut(pMgmt->cache, &showId, sizeof(int64_t), &showObj, size, keepTime);
209,367✔
172
  if (pShow == NULL) {
209,593!
173
    terrno = TSDB_CODE_OUT_OF_MEMORY;
×
174
    mError("show:0x%" PRIx64 ", failed to put into cache since %s", showId, terrstr());
×
175
    return NULL;
×
176
  }
177

178
  mTrace("show:0x%" PRIx64 ", is created, data:%p", showId, pShow);
209,593✔
179
  return pShow;
209,578✔
180
}
181

182
static void mndFreeShowObj(SShowObj *pShow) {
209,722✔
183
  SMnode    *pMnode = pShow->pMnode;
209,722✔
184
  SShowMgmt *pMgmt = &pMnode->showMgmt;
209,722✔
185

186
  ShowFreeIterFp freeFp = pMgmt->freeIterFps[pShow->type];
209,722✔
187
  if (freeFp != NULL) {
209,722✔
188
    if (pShow->pIter != NULL) {
197,306!
189
      mTrace("show:0x%" PRIx64 ", is destroying, data:%p, pIter:%p, ", pShow->id, pShow, pShow->pIter);
×
190

191
      (*freeFp)(pMnode, pShow->pIter);
×
192

193
      pShow->pIter = NULL;
×
194
    }
195
  }
196

197
  mTrace("show:0x%" PRIx64 ", is destroyed, data:%p", pShow->id, pShow);
209,722✔
198
}
209,722✔
199

200
static SShowObj *mndAcquireShowObj(SMnode *pMnode, int64_t showId) {
2,995✔
201
  SShowMgmt *pMgmt = &pMnode->showMgmt;
2,995✔
202

203
  SShowObj *pShow = taosCacheAcquireByKey(pMgmt->cache, &showId, sizeof(showId));
2,995✔
204
  if (pShow == NULL) {
2,997!
205
    mError("show:0x%" PRIx64 ", already destroyed", showId);
×
206
    return NULL;
×
207
  }
208

209
  mTrace("show:0x%" PRIx64 ", acquired from cache, data:%p", pShow->id, pShow);
2,997!
210
  return pShow;
2,997✔
211
}
212

213
static void mndReleaseShowObj(SShowObj *pShow, bool forceRemove) {
212,334✔
214
  if (pShow == NULL) return;
212,334!
215
  mTrace("show:0x%" PRIx64 ", released from cache, data:%p force:%d", pShow->id, pShow, forceRemove);
212,334✔
216

217
  // A bug in tcache.c
218
  forceRemove = 0;
212,334✔
219

220
  SMnode    *pMnode = pShow->pMnode;
212,334✔
221
  SShowMgmt *pMgmt = &pMnode->showMgmt;
212,334✔
222
  taosCacheRelease(pMgmt->cache, (void **)(&pShow), forceRemove);
212,334✔
223
}
224

225
static int32_t mndProcessRetrieveSysTableReq(SRpcMsg *pReq) {
212,586✔
226
  int32_t    code = 0;
212,586✔
227
  SMnode    *pMnode = pReq->info.node;
212,586✔
228
  SShowMgmt *pMgmt = &pMnode->showMgmt;
212,586✔
229
  SShowObj  *pShow = NULL;
212,586✔
230
  int32_t    rowsToRead = SHOW_STEP_SIZE;
212,586✔
231
  int32_t    size = 0;
212,586✔
232
  int32_t    rowsRead = 0;
212,586✔
233
  mDebug("mndProcessRetrieveSysTableReq start");
212,586✔
234
  SRetrieveTableReq retrieveReq = {0};
212,586✔
235
  TAOS_CHECK_RETURN(tDeserializeSRetrieveTableReq(pReq->pCont, pReq->contLen, &retrieveReq));
212,586!
236

237
  mDebug("process to retrieve systable req db:%s, tb:%s", retrieveReq.db, retrieveReq.tb);
212,532✔
238

239
  if (retrieveReq.showId == 0) {
212,512✔
240
    STableMetaRsp *pMeta = taosHashGet(pMnode->infosMeta, retrieveReq.tb, strlen(retrieveReq.tb));
209,517✔
241
    if (pMeta == NULL) {
209,522✔
242
      pMeta = taosHashGet(pMnode->perfsMeta, retrieveReq.tb, strlen(retrieveReq.tb));
40,731✔
243
      if (pMeta == NULL) {
40,735!
244
        code = TSDB_CODE_PAR_TABLE_NOT_EXIST;
×
245
        mError("failed to process show-retrieve req:%p since %s", pShow, tstrerror(code));
×
246
        TAOS_RETURN(code);
×
247
      }
248
    }
249

250
    pShow = mndCreateShowObj(pMnode, &retrieveReq);
209,526✔
251
    if (pShow == NULL) {
209,551✔
252
      code = terrno;
80✔
253
      mError("failed to process show-meta req since %s", tstrerror(code));
×
254
      TAOS_RETURN(code);
×
255
    }
256

257
    pShow->pMeta = pMeta;
209,471✔
258
    pShow->numOfColumns = pShow->pMeta->numOfColumns;
209,471✔
259
  } else {
260
    pShow = mndAcquireShowObj(pMnode, retrieveReq.showId);
2,995✔
261
    if (pShow == NULL) {
2,997✔
262
      code = TSDB_CODE_MND_INVALID_SHOWOBJ;
29✔
263
      mError("failed to process show-retrieve req:%p since %s", pShow, tstrerror(code));
29!
264
      TAOS_RETURN(code);
29✔
265
    }
266
  }
267

268
  if (pShow->type == TSDB_MGMT_TABLE_COL) {  // expend capacity for ins_columns
212,439✔
269
    rowsToRead = SHOW_COLS_STEP_SIZE;
13,315✔
270
  } else if (pShow->type == TSDB_MGMT_TABLE_PRIVILEGES) {
199,124✔
271
    rowsToRead = SHOW_PRIVILEGES_STEP_SIZE;
4,333✔
272
  }
273
  ShowRetrieveFp retrieveFp = pMgmt->retrieveFps[pShow->type];
212,439✔
274
  if (retrieveFp == NULL) {
212,439!
275
    mndReleaseShowObj(pShow, false);
×
276
    code = TSDB_CODE_MSG_NOT_PROCESSED;
×
277
    mError("show:0x%" PRIx64 ", failed to retrieve data since %s", pShow->id, tstrerror(code));
×
278
    TAOS_RETURN(code);
×
279
  }
280

281
  mDebug("show:0x%" PRIx64 ", start retrieve data, type:%d", pShow->id, pShow->type);
212,439✔
282
  if (retrieveReq.user[0] != 0) {
212,368!
283
    (void)memcpy(pReq->info.conn.user, retrieveReq.user, TSDB_USER_LEN);
212,368✔
284
  } else {
285
    (void)memcpy(pReq->info.conn.user, TSDB_DEFAULT_USER, strlen(TSDB_DEFAULT_USER) + 1);
×
286
  }
287
  code = -1;
212,368✔
288
  if (retrieveReq.db[0] &&
215,082✔
289
      (code = mndCheckShowPrivilege(pMnode, pReq->info.conn.user, pShow->type, retrieveReq.db)) != 0) {
2,714✔
290
    TAOS_RETURN(code);
4✔
291
  }
292
  if (pShow->type == TSDB_MGMT_TABLE_USER_FULL) {
212,364!
293
    if (strcmp(pReq->info.conn.user, "root") != 0) {
×
294
      mError("The operation is not permitted, user:%s, pShow->type:%d", pReq->info.conn.user, pShow->type);
×
295
      code = TSDB_CODE_MND_NO_RIGHTS;
×
296
      TAOS_RETURN(code);
×
297
    }
298
  }
299

300
  int32_t numOfCols = pShow->pMeta->numOfColumns;
212,364✔
301

302
  SSDataBlock *pBlock = NULL;
212,364✔
303
  code = createDataBlock(&pBlock);
212,364✔
304
  if (code) {
212,453✔
305
    TAOS_RETURN(code);
10✔
306
  }
307

308
  for (int32_t i = 0; i < numOfCols; ++i) {
3,135,945✔
309
    SColumnInfoData idata = {0};
2,923,137✔
310

311
    SSchema *p = &pShow->pMeta->pSchemas[i];
2,923,137✔
312

313
    idata.info.bytes = p->bytes;
2,923,137✔
314
    idata.info.type = p->type;
2,923,137✔
315
    idata.info.colId = p->colId;
2,923,137✔
316
    TAOS_CHECK_RETURN(blockDataAppendColInfo(pBlock, &idata));
2,923,137!
317
  }
318

319
  TAOS_CHECK_RETURN(blockDataEnsureCapacity(pBlock, rowsToRead));
212,808!
320

321
  if (mndCheckRetrieveFinished(pShow)) {
212,530!
322
    mDebug("show:0x%" PRIx64 ", read finished, numOfRows:%d", pShow->id, pShow->numOfRows);
×
323
    rowsRead = 0;
×
324
  } else {
325
    rowsRead = (*retrieveFp)(pReq, pShow, pBlock, rowsToRead);
212,534✔
326
    if (rowsRead < 0) {
212,605✔
327
      code = rowsRead;
3✔
328
      mDebug("show:0x%" PRIx64 ", retrieve completed", pShow->id);
3!
329
      mndReleaseShowObj(pShow, true);
3✔
330
      blockDataDestroy(pBlock);
3✔
331
      TAOS_RETURN(code);
3✔
332
    }
333

334
    pBlock->info.rows = rowsRead;
212,602✔
335
    mDebug("show:0x%" PRIx64 ", stop retrieve data, rowsRead:%d numOfRows:%d", pShow->id, rowsRead, pShow->numOfRows);
212,602✔
336
  }
337

338
  size_t dataEncodeBufSize = blockGetEncodeSize(pBlock);
212,602✔
339
  size = sizeof(SRetrieveMetaTableRsp) + sizeof(int32_t) + sizeof(SSysTableSchema) * pShow->pMeta->numOfColumns +
212,495✔
340
         dataEncodeBufSize;
341

342
  SRetrieveMetaTableRsp *pRsp = rpcMallocCont(size);
212,495✔
343
  if (pRsp == NULL) {
212,485!
344
    mError("show:0x%" PRIx64 ", failed to retrieve data since %s", pShow->id, tstrerror(code));
×
345
    code = terrno;
×
346
    goto _exit;
×
347
  }
348

349
  pRsp->handle = htobe64(pShow->id);
212,485✔
350

351
  if (rowsRead > 0) {
212,482✔
352
    char    *pStart = pRsp->data;
166,755✔
353
    SSchema *ps = pShow->pMeta->pSchemas;
166,755✔
354

355
    *(int32_t *)pStart = htonl(pShow->pMeta->numOfColumns);
166,755✔
356
    pStart += sizeof(int32_t);  // number of columns
166,755✔
357

358
    for (int32_t i = 0; i < pShow->pMeta->numOfColumns; ++i) {
2,727,073✔
359
      SSysTableSchema *pSchema = (SSysTableSchema *)pStart;
2,560,318✔
360
      pSchema->bytes = htonl(ps[i].bytes);
2,560,318✔
361
      pSchema->colId = htons(ps[i].colId);
2,560,318✔
362
      pSchema->type = ps[i].type;
2,560,318✔
363

364
      pStart += sizeof(SSysTableSchema);
2,560,318✔
365
    }
366

367
    int32_t len = blockEncode(pBlock, pStart, dataEncodeBufSize, pShow->pMeta->numOfColumns);
166,755✔
368
    if (len < 0) {
166,795!
369
      mError("show:0x%" PRIx64 ", failed to retrieve data since %s", pShow->id, tstrerror(code));
×
370
      code = terrno;
×
371
      return code;
×
372
    }
373
  }
374

375
  pRsp->numOfRows = htonl(rowsRead);
212,522✔
376
  pRsp->precision = TSDB_TIME_PRECISION_MILLI;  // millisecond time precision
212,522✔
377
  pReq->info.rsp = pRsp;
212,522✔
378
  pReq->info.rspLen = size;
212,522✔
379

380
  if (rowsRead == 0 || mndCheckRetrieveFinished(pShow)) {
212,522✔
381
    pRsp->completed = 1;
209,564✔
382
    mDebug("show:0x%" PRIx64 ", retrieve completed", pShow->id);
209,564✔
383
    mndReleaseShowObj(pShow, true);
209,564✔
384
  } else {
385
    mDebug("show:0x%" PRIx64 ", retrieve not completed yet", pShow->id);
2,994✔
386
    mndReleaseShowObj(pShow, false);
2,994✔
387
  }
388

389
  blockDataDestroy(pBlock);
212,449✔
390
  return TSDB_CODE_SUCCESS;
212,678✔
391
_exit:
×
392
  mndReleaseShowObj(pShow, false);
×
393
  blockDataDestroy(pBlock);
×
394
  if (pRsp) {
×
395
    rpcFreeCont(pRsp);
×
396
  }
397
  return code;
×
398
}
399

400
static bool mndCheckRetrieveFinished(SShowObj *pShow) {
379,200✔
401
  if (pShow->pIter == NULL && pShow->numOfRows != 0) {
379,200✔
402
    return true;
163,733✔
403
  }
404
  return false;
215,467✔
405
}
406

407
void mndAddShowRetrieveHandle(SMnode *pMnode, EShowType showType, ShowRetrieveFp fp) {
62,937✔
408
  SShowMgmt *pMgmt = &pMnode->showMgmt;
62,937✔
409
  pMgmt->retrieveFps[showType] = fp;
62,937✔
410
}
62,937✔
411

412
void mndAddShowFreeIterHandle(SMnode *pMnode, EShowType showType, ShowFreeIterFp fp) {
59,535✔
413
  SShowMgmt *pMgmt = &pMnode->showMgmt;
59,535✔
414
  pMgmt->freeIterFps[showType] = fp;
59,535✔
415
}
59,535✔
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

© 2025 Coveralls, Inc