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

taosdata / TDengine / #3546

03 Dec 2024 10:02AM UTC coverage: 60.691% (-0.1%) from 60.839%
#3546

push

travis-ci

web-flow
Merge pull request #29015 from taosdata/fix/TS-5668

[TS-5668] fix(keeper): fix endpoint value too long for column/tag and eliminate warnings

120577 of 253823 branches covered (47.5%)

Branch coverage included in aggregate %.

201666 of 277134 relevant lines covered (72.77%)

18719900.08 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) {
13,543✔
19
  return vnodeBufPoolMallocAligned((SVBufPool *)pPool, size);
13,543✔
20
}
21
static FORCE_INLINE void metaFree(void *pPool, void *p) { vnodeBufPoolFree((SVBufPool *)pPool, p); }
13,543✔
22

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

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

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

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

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

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

56
  TAOS_RETURN(code);
45,707✔
57
}
58

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

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

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

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

80
  pMeta->txn = NULL;
31,721✔
81

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

90
  TAOS_RETURN(code);
31,722✔
91
}
92

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

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

© 2025 Coveralls, Inc