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

taosdata / TDengine / #4513

17 Jul 2025 02:02AM UTC coverage: 31.359% (-31.1%) from 62.446%
#4513

push

travis-ci

web-flow
Merge pull request #31914 from taosdata/fix/3.0/compare-ans-failed

fix:Convert line endings from LF to CRLF for ans file

68541 of 301034 branches covered (22.77%)

Branch coverage included in aggregate %.

117356 of 291771 relevant lines covered (40.22%)

602262.98 hits per line

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

61.63
/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) {
×
21
  SVBufPool *pool = (SVBufPool *)pPool;
×
22
  SVnode    *pVnode = pool->pVnode;
×
23

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

28
  return vnodeBufPoolMallocAligned((SVBufPool *)pPool, size);
×
29
}
30

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

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

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

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

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

55
  code = tdbCommit(pMeta->pEnv, pMeta->txn);
77✔
56
  TSDB_CHECK_CODE(code, lino, _exit);
77!
57

58
_exit:
77✔
59
  if (code) {
77!
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__);
77✔
64
  }
65

66
  TAOS_RETURN(code);
77✔
67
}
68

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

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

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

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

90
  pMeta->txn = NULL;
24✔
91

92
_exit:
24✔
93
  if (code) {
24!
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__);
24✔
98
  }
99

100
  TAOS_RETURN(code);
24✔
101
}
102

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

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