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

taosdata / TDengine / #3523

06 Nov 2024 02:29AM UTC coverage: 55.861% (-2.4%) from 58.216%
#3523

push

travis-ci

web-flow
Merge pull request #28551 from taosdata/feat/TS-5215-2

test(blob): testing & fixes for blob

106075 of 245834 branches covered (43.15%)

Branch coverage included in aggregate %.

0 of 15 new or added lines in 2 files covered. (0.0%)

17003 existing lines in 254 files now uncovered.

181910 of 269703 relevant lines covered (67.45%)

1527639.59 hits per line

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

68.83
/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) {
7,146✔
25
  int32_t code = 0;
7,146✔
26
  int32_t lino;
27

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

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

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

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

48
_exit:
7,163✔
49
  if (code) {
7,163!
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__);
7,163✔
54
  }
55
  return 0;
7,163✔
56
}
57

58
// commit the meta txn
59
TXN *metaGetTxn(SMeta *pMeta) { return pMeta->txn; }
1,756✔
60
int  metaCommit(SMeta *pMeta, TXN *txn) { return tdbCommit(pMeta->pEnv, txn); }
1✔
61
int  metaFinishCommit(SMeta *pMeta, TXN *txn) { return tdbPostCommit(pMeta->pEnv, txn); }
1,757✔
62

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

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

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

79
  pMeta->txn = NULL;
1,756✔
80

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

91
// abort the meta txn
92
int metaAbort(SMeta *pMeta) {
5,406✔
93
  if (!pMeta->txn) {
5,406!
94
    return 0;
×
95
  }
96

97
  tdbAbort(pMeta->pEnv, pMeta->txn);
5,406✔
98
  pMeta->txn = NULL;
5,406✔
99
  return 0;
5,406✔
100
}
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