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

taosdata / TDengine / #5063

17 May 2026 01:15AM UTC coverage: 73.388% (-0.02%) from 73.408%
#5063

push

travis-ci

web-flow
feat (TDgpt): Dynamic Model Synchronization Enhancements (#35344)

* refactor: do some internal refactor.

* fix: fix multiprocess sync issue.

* feat: add dynamic anomaly detection and forecasting services

* fix: log error message for undeploying model in exception handling

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* fix: handle undeploy when model exists only on disk

Agent-Logs-Url: https://github.com/taosdata/TDengine/sessions/286aafa0-c3ce-4c27-b803-2707571e9dc1

Co-authored-by: hjxilinx <8252296+hjxilinx@users.noreply.github.com>

* fix: guard dynamic registry concurrent access

Agent-Logs-Url: https://github.com/taosdata/TDengine/sessions/5e4db858-6458-40f4-ac28-d1b1b7f97c18

Co-authored-by: hjxilinx <8252296+hjxilinx@users.noreply.github.com>

* fix: tighten service list locking scope

Agent-Logs-Url: https://github.com/taosdata/TDengine/sessions/5e4db858-6458-40f4-ac28-d1b1b7f97c18

Co-authored-by: hjxilinx <8252296+hjxilinx@users.noreply.github.com>

* fix: restore prophet support and update tests per review feedback

Agent-Logs-Url: https://github.com/taosdata/TDengine/sessions/92298ae1-7da6-4d07-b20e-101c7cd0b26b

Co-authored-by: hjxilinx <8252296+hjxilinx@users.noreply.github.com>

* fix: improve test name and move copy inside lock scope

Agent-Logs-Url: https://github.com/taosdata/TDengine/sessions/92298ae1-7da6-4d07-b20e-101c7cd0b26b

Co-authored-by: hjxilinx <8252296+hjxilinx@users.noreply.github.com>

* Potential fix for pull request finding

Co-au... (continued)

281660 of 383795 relevant lines covered (73.39%)

138762754.36 hits per line

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

85.54
/source/dnode/vnode/src/meta/metaSnapshot.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 <string.h>
17
#include "meta.h"
18
#include "tdataformat.h"
19

20
// SMetaSnapReader ========================================
21
struct SMetaSnapReader {
22
  SMeta*  pMeta;
23
  int64_t sver;
24
  int64_t ever;
25
  TBC*    pTbc;
26
  int32_t iLoop;
27
};
28

29
int32_t metaSnapReaderOpen(SMeta* pMeta, int64_t sver, int64_t ever, SMetaSnapReader** ppReader) {
34,353✔
30
  int32_t          code = 0;
34,353✔
31
  int32_t          lino;
32
  int32_t          c = 0;
34,353✔
33
  SMetaSnapReader* pReader = NULL;
34,353✔
34

35
  // alloc
36
  pReader = (SMetaSnapReader*)taosMemoryCalloc(1, sizeof(*pReader));
34,353✔
37
  if (pReader == NULL) {
34,353✔
38
    TSDB_CHECK_CODE(code = terrno, lino, _exit);
×
39
  }
40
  pReader->pMeta = pMeta;
34,353✔
41
  pReader->sver = sver;
34,353✔
42
  pReader->ever = ever;
34,353✔
43

44
  // impl
45
  code = tdbTbcOpen(pMeta->pTbDb, &pReader->pTbc, NULL);
34,353✔
46
  TSDB_CHECK_CODE(code, lino, _exit);
34,353✔
47

48
  code = tdbTbcMoveTo(pReader->pTbc, &(STbDbKey){.version = sver, .uid = INT64_MIN}, sizeof(STbDbKey), &c);
34,353✔
49
  TSDB_CHECK_CODE(code, lino, _exit);
34,353✔
50

51
_exit:
34,353✔
52
  if (code) {
34,353✔
53
    metaError("vgId:%d, %s failed at %s:%d since %s", TD_VID(pMeta->pVnode), __func__, __FILE__, lino, tstrerror(code));
×
54
    metaSnapReaderClose(&pReader);
×
55
    *ppReader = NULL;
×
56
  } else {
57
    metaInfo("vgId:%d, %s success", TD_VID(pMeta->pVnode), __func__);
34,353✔
58
    *ppReader = pReader;
34,353✔
59
  }
60
  return code;
34,353✔
61
}
62

63
void metaSnapReaderClose(SMetaSnapReader** ppReader) {
34,353✔
64
  if (ppReader && *ppReader) {
34,353✔
65
    tdbTbcClose((*ppReader)->pTbc);
34,353✔
66
    taosMemoryFree(*ppReader);
34,353✔
67
    *ppReader = NULL;
34,353✔
68
  }
69
}
34,353✔
70

71
extern int metaDecodeEntryImpl(SDecoder* pCoder, SMetaEntry* pME, bool headerOnly);
72

73
static int32_t metaDecodeEntryHeader(void* data, int32_t size, SMetaEntry* entry) {
420,210✔
74
  SDecoder decoder = {0};
420,210✔
75
  tDecoderInit(&decoder, (uint8_t*)data, size);
420,210✔
76

77
  int32_t code = metaDecodeEntryImpl(&decoder, entry, true);
420,210✔
78
  if (code) {
420,210✔
79
    tDecoderClear(&decoder);
×
80
    return code;
×
81
  }
82

83
  tDecoderClear(&decoder);
420,210✔
84
  return 0;
420,210✔
85
}
86

87
int32_t metaSnapRead(SMetaSnapReader* pReader, uint8_t** ppData) {
244,051✔
88
  int32_t     code = 0;
244,051✔
89
  const void* pKey = NULL;
244,051✔
90
  const void* pData = NULL;
244,051✔
91
  int32_t     nKey = 0;
244,051✔
92
  int32_t     nData = 0;
244,051✔
93
  STbDbKey    key;
94
  int32_t     c;
244,051✔
95

96
  *ppData = NULL;
244,051✔
97
  while (pReader->iLoop < 2) {
523,269✔
98
    if (tdbTbcGet(pReader->pTbc, &pKey, &nKey, &pData, &nData) != 0 || ((STbDbKey*)pKey)->version > pReader->ever) {
488,916✔
99
      pReader->iLoop++;
68,706✔
100

101
      // Reopen the cursor to read from the beginning
102
      tdbTbcClose(pReader->pTbc);
68,706✔
103
      pReader->pTbc = NULL;
68,706✔
104
      code = tdbTbcOpen(pReader->pMeta->pTbDb, &pReader->pTbc, NULL);
68,706✔
105
      if (code) {
68,706✔
106
        metaError("vgId:%d, %s failed at %s:%d since %s", TD_VID(pReader->pMeta->pVnode), __func__, __FILE__, __LINE__,
×
107
                  tstrerror(code));
108
        goto _exit;
×
109
      }
110

111
      code = tdbTbcMoveTo(pReader->pTbc, &(STbDbKey){.version = pReader->sver, .uid = INT64_MIN}, sizeof(STbDbKey), &c);
68,706✔
112
      if (code) {
68,706✔
113
        metaError("vgId:%d, %s failed at %s:%d since %s", TD_VID(pReader->pMeta->pVnode), __func__, __FILE__, __LINE__,
×
114
                  tstrerror(code));
115
        goto _exit;
×
116
      }
117

118
      continue;
68,706✔
119
    }
120

121
    // Decode meta entry
122
    SMetaEntry entry = {0};
420,210✔
123
    code = metaDecodeEntryHeader((void*)pData, nData, &entry);
420,210✔
124
    if (code) {
420,210✔
125
      metaError("vgId:%d, %s failed at %s:%d since %s", TD_VID(pReader->pMeta->pVnode), __func__, __FILE__, __LINE__,
×
126
                tstrerror(code));
127
      goto _exit;
×
128
    }
129

130
    key = ((STbDbKey*)pKey)[0];
420,210✔
131
    if (key.version < pReader->sver                                       //
420,210✔
132
        || (pReader->iLoop == 0 && TABS(entry.type) != TSDB_SUPER_TABLE)  // First loop send super table entry
419,396✔
133
        || (pReader->iLoop == 1 && TABS(entry.type) == TSDB_SUPER_TABLE)  // Second loop send non-super table entry
240,125✔
134
    ) {
135
      if (tdbTbcMoveToNext(pReader->pTbc) != 0) {
210,512✔
136
        metaTrace("vgId:%d, vnode snapshot meta read data done", TD_VID(pReader->pMeta->pVnode));
×
137
      }
138
      continue;
210,512✔
139
    }
140

141
    if (!pData || !nData) {
209,698✔
142
      metaError("meta/snap: invalide nData: %" PRId32 " meta snap read failed.", nData);
×
143
      goto _exit;
×
144
    }
145

146
    *ppData = taosMemoryMalloc(sizeof(SSnapDataHdr) + nData);
209,698✔
147
    if (*ppData == NULL) {
209,698✔
148
      code = terrno;
×
149
      goto _exit;
×
150
    }
151

152
    SSnapDataHdr* pHdr = (SSnapDataHdr*)(*ppData);
209,698✔
153
    pHdr->type = SNAP_DATA_META;
209,698✔
154
    pHdr->size = nData;
209,698✔
155
    memcpy(pHdr->data, pData, nData);
209,698✔
156

157
    metaDebug("vgId:%d, vnode snapshot meta read data, version:%" PRId64 " uid:%" PRId64 " blockLen:%d",
209,698✔
158
              TD_VID(pReader->pMeta->pVnode), key.version, key.uid, nData);
159

160
    if (tdbTbcMoveToNext(pReader->pTbc) != 0) {
209,698✔
161
      metaTrace("vgId:%d, vnode snapshot meta read data done", TD_VID(pReader->pMeta->pVnode));
×
162
    }
163
    break;
209,698✔
164
  }
165

166
_exit:
244,051✔
167
  if (code) {
244,051✔
168
    metaError("vgId:%d, vnode snapshot meta read data failed since %s", TD_VID(pReader->pMeta->pVnode),
×
169
              tstrerror(code));
170
  }
171
  return code;
244,051✔
172
}
173

174
// SMetaSnapWriter ========================================
175
struct SMetaSnapWriter {
176
  SMeta*  pMeta;
177
  int64_t sver;
178
  int64_t ever;
179
};
180

181
int32_t metaSnapWriterOpen(SMeta* pMeta, int64_t sver, int64_t ever, SMetaSnapWriter** ppWriter) {
30,219✔
182
  int32_t          code = 0;
30,219✔
183
  int32_t          lino;
184
  SMetaSnapWriter* pWriter;
185

186
  // alloc
187
  pWriter = (SMetaSnapWriter*)taosMemoryCalloc(1, sizeof(*pWriter));
30,219✔
188
  if (pWriter == NULL) {
30,219✔
189
    TSDB_CHECK_CODE(code = terrno, lino, _exit);
×
190
  }
191
  pWriter->pMeta = pMeta;
30,219✔
192
  pWriter->sver = sver;
30,219✔
193
  pWriter->ever = ever;
30,219✔
194

195
  code = metaBegin(pMeta, META_BEGIN_HEAP_NIL);
30,219✔
196
  TSDB_CHECK_CODE(code, lino, _exit);
30,219✔
197

198
_exit:
30,219✔
199
  if (code) {
30,219✔
200
    metaError("vgId:%d, %s failed at %s:%d since %s", TD_VID(pMeta->pVnode), __func__, __FILE__, lino, tstrerror(code));
×
201
    taosMemoryFree(pWriter);
×
202
    *ppWriter = NULL;
×
203
  } else {
204
    metaDebug("vgId:%d, %s success", TD_VID(pMeta->pVnode), __func__);
30,219✔
205
    *ppWriter = pWriter;
30,219✔
206
  }
207
  return code;
30,219✔
208
}
209

210
int32_t metaSnapWriterClose(SMetaSnapWriter** ppWriter, int8_t rollback) {
30,219✔
211
  int32_t          code = 0;
30,219✔
212
  SMetaSnapWriter* pWriter = *ppWriter;
30,219✔
213

214
  if (rollback) {
30,219✔
215
    metaInfo("vgId:%d, meta snapshot writer close and rollback start ", TD_VID(pWriter->pMeta->pVnode));
×
216
    code = metaAbort(pWriter->pMeta);
×
217
    metaInfo("vgId:%d, meta snapshot writer close and rollback finished, code:0x%x", TD_VID(pWriter->pMeta->pVnode),
×
218
             code);
219
    if (code) goto _err;
×
220
  } else {
221
    code = metaCommit(pWriter->pMeta, pWriter->pMeta->txn);
30,219✔
222
    if (code) goto _err;
30,219✔
223
    code = metaFinishCommit(pWriter->pMeta, pWriter->pMeta->txn);
30,219✔
224
    if (code) goto _err;
30,219✔
225
  }
226
  taosMemoryFree(pWriter);
30,219✔
227
  *ppWriter = NULL;
30,219✔
228

229
  return code;
30,219✔
230

231
_err:
×
232
  metaError("vgId:%d, meta snapshot writer close failed since %s", TD_VID(pWriter->pMeta->pVnode), tstrerror(code));
×
233
  return code;
×
234
}
235

236
int32_t metaSnapWrite(SMetaSnapWriter* pWriter, uint8_t* pData, uint32_t nData) {
209,686✔
237
  int32_t    code = 0;
209,686✔
238
  int32_t    lino = 0;
209,686✔
239
  SMeta*     pMeta = pWriter->pMeta;
209,686✔
240
  SMetaEntry metaEntry = {0};
209,686✔
241
  SDecoder*  pDecoder = &(SDecoder){0};
209,686✔
242

243
  tDecoderInit(pDecoder, pData + sizeof(SSnapDataHdr), nData - sizeof(SSnapDataHdr));
209,686✔
244
  code = metaDecodeEntry(pDecoder, &metaEntry);
209,686✔
245
  TSDB_CHECK_CODE(code, lino, _exit);
209,686✔
246

247
  metaHandleSyncEntry(pMeta, &metaEntry);
209,686✔
248

249
_exit:
209,686✔
250
  if (code) {
209,686✔
251
    metaError("vgId:%d, %s failed at %s:%d since %s", TD_VID(pMeta->pVnode), __func__, __FILE__, lino, tstrerror(code));
×
252
  }
253
  tDecoderClear(pDecoder);
209,686✔
254
  return code;
209,686✔
255
}
256

257
typedef struct STableInfoForChildTable {
258
  char*           tableName;
259
  SSchemaWrapper* schemaRow;
260
  SSchemaWrapper* tagRow;
261
  SExtSchema*     pExtSchemas;
262
} STableInfoForChildTable;
263

264
static void destroySTableInfoForChildTable(void* data) {
216,756✔
265
  STableInfoForChildTable* pData = (STableInfoForChildTable*)data;
216,756✔
266
  taosMemoryFree(pData->tableName);
216,756✔
267
  tDeleteSchemaWrapper(pData->schemaRow);
216,756✔
268
  tDeleteSchemaWrapper(pData->tagRow);
216,756✔
269
  taosMemoryFreeClear(pData->pExtSchemas);
216,756✔
270
}
216,756✔
271

272
static int32_t MoveToSnapShotVersion(SSnapContext* ctx) {
148,098✔
273
  int32_t code = 0;
148,098✔
274
  tdbTbcClose((TBC*)ctx->pCur);
148,098✔
275
  code = tdbTbcOpen(ctx->pMeta->pTbDb, (TBC**)&ctx->pCur, NULL);
148,098✔
276
  if (code != 0) {
148,098✔
277
    return TAOS_GET_TERRNO(code);
×
278
  }
279
  STbDbKey key = {.version = ctx->snapVersion, .uid = INT64_MAX};
148,098✔
280
  int      c = 0;
148,098✔
281
  code = tdbTbcMoveTo((TBC*)ctx->pCur, &key, sizeof(key), &c);
148,098✔
282
  if (code != 0) {
148,098✔
283
    return TAOS_GET_TERRNO(code);
×
284
  }
285
  if (c < 0) {
148,098✔
286
    if (tdbTbcMoveToPrev((TBC*)ctx->pCur) != 0) {
3,180✔
287
      metaTrace("vgId:%d, vnode snapshot move to prev failed", TD_VID(ctx->pMeta->pVnode));
×
288
    }
289
  }
290
  return 0;
148,098✔
291
}
292

293
static int32_t MoveToPosition(SSnapContext* ctx, int64_t ver, int64_t uid) {
1,884,044✔
294
  tdbTbcClose((TBC*)ctx->pCur);
1,884,044✔
295
  int32_t code = tdbTbcOpen(ctx->pMeta->pTbDb, (TBC**)&ctx->pCur, NULL);
1,884,044✔
296
  if (code != 0) {
1,884,403✔
297
    return TAOS_GET_TERRNO(code);
×
298
  }
299
  STbDbKey key = {.version = ver, .uid = uid};
1,884,403✔
300
  int      c = 0;
1,884,403✔
301
  code = tdbTbcMoveTo((TBC*)ctx->pCur, &key, sizeof(key), &c);
1,884,403✔
302
  if (code != 0) {
1,884,044✔
303
    return TAOS_GET_TERRNO(code);
×
304
  }
305
  return c;
1,884,044✔
306
}
307

308
static int32_t MoveToFirst(SSnapContext* ctx) {
148,098✔
309
  tdbTbcClose((TBC*)ctx->pCur);
148,098✔
310
  int32_t code = tdbTbcOpen(ctx->pMeta->pTbDb, (TBC**)&ctx->pCur, NULL);
148,098✔
311
  if (code != 0) {
148,098✔
312
    return TAOS_GET_TERRNO(code);
×
313
  }
314
  code = tdbTbcMoveToFirst((TBC*)ctx->pCur);
148,098✔
315
  if (code != 0) {
148,098✔
316
    return TAOS_GET_TERRNO(code);
×
317
  }
318
  return 0;
148,098✔
319
}
320

321
static int32_t saveSuperTableInfoForChildTable(SMetaEntry* me, SHashObj* suidInfo) {
216,756✔
322
  STableInfoForChildTable* data = (STableInfoForChildTable*)taosHashGet(suidInfo, &me->uid, sizeof(tb_uid_t));
216,756✔
323
  if (data) {
216,756✔
324
    return 0;
×
325
  }
326
  int32_t                 code = 0;
216,756✔
327
  STableInfoForChildTable dataTmp = {0};
216,756✔
328
  dataTmp.tableName = taosStrdup(me->name);
216,756✔
329
  if (dataTmp.tableName == NULL) {
216,756✔
330
    code = terrno;
×
331
    goto END;
×
332
  }
333
  dataTmp.schemaRow = tCloneSSchemaWrapper(&me->stbEntry.schemaRow);
216,756✔
334
  if (dataTmp.schemaRow == NULL) {
216,756✔
335
    code = TSDB_CODE_OUT_OF_MEMORY;
×
336
    goto END;
×
337
  }
338
  dataTmp.tagRow = tCloneSSchemaWrapper(&me->stbEntry.schemaTag);
216,756✔
339
  if (dataTmp.tagRow == NULL) {
216,756✔
340
    code = TSDB_CODE_OUT_OF_MEMORY;
×
341
    goto END;
×
342
  }
343
  if (me->pExtSchemas != NULL) {
216,756✔
344
    dataTmp.pExtSchemas = taosMemoryMalloc(sizeof(SExtSchema) * me->stbEntry.schemaRow.nCols);
9,789✔
345
    if (dataTmp.pExtSchemas == NULL) {
9,789✔
346
      code = TSDB_CODE_OUT_OF_MEMORY;
×
347
      goto END;
×
348
    }
349
    memcpy(dataTmp.pExtSchemas, me->pExtSchemas, sizeof(SExtSchema) * me->stbEntry.schemaRow.nCols);
9,789✔
350
  }
351
  
352
  code = taosHashPut(suidInfo, &me->uid, sizeof(tb_uid_t), &dataTmp, sizeof(STableInfoForChildTable));
216,756✔
353
  if (code != 0) {
216,756✔
354
    goto END;
×
355
  }
356
  return 0;
216,756✔
357

358
END:
×
359
  destroySTableInfoForChildTable(&dataTmp);
×
360
  return TAOS_GET_TERRNO(code);
×
361
}
362

363
int32_t buildSnapContext(SVnode* pVnode, int64_t snapVersion, int64_t suid, int8_t subType, int8_t withMeta,
147,700✔
364
                         SSnapContext** ctxRet) {
365
  int32_t code = 0;
147,700✔
366
  int32_t lino = 0;
147,700✔
367
  SDecoder   dc = {0};
147,700✔
368
  void* pKey = NULL;
148,098✔
369
  void* pVal = NULL;
148,098✔
370
  int   vLen = 0, kLen = 0;
148,098✔
371

372
  metaRLock(pVnode->pMeta);
148,098✔
373
  SSnapContext* ctx = taosMemoryCalloc(1, sizeof(SSnapContext));
147,765✔
374
  TSDB_CHECK_NULL(ctx, code, lino, END, terrno);
147,765✔
375
  *ctxRet = ctx;
147,765✔
376
  ctx->pMeta = pVnode->pMeta;
147,765✔
377
  ctx->snapVersion = snapVersion;
147,765✔
378
  ctx->suid = suid;
147,765✔
379
  ctx->subType = subType;
147,765✔
380
  ctx->queryMeta = withMeta;
148,098✔
381
  ctx->withMeta = withMeta;
148,098✔
382
  ctx->idVersion = taosHashInit(100, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_NO_LOCK);
148,098✔
383
  TSDB_CHECK_NULL(ctx->idVersion, code, lino, END, terrno);
148,098✔
384
  ctx->suidInfo = taosHashInit(100, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_NO_LOCK);
148,098✔
385
  TSDB_CHECK_NULL(ctx->suidInfo, code, lino, END, terrno);
148,098✔
386
  taosHashSetFreeFp(ctx->suidInfo, destroySTableInfoForChildTable);
148,098✔
387

388
  ctx->index = 0;
148,098✔
389
  ctx->idList = taosArrayInit(100, sizeof(int64_t));
148,098✔
390
  TSDB_CHECK_NULL(ctx->idList, code, lino, END, terrno);
148,098✔
391

392
  metaDebug("tmqsnap init snapVersion:%" PRIi64, ctx->snapVersion);
148,098✔
393
  code = MoveToFirst(ctx);
148,098✔
394
  TSDB_CHECK_CODE(code, lino, END);
148,098✔
395
  while (1) {
14,509,087✔
396
    int32_t ret = tdbTbcNext((TBC*)ctx->pCur, &pKey, &kLen, &pVal, &vLen);
14,657,185✔
397
    if (ret < 0) break;
14,654,593✔
398
    STbDbKey* tmp = (STbDbKey*)pKey;
14,510,433✔
399
    if (tmp->version > ctx->snapVersion) break;
14,510,433✔
400

401
    SIdInfo* idData = (SIdInfo*)taosHashGet(ctx->idVersion, &tmp->uid, sizeof(tb_uid_t));
14,507,648✔
402
    if (idData) {
14,506,839✔
403
      continue;
121,217✔
404
    }
405

406
    // check if table exist for now, need optimize later
407
    if (tdbTbGet(ctx->pMeta->pUidIdx, &tmp->uid, sizeof(tb_uid_t), NULL, NULL) < 0) {
14,385,622✔
408
      continue;
116,120✔
409
    }
410

411
    SMetaEntry me = {0};
14,266,044✔
412
    tDecoderInit(&dc, pVal, vLen);
14,266,390✔
413
    code = metaDecodeEntry(&dc, &me);
14,270,560✔
414
    TSDB_CHECK_CODE(code, lino, END);
14,264,099✔
415
    if (ctx->subType == TOPIC_SUB_TYPE__TABLE) {
14,264,099✔
416
      if (!((me.uid == ctx->suid && me.type == TSDB_SUPER_TABLE) ||
262,305✔
417
          (me.ctbEntry.suid == ctx->suid && (me.type == TSDB_CHILD_TABLE || me.type == TSDB_VIRTUAL_CHILD_TABLE)))) {
234,065✔
418
        tDecoderClear(&dc);
30,137✔
419
        continue;
30,137✔
420
      }
421
    }
422

423
    TSDB_CHECK_NULL(taosArrayPush(ctx->idList, &tmp->uid), code, lino, END, terrno);
28,477,799✔
424
    metaDebug("tmqsnap init idlist name:%s, uid:%" PRIi64, me.name, tmp->uid);
14,241,928✔
425
    tDecoderClear(&dc);
14,242,312✔
426

427
    SIdInfo info = {0};
14,244,136✔
428
    code = taosHashPut(ctx->idVersion, &tmp->uid, sizeof(tb_uid_t), &info, sizeof(SIdInfo));
14,244,136✔
429
    TSDB_CHECK_CODE(code, lino, END);
14,241,960✔
430
  }
431
  taosHashClear(ctx->idVersion);
148,098✔
432

433
  code = MoveToSnapShotVersion(ctx);
148,098✔
434
  TSDB_CHECK_CODE(code, lino, END);
148,098✔
435

436
  while (1) {
14,511,622✔
437
    int32_t ret = tdbTbcPrev((TBC*)ctx->pCur, &pKey, &kLen, &pVal, &vLen);
14,659,720✔
438
    if (ret < 0) break;
14,657,119✔
439

440
    STbDbKey* tmp = (STbDbKey*)pKey;
14,509,021✔
441
    SIdInfo*  idData = (SIdInfo*)taosHashGet(ctx->idVersion, &tmp->uid, sizeof(tb_uid_t));
14,509,021✔
442
    if (idData) {
14,511,256✔
443
      continue;
205,251✔
444
    }
445
    SIdInfo info = {.version = tmp->version, .index = 0};
14,306,005✔
446
    code = taosHashPut(ctx->idVersion, &tmp->uid, sizeof(tb_uid_t), &info, sizeof(SIdInfo));
14,306,383✔
447
    TSDB_CHECK_CODE(code, lino, END);
14,304,645✔
448

449
    SMetaEntry me = {0};
14,304,645✔
450
    tDecoderInit(&dc, pVal, vLen);
14,304,645✔
451
    code = metaDecodeEntry(&dc, &me);
14,307,879✔
452
    TSDB_CHECK_CODE(code, lino, END);
14,304,522✔
453

454
    if (ctx->subType == TOPIC_SUB_TYPE__TABLE) {
14,304,522✔
455
      if (!((me.uid == ctx->suid && me.type == TSDB_SUPER_TABLE) ||
256,597✔
456
          (me.ctbEntry.suid == ctx->suid && (me.type == TSDB_CHILD_TABLE || me.type == TSDB_VIRTUAL_CHILD_TABLE)))) {
228,357✔
457
        tDecoderClear(&dc);
24,809✔
458
        continue;
24,809✔
459
      }
460
    }
461

462
    if ((ctx->subType == TOPIC_SUB_TYPE__DB && me.type == TSDB_SUPER_TABLE) ||
14,280,467✔
463
        (ctx->subType == TOPIC_SUB_TYPE__TABLE && me.uid == ctx->suid)) {
14,092,705✔
464
      code = saveSuperTableInfoForChildTable(&me, ctx->suidInfo);
215,610✔
465
      TSDB_CHECK_CODE(code, lino, END);
216,756✔
466
    }
467
    tDecoderClear(&dc);
14,282,711✔
468

469
  }
470

471
  for (int i = 0; i < taosArrayGetSize(ctx->idList); i++) {
14,394,472✔
472
    int64_t* uid = taosArrayGet(ctx->idList, i);
14,245,997✔
473
    TSDB_CHECK_NULL(uid, code, lino, END, terrno);
14,245,997✔
474
    SIdInfo* idData = (SIdInfo*)taosHashGet(ctx->idVersion, uid, sizeof(int64_t));
14,245,997✔
475
    TSDB_CHECK_NULL(idData, code, lino, END, terrno);
14,246,374✔
476

477
    idData->index = i;
14,246,374✔
478
    metaDebug("tmqsnap init idVersion uid:%" PRIi64 " version:%" PRIi64 " index:%d", *uid, idData->version, idData->index);
14,246,374✔
479
  }
480

481
END:
147,335✔
482
  tdbFree(pKey);
148,098✔
483
  tdbFree(pVal);
148,098✔
484
  tDecoderClear(&dc);
148,098✔
485

486
  if (ctx != NULL) {
148,098✔
487
    tdbTbcClose((TBC*)ctx->pCur);
148,098✔
488
    ctx->pCur = NULL;
148,098✔
489
  }
490
  metaULock(pVnode->pMeta);
148,098✔
491

492
  if(code != 0) {
148,098✔
493
    destroySnapContext(ctx);
×
494
    *ctxRet = NULL;
×
495
    metaError("tmqsnap build snap context failed line:%d since %s", lino, tstrerror(code));
×
496
  }
497
  return code;
148,098✔
498
}
499

500
void destroySnapContext(SSnapContext* ctx) {
677,567✔
501
  if (ctx == NULL) {
677,567✔
502
    return;
530,486✔
503
  }
504
  taosArrayDestroy(ctx->idList);
147,081✔
505
  taosHashCleanup(ctx->idVersion);
148,098✔
506
  taosHashCleanup(ctx->suidInfo);
148,098✔
507
  taosMemoryFree(ctx);
148,098✔
508
}
509

510
static int32_t buildNormalChildTableInfo(SVCreateTbReq* req, void** pBuf, int32_t* contLen) {
39,302✔
511
  int32_t            ret = 0;
39,302✔
512
  SVCreateTbBatchReq reqs = {0};
39,302✔
513

514
  reqs.pArray = taosArrayInit(1, sizeof(struct SVCreateTbReq));
39,302✔
515
  if (NULL == reqs.pArray) {
39,302✔
516
    ret = TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);
×
517
    goto end;
×
518
  }
519
  if (taosArrayPush(reqs.pArray, req) == NULL) {
78,604✔
520
    ret = TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);
×
521
    goto end;
×
522
  }
