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

taosdata / TDengine / #4747

21 Sep 2025 11:53PM UTC coverage: 58.002% (-1.1%) from 59.065%
#4747

push

travis-ci

web-flow
fix: refine python taos error log matching in checkAsan.sh (#33029)

* fix: refine python taos error log matching in checkAsan.sh

* fix: improve python taos error log matching in checkAsan.sh

133398 of 293157 branches covered (45.5%)

Branch coverage included in aggregate %.

201778 of 284713 relevant lines covered (70.87%)

5539418.83 hits per line

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

81.0
/source/libs/sync/src/syncRaftEntry.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
#define _DEFAULT_SOURCE
17
#include "syncRaftEntry.h"
18
#include "syncUtil.h"
19
#include "tref.h"
20

21
SSyncRaftEntry* syncEntryBuild(int32_t dataLen) {
2,138,303✔
22
  int32_t         bytes = sizeof(SSyncRaftEntry) + dataLen;
2,138,303✔
23
  SSyncRaftEntry* pEntry = taosMemoryCalloc(1, bytes);
2,138,303!
24
  if (pEntry == NULL) {
2,138,305!
25
    terrno = TSDB_CODE_OUT_OF_MEMORY;
×
26
    return NULL;
×
27
  }
28

29
  pEntry->bytes = bytes;
2,138,305✔
30
  pEntry->dataLen = dataLen;
2,138,305✔
31
  pEntry->rid = -1;
2,138,305✔
32

33
  return pEntry;
2,138,305✔
34
}
35

36
SSyncRaftEntry* syncEntryBuildFromClientRequest(const SyncClientRequest* pMsg, SyncTerm term, SyncIndex index, const STraceId *traceId) {
188,687✔
37
  SSyncRaftEntry* pEntry = syncEntryBuild(pMsg->dataLen);
188,687✔
38
  if (pEntry == NULL) return NULL;
188,687!
39

40
  pEntry->msgType = pMsg->msgType;
188,687✔
41
  pEntry->originalRpcType = pMsg->originalRpcType;
188,687✔
42
  pEntry->originRpcTraceId = *traceId;
188,687✔
43
  pEntry->seqNum = pMsg->seqNum;
188,687✔
44
  pEntry->isWeak = pMsg->isWeak;
188,687✔
45
  pEntry->term = term;
188,687✔
46
  pEntry->index = index;
188,687✔
47
  memcpy(pEntry->data, pMsg->data, pMsg->dataLen);
188,687✔
48

49
  return pEntry;
188,687✔
50
}
51

52
SSyncRaftEntry* syncEntryBuildFromRpcMsg(const SRpcMsg* pMsg, SyncTerm term, SyncIndex index) {
1,750,366✔
53
  SSyncRaftEntry* pEntry = syncEntryBuild(pMsg->contLen);
1,750,366✔
54
  if (pEntry == NULL) return NULL;
1,750,359!
55

56
  pEntry->msgType = TDMT_SYNC_CLIENT_REQUEST;
1,750,359✔
57
  pEntry->originalRpcType = pMsg->msgType;
1,750,359✔
58
  pEntry->originRpcTraceId = pMsg->info.traceId;
1,750,359✔
59
  pEntry->seqNum = 0;
1,750,359✔
60
  pEntry->isWeak = 0;
1,750,359✔
61
  pEntry->term = term;
1,750,359✔
62
  pEntry->index = index;
1,750,359✔
63
  memcpy(pEntry->data, pMsg->pCont, pMsg->contLen);
1,750,359✔
64

65
  return pEntry;
1,750,359✔
66
}
67

68
SSyncRaftEntry* syncEntryBuildFromAppendEntries(const SyncAppendEntries* pMsg) {
240,712✔
69
  SSyncRaftEntry* pEntry = taosMemoryMalloc(pMsg->dataLen);
240,712!
70
  if (pEntry == NULL) {
240,711!
71
    terrno = TSDB_CODE_OUT_OF_MEMORY;
×
72
    return NULL;
×
73
  }
74
  memcpy(pEntry, pMsg->data, pMsg->dataLen);
240,711✔
75
  if (pEntry->bytes != pMsg->dataLen) {
240,711!
76
    terrno = TSDB_CODE_SYN_INTERNAL_ERROR;
×
77
    return NULL;
×
78
  }
79
  return pEntry;
240,711✔
80
}
81

82
SSyncRaftEntry* syncEntryBuildNoop(SyncTerm term, SyncIndex index, int32_t vgId) {
26,207✔
83
  SSyncRaftEntry* pEntry = syncEntryBuild(sizeof(SMsgHead));
26,207✔
84
  if (pEntry == NULL) return NULL;
26,207!
85

86
  pEntry->msgType = TDMT_SYNC_CLIENT_REQUEST;
26,207✔
87
  pEntry->originalRpcType = TDMT_SYNC_NOOP;
26,207✔
88
  pEntry->seqNum = 0;
26,207✔
89
  pEntry->isWeak = 0;
26,207✔
90
  pEntry->term = term;
26,207✔
91
  pEntry->index = index;
26,207✔
92

93
  SMsgHead* pHead = (SMsgHead*)pEntry->data;
26,207✔
94
  pHead->vgId = vgId;
26,207✔
95
  pHead->contLen = sizeof(SMsgHead);
26,207✔
96

97
  return pEntry;
26,207✔
98
}
99

100
void syncEntryDestroy(SSyncRaftEntry* pEntry) {
5,019,868✔
101
  if (pEntry != NULL) {
5,019,868✔
102
    sTrace("free entry:%p", pEntry);
2,372,075✔
103
    taosMemoryFree(pEntry);
2,372,075!
104
  }
105
}
5,018,463✔
106

107
int32_t syncEntry2OriginalRpc(const SSyncRaftEntry* pEntry, SRpcMsg* pRpcMsg) {
570,332✔
108
  pRpcMsg->msgType = pEntry->originalRpcType;
570,332✔
109
  pRpcMsg->contLen = (int32_t)(pEntry->dataLen);
570,332✔
110
  pRpcMsg->pCont = rpcMallocCont(pRpcMsg->contLen);
570,332✔
111
  if (pRpcMsg->pCont == NULL) {
570,328!
112
    return terrno;
×
113
  }
114
  memcpy(pRpcMsg->pCont, pEntry->data, pRpcMsg->contLen);
570,332✔
115

116
  return 0;
570,332✔
117
}
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