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

taosdata / TDengine / #3565

25 Dec 2024 05:34AM UTC coverage: 51.098% (-11.1%) from 62.21%
#3565

push

travis-ci

web-flow
Merge pull request #29316 from taosdata/enh/3.0/TD-33266

enh(ut):Add wal & config UT.

111558 of 284773 branches covered (39.17%)

Branch coverage included in aggregate %.

1 of 2 new or added lines in 2 files covered. (50.0%)

39015 existing lines in 102 files now uncovered.

177882 of 281666 relevant lines covered (63.15%)

15090998.35 hits per line

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

64.94
/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
24
int32_t metaBegin(SMeta *pMeta, int8_t heap) {
20✔
25
  int32_t code = 0;
20✔
26
  int32_t lino;
27

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

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

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

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

48
_exit:
20✔
49
  if (code) {
20!
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__);
20!
54
  }
55

56
  TAOS_RETURN(code);
20✔
57
}
58

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

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

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

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

80
  pMeta->txn = NULL;
2✔
81

82
_exit:
2✔
83
  if (code) {
2!
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__);
2!
88
  }
89

90
  TAOS_RETURN(code);
2✔
91
}
92

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

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