523
  reqs.nReqs = 1;
39,302✔
524

525
  tEncodeSize(tEncodeSVCreateTbBatchReq, &reqs, *contLen, ret);
39,302✔
526
  if (ret < 0) {
39,302✔
527
    ret = TAOS_GET_TERRNO(ret);
×
528
    goto end;
×
529
  }
530
  *contLen += sizeof(SMsgHead);
39,302✔
531
  *pBuf = taosMemoryMalloc(*contLen);
39,302✔
532
  if (NULL == *pBuf) {
39,302✔
533
    ret = TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);
×
534
    goto end;
×
535
  }
536
  SEncoder coder = {0};
39,302✔
537
  tEncoderInit(&coder, POINTER_SHIFT(*pBuf, sizeof(SMsgHead)), *contLen);
39,302✔
538
  ret = tEncodeSVCreateTbBatchReq(&coder, &reqs);
39,302✔
539
  tEncoderClear(&coder);
39,302✔
540

541
  if (ret < 0) {
39,302✔
542
    taosMemoryFreeClear(*pBuf);
×
543
    ret = TAOS_GET_TERRNO(ret);
×
544
    goto end;
×
545
  }
546

547
end:
39,302✔
548
  taosArrayDestroy(reqs.pArray);
39,302✔
549
  return ret;
