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

taosdata / TDengine / #3621

22 Feb 2025 11:44AM UTC coverage: 2.037% (-61.5%) from 63.573%
#3621

push

travis-ci

web-flow
Merge pull request #29874 from taosdata/merge/mainto3.0

merge: from main to 3.0 branch

4357 of 287032 branches covered (1.52%)

Branch coverage included in aggregate %.

0 of 174 new or added lines in 18 files covered. (0.0%)

213359 existing lines in 469 files now uncovered.

7260 of 283369 relevant lines covered (2.56%)

23737.72 hits per line

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

0.0
/source/dnode/vnode/src/meta/metaCommit.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 "meta.h"
17

UNCOV
18
static FORCE_INLINE void *metaMalloc(void *pPool, size_t size) {
×
UNCOV
19
  return vnodeBufPoolMallocAligned((SVBufPool *)pPool, size);
×
20
}
UNCOV
21
static FORCE_INLINE void metaFree(void *pPool, void *p) { vnodeBufPoolFree((SVBufPool *)pPool, p); }
×
22

23
// begin a meta txn
UNCOV
24
int32_t metaBegin(SMeta *pMeta, int8_t heap) {
×
UNCOV
25
  int32_t code = 0;
×
26
  int32_t lino;
27

UNCOV
28
  void *(*xMalloc)(void *, size_t) = NULL;
×
UNCOV
29
  void (*xFree)(void *, void *) = NULL;
×
UNCOV
30
  void *xArg = NULL;
×
31

32
  // default heap to META_BEGIN_HEAP_NIL
UNCOV
33
  if (heap == META_BEGIN_HEAP_OS) {
×
34
    xMalloc = tdbDefaultMalloc;
×
35
    xFree = tdbDefaultFree;
×
UNCOV
36
  } else if (heap == META_BEGIN_HEAP_BUFFERPOOL) {
×
UNCOV
37
    xMalloc = metaMalloc;
×
UNCOV
38
    xFree = metaFree;
×
UNCOV
39
    xArg = pMeta->pVnode->inUse;
×
40
  }
41

UNCOV
42
  code = tdbBegin(pMeta->pEnv, &pMeta->txn, xMalloc, xFree, xArg, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED);
×
UNCOV
43
  TSDB_CHECK_CODE(code, lino, _exit);
×
44

UNCOV
45
  code = tdbCommit(pMeta->pEnv, pMeta->txn);
×
UNCOV
46
  TSDB_CHECK_CODE(code, lino, _exit);
×
47

UNCOV
48
_exit:
×
UNCOV
49
  if (code) {
×
50
    metaError("vgId:%d %s failed at %s:%d since %s", TD_VID(pMeta->pVnode), __func__, __FILE__, __LINE__,
×
51
              tstrerror(terrno));
52
  } else {
UNCOV
53
    metaDebug("vgId:%d %s success", TD_VID(pMeta->pVnode), __func__);
×
54
  }
55

UNCOV
56
  TAOS_RETURN(code);
×
57
}
58

59
// commit the meta txn
UNCOV
60
TXN *metaGetTxn(SMeta *pMeta) { return pMeta->txn; }
×
UNCOV
61
int  metaCommit(SMeta *pMeta, TXN *txn) { return tdbCommit(pMeta->pEnv, txn); }
×
UNCOV
62
int  metaFinishCommit(SMeta *pMeta, TXN *txn) { return tdbPostCommit(pMeta->pEnv, txn); }
×
63

UNCOV
64
int metaPrepareAsyncCommit(SMeta *pMeta) {
×
65
  // return tdbPrepareAsyncCommit(pMeta->pEnv, pMeta->txn);
UNCOV
66
  int     code = 0;
×
67
  int32_t lino;
68

UNCOV
69
  metaWLock(pMeta);
×
UNCOV
70
  int32_t ret = ttlMgrFlush(pMeta->pTtlMgr, pMeta->txn);
×
UNCOV
71
  if (ret < 0) {
×
72
    metaError("vgId:%d, failed to flush ttl since %s", TD_VID(pMeta->pVnode), tstrerror(ret));
×
73
  }
UNCOV
74
  metaULock(pMeta);
×
75

UNCOV
76
  code = tdbCommit(pMeta->pEnv, pMeta->txn);
×
UNCOV
77
  TSDB_CHECK_CODE(code, lino, _exit);
×
UNCOV
78
  pMeta->changed = false;
×
79

UNCOV
80
  pMeta->txn = NULL;
×
81

UNCOV
82
_exit:
×
UNCOV
83
  if (code) {
×
84
    metaError("vgId:%d %s failed at %s:%d since %s", TD_VID(pMeta->pVnode), __func__, __FILE__, __LINE__,
×
85
              tstrerror(terrno));
86
  } else {
UNCOV
87
    metaDebug("vgId:%d %s success", TD_VID(pMeta->pVnode), __func__);
×
88
  }
89

UNCOV
90
  TAOS_RETURN(code);
×
91
}
92

93
// abort the meta txn
UNCOV
94
int metaAbort(SMeta *pMeta) {
×
UNCOV
95
  if (!pMeta->txn) {
×
96
    return 0;
×
97
  }
98

UNCOV
99
  tdbAbort(pMeta->pEnv, pMeta->txn);
×
UNCOV
100
  pMeta->txn = NULL;
×
UNCOV
101
  return 0;
×
102
}
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