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

taosdata / TDengine / #3562

20 Dec 2024 09:57AM UTC coverage: 26.655% (-32.2%) from 58.812%
#3562

push

travis-ci

web-flow
Merge pull request #29229 from taosdata/enh/TS-5749-3.0

enh: seperate tsdb async tasks to different thread pools

21498 of 109421 branches covered (19.65%)

Branch coverage included in aggregate %.

66 of 96 new or added lines in 7 files covered. (68.75%)

39441 existing lines in 157 files now uncovered.

35007 of 102566 relevant lines covered (34.13%)

53922.97 hits per line

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

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

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

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

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

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

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

56
  TAOS_RETURN(code);
566✔
57
}
58

59
// commit the meta txn
60
TXN *metaGetTxn(SMeta *pMeta) { return pMeta->txn; }
13✔
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); }
13✔
63

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

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

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

80
  pMeta->txn = NULL;
13✔
81

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

90
  TAOS_RETURN(code);
13✔
91
}
92

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

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