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

taosdata / TDengine / #3611

12 Feb 2025 09:54AM UTC coverage: 63.456% (+8.7%) from 54.713%
#3611

push

travis-ci

web-flow
Merge pull request #29745 from taosdata/fix/TD33664-3.0

fix: --version show information check for 3.0

141323 of 286257 branches covered (49.37%)

Branch coverage included in aggregate %.

220096 of 283298 relevant lines covered (77.69%)

19188455.82 hits per line

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

74.03
/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

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

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

28
  void *(*xMalloc)(void *, size_t) = NULL;
39,121✔
29
  void (*xFree)(void *, void *) = NULL;
39,121✔
30
  void *xArg = NULL;
39,121✔
31

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

42
  code = tdbBegin(pMeta->pEnv, &pMeta->txn, xMalloc, xFree, xArg, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED);
39,121✔
43
  TSDB_CHECK_CODE(code, lino, _exit);
39,152!
44

45
  code = tdbCommit(pMeta->pEnv, pMeta->txn);
39,152✔
46
  TSDB_CHECK_CODE(code, lino, _exit);
39,153!
47

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

56
  TAOS_RETURN(code);
39,153✔
57
}
58

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

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

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

76
  code = tdbCommit(pMeta->pEnv, pMeta->txn);
27,428✔
77
  TSDB_CHECK_CODE(code, lino, _exit);
27,423!
78
  pMeta->changed = false;
27,423✔
79

80
  pMeta->txn = NULL;
27,423✔
81

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

90
  TAOS_RETURN(code);
27,424✔
91
}
92

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

99
  tdbAbort(pMeta->pEnv, pMeta->txn);
11,658✔
100
  pMeta->txn = NULL;
11,658✔
101
  return 0;
11,658✔
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