39,302✔
550
}
551

552
static int32_t buildSuperTableInfo(SVCreateStbReq* req, void** pBuf, int32_t* contLen) {
16,079✔
553
  int32_t ret = 0;
16,079✔
554
  tEncodeSize(tEncodeSVCreateStbReq, req, *contLen, ret);
16,079✔
555
  if (ret < 0) {
16,079✔
556
    return TAOS_GET_TERRNO(ret);
×
557
  }
558

559
  *contLen += sizeof(SMsgHead);
16,079✔
560
  *pBuf = taosMemoryMalloc(*contLen);
16,079✔
561
  if (NULL == *pBuf) {
16,079✔
562
    return TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);
×
563
  }
564

565
  SEncoder encoder = {0};
16,079✔
566
  tEncoderInit(&encoder, POINTER_SHIFT(*pBuf, sizeof(SMsgHead)), *contLen);
16,079✔
567
  ret = tEncodeSVCreateStbReq(&encoder, req);
16,079✔
568
  tEncoderClear(&encoder);
16,079✔
569
  if (ret < 0) {
16,079✔
570
    taosMemoryFreeClear(*pBuf);
×
571
    return TAOS_GET_TERRNO(ret);
×
572
  }
573
  return 0;
16,079✔
574
}
575

576
int32_t setForSnapShot(SSnapContext* ctx, int64_t uid) {
915,640✔
577
  if (uid == 0) {
915,640✔
578
    ctx->index = 0;
22,433✔
579
    return 0;
22,433✔
580
  }
581

582
  SIdInfo* idInfo = (SIdInfo*)taosHashGet(ctx->idVersion, &uid, sizeof(tb_uid_t));
893,207✔
583
  if (idInfo == NULL) {
893,207✔
584
    return terrno;
×
585
  }
586

587
  ctx->index = idInfo->index;
893,207✔
588

589
  return 0;
893,207✔
590
}
591

