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

taosdata / TDengine / #4829

30 Oct 2025 09:25AM UTC coverage: 49.734% (-11.3%) from 61.071%
#4829

push

travis-ci

web-flow
Merge pull request #33435 from taosdata/3.0

merge 3.0

123072 of 323930 branches covered (37.99%)

Branch coverage included in aggregate %.

7 of 25 new or added lines in 3 files covered. (28.0%)

35232 existing lines in 327 files now uncovered.

172062 of 269495 relevant lines covered (63.85%)

70709785.06 hits per line

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

75.58
/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
#include "vnd.h"
18
#include "tdbUtil.h"
19

20
static FORCE_INLINE void *metaMalloc(void *pPool, size_t size) {
665,707✔
21
  SVBufPool *pool = (SVBufPool *)pPool;
665,707✔
22
  SVnode    *pVnode = pool->pVnode;
665,707✔
23

24
  if (pVnode->inUse && pVnode->inUse->size > pVnode->inUse->node.size) {
666,034!
UNCOV
25
    return NULL;
×
26
  }
27

28
  return vnodeBufPoolMallocAligned((SVBufPool *)pPool, size);
666,034✔
29
}
30

31
static FORCE_INLINE void metaFree(void *pPool, void *p) { vnodeBufPoolFree((SVBufPool *)pPool, p); }
665,707✔
32

33
// begin a meta txn
34
int32_t metaBegin(SMeta *pMeta, int8_t heap) {
1,539,682✔
35
  int32_t code = 0;
1,539,682✔
36
  int32_t lino;
37

38
  void *(*xMalloc)(void *, size_t) = NULL;
1,539,682✔
39
  void (*xFree)(void *, void *) = NULL;
1,539,682✔
40
  void *xArg = NULL;
1,539,682✔
41

42
  // default heap to META_BEGIN_HEAP_NIL
43
  if (heap == META_BEGIN_HEAP_OS) {
1,539,682!
44
    xMalloc = tdbDefaultMalloc;
×
45
    xFree = tdbDefaultFree;
×
46
  } else if (heap == META_BEGIN_HEAP_BUFFERPOOL) {
1,539,682✔
47
    xMalloc = metaMalloc;
1,539,097✔
48
    xFree = metaFree;
1,539,097✔
49
    xArg = pMeta->pVnode->inUse;
1,539,097✔
50
  }
51

52
  code = tdbBegin(pMeta->pEnv, &pMeta->txn, xMalloc, xFree, xArg, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED);
1,539,682✔
53
  TSDB_CHECK_CODE(code, lino, _exit);
1,539,726!
54

55
  code = tdbCommit(pMeta->pEnv, pMeta->txn);
1,539,726✔
56
  TSDB_CHECK_CODE(code, lino, _exit);
1,538,782!
57

58
_exit:
1,538,782✔
59
  if (code) {
1,538,782!
60
    metaError("vgId:%d %s failed at %s:%d since %s", TD_VID(pMeta->pVnode), __func__, __FILE__, __LINE__,
×
61
              tstrerror(terrno));
62
  } else {
63
    metaDebug("vgId:%d %s success", TD_VID(pMeta->pVnode), __func__);
1,538,782✔
64
  }
65

66
  TAOS_RETURN(code);
1,538,782✔
67
}
68

69
// commit the meta txn
70
TXN *metaGetTxn(SMeta *pMeta) { return pMeta->txn; }
839,965✔
71
int  metaCommit(SMeta *pMeta, TXN *txn) { return tdbCommit(pMeta->pEnv, txn); }
850✔
72
int  metaFinishCommit(SMeta *pMeta, TXN *txn) { return tdbPostCommit(pMeta->pEnv, txn); }
840,203✔
73

74
int metaPrepareAsyncCommit(SMeta *pMeta) {
836,140✔
75
  // return tdbPrepareAsyncCommit(pMeta->pEnv, pMeta->txn);
76
  int     code = 0;
836,140✔
77
  int32_t lino;
78

79
  metaWLock(pMeta);
836,140✔
80
  int32_t ret = ttlMgrFlush(pMeta->pTtlMgr, pMeta->txn);
838,891✔
81
  if (ret < 0) {
837,668!
82
    metaError("vgId:%d, failed to flush ttl since %s", TD_VID(pMeta->pVnode), tstrerror(ret));
×
83
  }
84
  metaULock(pMeta);
837,668✔
85

86
  code = tdbCommit(pMeta->pEnv, pMeta->txn);
837,566✔
87
  TSDB_CHECK_CODE(code, lino, _exit);
838,923!
88
  pMeta->changed = false;
838,923✔
89

90
  pMeta->txn = NULL;
838,923✔
91

92
_exit:
838,104✔
93
  if (code) {
838,104!
94
    metaError("vgId:%d %s failed at %s:%d since %s", TD_VID(pMeta->pVnode), __func__, __FILE__, __LINE__,
×
95
              tstrerror(terrno));
96
  } else {
97
    metaDebug("vgId:%d %s success", TD_VID(pMeta->pVnode), __func__);
838,104✔
98
  }
99

100
  TAOS_RETURN(code);
838,104✔
101
}
102

103
// abort the meta txn
104
int metaAbort(SMeta *pMeta) {
699,972✔
105
  if (!pMeta->txn) {
699,972✔
106
    return 0;
306✔
107
  }
108

109
  metaCacheClear(pMeta);
700,050✔
110
  tdbAbort(pMeta->pEnv, pMeta->txn);
700,050✔
111
  pMeta->txn = NULL;
700,050✔
112
  return 0;
700,050✔
113
}
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