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

taosdata / TDengine / #4688

26 Aug 2025 02:05PM UTC coverage: 56.997% (-0.9%) from 57.894%
#4688

push

travis-ci

web-flow
fix: modify the prompt language of the taos-shell (#32758)

* fix: modify prompt language

* fix: add shell test case

* fix: modify comments

* fix: modify test case for TDengine TSDB

130660 of 292423 branches covered (44.68%)

Branch coverage included in aggregate %.

16 of 17 new or added lines in 2 files covered. (94.12%)

9459 existing lines in 157 files now uncovered.

198294 of 284715 relevant lines covered (69.65%)

4532552.29 hits per line

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

1.82
/source/dnode/vnode/src/vnd/vnodeRetention.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 "vnd.h"
17

18
extern int32_t tsdbAsyncRetention(STsdb *tsdb, int64_t now);
19
extern int32_t tsdbListSsMigrateFileSets(STsdb* tsdb, SArray* fidArr);
20
extern int32_t tsdbAsyncSsMigrateFileSet(STsdb *tsdb, SSsMigrateFileSetReq *pReq);
21
extern int32_t tsdbQuerySsMigrateProgress(STsdb *tsdb, SSsMigrateProgress *pProgress);
22
extern int32_t tsdbUpdateSsMigrateProgress(STsdb* tsdb, SSsMigrateProgress* pProgress);
23

24

25

26
int32_t vnodeAsyncRetention(SVnode *pVnode, int64_t now) {
42✔
27
  // async retention
28
  return tsdbAsyncRetention(pVnode->pTsdb, now);
42✔
29
}
30

31

32

33
int32_t vnodeQuerySsMigrateProgress(SVnode *pVnode, SRpcMsg *pMsg) {
×
34
#ifdef USE_SHARED_STORAGE
35

36
  int32_t code = 0;
×
37

UNCOV
38
  SSsMigrateProgress req = {0};
×
39

40
  int32_t                  rspSize = 0;
×
UNCOV
41
  SRpcMsg                  rspMsg = {0};
×
42
  void                    *pRsp = NULL;
×
43

44
  char* buf = (char*)pMsg->pCont + sizeof(SMsgHead);
×
45
  code = tDeserializeSSsMigrateProgress(buf, pMsg->contLen - sizeof(SMsgHead), &req);
×
46
  if (code) {
×
47
    code = TSDB_CODE_INVALID_MSG;
×
UNCOV
48
    goto _exit;
×
49
  }
50

51
  vDebug("vgId:%d, ssMigrateId:%d, processing query ss migrate progress request", req.vgId, req.ssMigrateId);
×
52
  SSsMigrateProgress rsp = req;
×
53
  code = tsdbQuerySsMigrateProgress(pVnode->pTsdb, &rsp);
×
54
  if (code) {
×
UNCOV
55
    goto _exit;
×
56
  }
57

58
  rspSize = tSerializeSSsMigrateProgress(NULL, 0, &rsp);
×
UNCOV
59
  pRsp = rpcMallocCont(rspSize);
×
60
  if (pRsp == NULL) {
×
61
    code = TSDB_CODE_OUT_OF_MEMORY;
×
62
    vError("vgId:%d, ssMigrateId:%d, failed to allocate response buffer since %s", req.vgId, req.ssMigrateId, tstrerror(code));
×
63
    rspSize = 0;
×
64
    goto _exit;
×
65
  }
UNCOV
66
  TAOS_UNUSED(tSerializeSSsMigrateProgress(pRsp, rspSize, &rsp));
×
67

68
_exit:
×
UNCOV
69
  rspMsg.info = pMsg->info;
×
UNCOV
70
  rspMsg.pCont = pRsp;
×
71
  rspMsg.contLen = rspSize;
×
72
  rspMsg.code = code;
×
UNCOV
73
  rspMsg.msgType = TDMT_VND_QUERY_SSMIGRATE_PROGRESS_RSP;
×
74

UNCOV
75
  tmsgSendRsp(&rspMsg);
×
UNCOV
76
  return 0;
×
77

78
#else
79
  return TSDB_CODE_OPS_NOT_SUPPORT;
80
#endif
81
}
82

83

84

UNCOV
85
int32_t vnodeListSsMigrateFileSets(SVnode *pVnode, SRpcMsg *pMsg) {
×
86
#ifdef USE_SHARED_STORAGE
87

UNCOV
88
  int32_t code = 0, vgId = TD_VID(pVnode);
×
UNCOV
89
  SListSsMigrateFileSetsReq req = {0};
×
UNCOV
90
  SArray* fidArr = NULL;
×
91

UNCOV
92
  int32_t                  rspSize = 0;
×
UNCOV
93
  SRpcMsg                  rspMsg = {0};
×
UNCOV
94
  void                    *pRsp = NULL;
×
UNCOV
95
  SListSsMigrateFileSetsRsp rsp = {0};
×
96

97
  // deserialize request
UNCOV
98
  char* buf = (char*)pMsg->pCont + sizeof(SMsgHead);
×
UNCOV
99
  code = tDeserializeSListSsMigrateFileSetsReq(buf, pMsg->contLen - sizeof(SMsgHead), &req);
×
UNCOV
100
  if (code) {
×
UNCOV
101
    vError("vgId:%d, failed to deserialize ss migrate query file sets request since %s", vgId, tstrerror(code));
×
UNCOV
102
    goto _exit;
×
103
  }
104

UNCOV
105
  fidArr = taosArrayInit(10, sizeof(int32_t));
×
UNCOV
106
  if (fidArr == NULL) {
×
UNCOV
107
    code = terrno;
×
UNCOV
108
    vError("vgId:%d, failed to initialize file set id array since %s", TD_VID(pVnode), tstrerror(code));
×
UNCOV
109
    goto _exit;
×
110
  }
111

UNCOV
112
  code = tsdbListSsMigrateFileSets(pVnode->pTsdb, fidArr);
×
UNCOV
113
  if (code != TSDB_CODE_SUCCESS) {
×
UNCOV
114
    vError("vgId:%d, %s failed since %s", TD_VID(pVnode), __func__, tstrerror(code));
×
UNCOV
115
    goto _exit;
×
116
  }
117

UNCOV
118
  rsp.ssMigrateId = req.ssMigrateId;
×
UNCOV
119
  rsp.vgId = vgId;
×
UNCOV
120
  rsp.pFileSets = fidArr;
×
UNCOV
121
  rspSize = tSerializeSListSsMigrateFileSetsRsp(NULL, 0, &rsp);
×
UNCOV
122
  pRsp = rpcMallocCont(rspSize);
×
UNCOV
123
  if (pRsp == NULL) {
×
UNCOV
124
    code = TSDB_CODE_OUT_OF_MEMORY;
×
UNCOV
125
    vError("vgId:%d, failed to allocate response buffer of size %d since %s", vgId, rspSize, tstrerror(code));
×
UNCOV
126
    rspSize = 0;
×
UNCOV
127
    goto _exit;
×
128
  }
UNCOV
129
  TAOS_UNUSED(tSerializeSListSsMigrateFileSetsRsp(pRsp, rspSize, &rsp));
×
130

UNCOV
131
_exit:
×
UNCOV
132
  taosArrayDestroy(fidArr);
×
UNCOV
133
  rspMsg.info = pMsg->info;
×
UNCOV
134
  rspMsg.pCont = pRsp;
×
UNCOV
135
  rspMsg.contLen = rspSize;
×
UNCOV
136
  rspMsg.code = code;
×
UNCOV
137
  rspMsg.msgType = TDMT_VND_LIST_SSMIGRATE_FILESETS_RSP;
×
138

UNCOV
139
  tmsgSendRsp(&rspMsg);
×
UNCOV
140
  return 0;
×
141

142
#else
143
  return TSDB_CODE_OPS_NOT_SUPPORT;
144
#endif
145
}
146

147

148

UNCOV
149
int32_t vnodeAsyncSsMigrateFileSet(SVnode *pVnode, SSsMigrateFileSetReq *pReq) {
×
150
  // async migration
151
#ifdef USE_SHARED_STORAGE
UNCOV
152
  if (tsSsEnabled) {
×
UNCOV
153
    return tsdbAsyncSsMigrateFileSet(pVnode->pTsdb, pReq);
×
154
  }
155
#endif
UNCOV
156
  return TSDB_CODE_OPS_NOT_SUPPORT;
×
157
}
158

159

160

UNCOV
161
int32_t vnodeFollowerSsMigrate(SVnode *pVnode, SSsMigrateProgress *pReq) {
×
162
#ifdef USE_SHARED_STORAGE
UNCOV
163
  return tsdbUpdateSsMigrateProgress(pVnode->pTsdb, pReq);
×
164
#else
165
  return TSDB_CODE_OPS_NOT_SUPPORT;
166
#endif
167
}
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