592
void taosXSetTablePrimaryKey(SSnapContext* ctx, int64_t uid) {
906,456✔
593
  bool            ret = false;
906,456✔
594
  SSchemaWrapper* schema = metaGetTableSchema(ctx->pMeta, uid, -1, 1, NULL, 0, false);
906,456✔
595
  if (schema && schema->nCols >= 2 && schema->pSchema[1].flags & COL_IS_KEY) {
905,020✔
596
    ret = true;
1,551✔
597
  }
598
  tDeleteSchemaWrapper(schema);
599
  ctx->hasPrimaryKey = ret;
905,379✔
600
}
906,456✔
601

602
bool taosXGetTablePrimaryKey(SSnapContext* ctx) { return ctx->hasPrimaryKey; }
1,797,773✔
603

604
int32_t getTableInfoFromSnapshot(SSnapContext* ctx, void** pBuf, int32_t* contLen, int16_t* type, int64_t* uid) {
63,115✔
605
  int32_t ret = 0;
63,115✔
606
  int32_t lino = 0;
63,115✔
607
  void*   pKey = NULL;
63,115✔
608
  void*   pVal = NULL;
63,115✔
609
  int     vLen = 0, kLen = 0;
63,115✔
610
  SDecoder   dc = {0};
63,115✔
611
  SArray* tagName = NULL;
63,115✔
612
  SArray* pTagVals = NULL;
63,115✔
613

614
  metaRLock(ctx->pMeta);
63,115✔
615
  while (1) {
×
616
    if (ctx->index >= taosArrayGetSize(ctx->idList)) {
63,115✔
617
      metaDebug("tmqsnap get meta end");
7,734✔
618
      ctx->index = 0;
7,734✔
619
      ctx->queryMeta = 0;  // change to get data
7,734✔
620
      goto END;
7,734✔
621
    }
622

623
    int64_t* uidTmp = taosArrayGet(ctx->idList, ctx->index);
55,381✔
624
    TSDB_CHECK_NULL(uidTmp, ret, lino, END, terrno);
55,381✔
625
    ctx->index++;
55,381✔
626
    SIdInfo* idInfo = (SIdInfo*)taosHashGet(ctx->idVersion, uidTmp, sizeof(tb_uid_t));
55,381✔
627
    TSDB_CHECK_NULL(idInfo, ret, lino, END, terrno);
55,381✔
628

629
    *uid = *uidTmp;
55,381✔
630
    ret = MoveToPosition(ctx, idInfo->version, *uidTmp);
55,381✔
631
    if (ret == 0) {
55,381✔
632
      break;
55,381✔
633
    }
634
    metaDebug("tmqsnap get meta not exist uid:%" PRIi64 " version:%" PRIi64, *uid, idInfo->version);
×
635
  }
636

637
  ret = tdbTbcGet((TBC*)ctx->pCur, (const void**)&pKey, &kLen, (const void**)&pVal, &vLen);
55,381✔
638
  TSDB_CHECK_CONDITION(ret >= 0, ret, lino, END, TAOS_GET_TERRNO(ret));
55,381✔
639
  SMetaEntry me = {0};
55,381✔
640
  tDecoderInit(&dc, pVal, vLen);
55,381✔
641
  ret = metaDecodeEntry(&dc, &me);
55,381✔
642
  TSDB_CHECK_CONDITION(ret >= 0, ret, lino, END, TAOS_GET_TERRNO(ret));
55,381✔
643
  metaDebug("tmqsnap get meta uid:%" PRIi64 " name:%s index:%d", *uid, me.name, ctx->index - 1);
55,381✔
644

645
  if ((ctx->subType == TOPIC_SUB_TYPE__DB && me.type == TSDB_SUPER_TABLE) ||
55,381✔
646
      (ctx->subType == TOPIC_SUB_TYPE__TABLE && me.uid == ctx->suid)) {
56,454✔
647
    SVCreateStbReq req = {0};
16,079✔
648
    req.name = me.name;
16,079✔
649
    req.suid = me.uid;
16,079✔
650
    req.schemaRow = me.stbEntry.schemaRow;
16,079✔
651
    req.schemaTag = me.stbEntry.schemaTag;
16,079✔
652
    req.schemaRow.version = 1;
16,079✔
653
    req.schemaTag.version = 1;
16,079✔
654
    req.colCmpr = me.colCmpr;
16,079✔
655
    req.pExtSchemas = me.pExtSchemas;
16,079✔
656
    req.virtualStb = TABLE_IS_VIRTUAL(me.flags);
16,079✔
657

658
    ret = buildSuperTableInfo(&req, pBuf, contLen);
16,079✔
659
    *type = TDMT_VND_CREATE_STB;
16,079✔
660
  } else if ((ctx->subType == TOPIC_SUB_TYPE__DB && (me.type == TSDB_CHILD_TABLE || me.type == TSDB_VIRTUAL_CHILD_TABLE)) ||
39,302✔
661
             (ctx->subType == TOPIC_SUB_TYPE__TABLE && (me.type == TSDB_CHILD_TABLE || me.type == TSDB_VIRTUAL_CHILD_TABLE) && me.ctbEntry.suid == ctx->suid)) {
41,448✔
662
    STableInfoForChildTable* data =
663
        (STableInfoForChildTable*)taosHashGet(ctx->suidInfo, &me.ctbEntry.suid, sizeof(tb_uid_t));
32,736✔
664
    TSDB_CHECK_NULL(data, ret, lino, END, terrno);
32,736✔
665

666
    SVCreateTbReq req = {0};
32,736✔
667

668
    req.type = me.type;
32,736✔
669
    req.name = me.name;
32,736✔
670
    req.uid = me.uid;
32,736✔
671
    req.commentLen = -1;
32,736✔
672
    req.ctb.suid = me.ctbEntry.suid;
32,736✔
673
    req.ctb.tagNum = data->tagRow->nCols;
32,736✔
674
    req.ctb.stbName = data->tableName;
32,736✔
675

676
    tagName = taosArrayInit(req.ctb.tagNum, TSDB_COL_NAME_LEN);
32,736✔
677
    TSDB_CHECK_NULL(tagName, ret, lino, END, terrno);
32,736✔
678
    STag* p = (STag*)me.ctbEntry.pTags;
32,736✔
679
    if (tTagIsJson(p)) {
32,736✔
680
      if (p->nTag != 0) {
3,996✔
681
        SSchema* schema = &data->tagRow->pSchema[0];
1,998✔
682
        TSDB_CHECK_NULL(taosArrayPush(tagName, schema->name), ret, lino, END, terrno);
3,996✔
683
      }
684
    } else {
685
      ret = tTagToValArray((const STag*)p, &pTagVals);
28,740✔
686
      TSDB_CHECK_CODE(ret, lino, END);
28,740✔
687
      int16_t nCols = taosArrayGetSize(pTagVals);
28,740✔
688
      for (int j = 0; j < nCols; ++j) {
92,112✔
689
        STagVal* pTagVal = (STagVal*)taosArrayGet(pTagVals, j);
63,372✔
690
        for (int i = 0; pTagVal && i < data->tagRow->nCols; i++) {
247,956✔
691
          SSchema* schema = &data->tagRow->pSchema[i];
184,584✔
692
          if (schema->colId == pTagVal->cid) {
184,584✔
693
            TSDB_CHECK_NULL(taosArrayPush(tagName, schema->name), ret, lino, END, terrno);
126,744✔
694
          }
695
        }
696
      }
697
    }
698
    req.ctb.pTag = me.ctbEntry.pTags;
32,736✔
699
    req.ctb.tagName = tagName;
32,736✔
700
    req.colRef = me.colRef;
32,736✔
701
    if (me.type == TSDB_VIRTUAL_CHILD_TABLE) {
32,736✔
702
      SMetaEntry *pSuper = NULL;
2,775✔
703
      int32_t code = metaFetchEntryByUid(ctx->pMeta, me.ctbEntry.suid, &pSuper);
2,775✔
704
      if (code == 0) {
2,775✔
705
        for (int i = 0; i < req.colRef.nCols && i < pSuper->stbEntry.schemaRow.nCols; i++) {
13,209✔
706
          SColRef *p = &req.colRef.pColRef[i];
10,434✔
707
          if (p->hasRef) {
10,434✔
708
            SSchema *schema = &pSuper->stbEntry.schemaRow.pSchema[i];
5,217✔
709
            tstrncpy(p->colName, schema->name, TSDB_COL_NAME_LEN);
5,217✔
710
          }
711
        }
712
      }
713
      metaFetchEntryFree(&pSuper);
2,775✔
714
    }
715
    ret = buildNormalChildTableInfo(&req, pBuf, contLen);
32,736✔
716
    *type = TDMT_VND_CREATE_TABLE;
32,736✔
717
  } else if (ctx->subType == TOPIC_SUB_TYPE__DB && (me.type == TSDB_NORMAL_TABLE || me.type == TSDB_VIRTUAL_NORMAL_TABLE)) {
13,132✔
718
    SVCreateTbReq req = {0};
6,566✔
719
    req.type = me.type;
6,566✔
720
    req.name = me.name;
6,566✔
721
    req.uid = me.uid;
6,566✔
722
    req.commentLen = -1;
6,566✔
723
    req.ntb.schemaRow = me.ntbEntry.schemaRow;
6,566✔
724
    req.colCmpr = me.colCmpr;
6,566✔
725
    req.pExtSchemas = me.pExtSchemas;
6,566✔
726
    req.colRef = me.colRef;
6,566✔
727
    ret = buildNormalChildTableInfo(&req, pBuf, contLen);
6,566✔
728
    *type = TDMT_VND_CREATE_TABLE;
6,566✔
729
  } else {
730
    metaError("meta/snap: invalid topic sub type: %" PRId8 " get meta from snap failed.", ctx->subType);
×
731
    ret = TSDB_CODE_SDB_INVALID_TABLE_TYPE;
×
732
  }
733

734
END:
63,115✔
735
  tdbTbcClose((TBC*)ctx->pCur);
63,115✔
736
  ctx->pCur = NULL;
63,115✔
737
  taosArrayDestroy(pTagVals);
63,115✔
738
  taosArrayDestroy(tagName);
63,115✔
739
  tDecoderClear(&dc);
63,115✔
740
  metaULock(ctx->pMeta);
63,115✔
741

742
  if(ret != 0) {
63,115✔
743
    metaError("tmqsnap get table info from snapshot failed line:%d since %s", lino, tstrerror(ret));
×
744
  }
745
  return ret;
63,115✔
746
}
747

748
int32_t getMetaTableInfoFromSnapshot(SSnapContext* ctx, SMetaTableInfo* result) {
1,813,967✔
749
  void* pKey = NULL;
1,813,967✔
750
  void* pVal = NULL;
1,813,967✔
751
  int   vLen = 0;
1,813,967✔
752
  int   kLen = 0;
1,813,967✔
753
  int32_t code = 0;
1,813,967✔
754
  int32_t lino = 0;
1,813,967✔
755
  SDecoder   dc = {0};
1,813,967✔
756

757
  metaRLock(ctx->pMeta);
1,813,967✔
758
  while (1) {
29,719✔
759
    if (ctx->index >= taosArrayGetSize(ctx->idList)) {
1,843,286✔
760
      metaDebug("tmqsnap get uid info end");
14,664✔
761
      goto END;
14,664✔
762
    }
763
    int64_t* uidTmp = taosArrayGet(ctx->idList, ctx->index);
1,829,022✔
764
    TSDB_CHECK_NULL(uidTmp, code, lino, END, terrno);
1,829,022✔
765
    ctx->index++;
1,829,022✔
766
    SIdInfo* idInfo = (SIdInfo*)taosHashGet(ctx->idVersion, uidTmp, sizeof(tb_uid_t));
1,829,022✔
767
    TSDB_CHECK_NULL(idInfo, code, lino, END, terrno);
1,829,022✔
768

769
    if (MoveToPosition(ctx, idInfo->version, *uidTmp) != 0) {
1,829,022✔
770
      metaDebug("tmqsnap getMetaTableInfoFromSnapshot not exist uid:%" PRIi64 " version:%" PRIi64, *uidTmp,
×
771
                idInfo->version);
772
      continue;
×
773
    }
774
    code = tdbTbcGet((TBC*)ctx->pCur, (const void**)&pKey, &kLen, (const void**)&pVal, &vLen);
1,829,022✔
775
    TSDB_CHECK_CODE(code, lino, END);
1,829,022✔
776
    SMetaEntry me = {0};
1,829,022✔
777
    tDecoderInit(&dc, pVal, vLen);
1,829,022✔
778
    code = metaDecodeEntry(&dc, &me);
1,829,022✔
779
    TSDB_CHECK_CODE(code, lino, END);
1,826,468✔
780
    metaDebug("tmqsnap get uid info uid:%" PRIi64 " name:%s index:%d", me.uid, me.name, ctx->index - 1);
1,826,468✔
781

782
    if ((ctx->subType == TOPIC_SUB_TYPE__DB && me.type == TSDB_CHILD_TABLE) ||
1,826,468✔
783
        (ctx->subType == TOPIC_SUB_TYPE__TABLE && me.type == TSDB_CHILD_TABLE && me.ctbEntry.suid == ctx->suid)) {
1,830,299✔
784
      STableInfoForChildTable* data =
785
          (STableInfoForChildTable*)taosHashGet(ctx->suidInfo, &me.ctbEntry.suid, sizeof(tb_uid_t));
357,295✔
786
      TSDB_CHECK_NULL(data, code, lino, END, terrno);
358,731✔
787
      result->suid = me.ctbEntry.suid;
358,731✔
788
      result->schema = tCloneSSchemaWrapper(data->schemaRow);
717,462✔
789
      if (data->pExtSchemas != NULL) {
358,731✔
790
        result->pExtSchemas = taosMemoryMalloc(sizeof(SExtSchema) * data->schemaRow->nCols);
10,367✔
791
        TSDB_CHECK_NULL(result->pExtSchemas, code, lino, END, terrno);
10,367✔
792
        memcpy(result->pExtSchemas, data->pExtSchemas, sizeof(SExtSchema) * data->schemaRow->nCols);
10,367✔
793
      }
794
    } else if (ctx->subType == TOPIC_SUB_TYPE__DB && me.type == TSDB_NORMAL_TABLE) {
1,470,291✔
795
      result->suid = 0;
1,439,495✔
796
      result->schema = tCloneSSchemaWrapper(&me.ntbEntry.schemaRow);
1,440,572✔
797
      if (me.pExtSchemas != NULL) {
1,439,854✔
798
        result->pExtSchemas = taosMemoryMalloc(sizeof(SExtSchema) * me.ntbEntry.schemaRow.nCols);
×
799
        TSDB_CHECK_NULL(result->pExtSchemas, code, lino, END, terrno);
×
800
        memcpy(result->pExtSchemas, me.pExtSchemas, sizeof(SExtSchema) * me.ntbEntry.schemaRow.nCols);
×
801
      }
802
    } else {
803
      metaDebug("tmqsnap get uid continue");
29,719✔
804
      tDecoderClear(&dc);
29,719✔
805
      continue;
29,719✔
806
    }
807
    result->uid = me.uid;
1,798,185✔
808
    tstrncpy(result->tbName, me.name, TSDB_TABLE_NAME_LEN);
1,798,226✔
809
    TSDB_CHECK_NULL(result->schema, code, lino, END, TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY));
1,798,226✔
810
    break;
1,797,508✔
811
  }
812

813
END:
1,812,531✔
814
  tDecoderClear(&dc);
1,813,567✔
815
  tdbTbcClose((TBC*)ctx->pCur);
1,812,890✔
816
  ctx->pCur = NULL;
1,812,887✔
817
  metaULock(ctx->pMeta);
1,812,887✔
818

819
  if (code != 0) {
1,812,487✔
820
    metaError("tmqsnap get meta table info from snapshot failed line:%d since %s", lino, tstrerror(code));
×
821
  }
822
  return code;
1,812,487✔
823
}
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