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

taosdata / TDengine / #4720

08 Sep 2025 08:43AM UTC coverage: 58.139% (-0.6%) from 58.762%
#4720

push

travis-ci

web-flow
Merge pull request #32881 from taosdata/enh/add-new-windows-ci

fix(ci): update workflow reference to use new Windows CI YAML

133181 of 292179 branches covered (45.58%)

Branch coverage included in aggregate %.

201691 of 283811 relevant lines covered (71.07%)

5442780.71 hits per line

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

61.79
/source/dnode/mnode/impl/src/mndCluster.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 "audit.h"
18
#include "mndCluster.h"
19
#include "mndGrant.h"
20
#include "mndPrivilege.h"
21
#include "mndShow.h"
22
#include "mndTrans.h"
23

24
#define CLUSTER_VER_NUMBE    1
25
#define CLUSTER_RESERVE_SIZE 60
26
int64_t tsExpireTime = 0;
27

28
static SSdbRaw *mndClusterActionEncode(SClusterObj *pCluster);
29
static SSdbRow *mndClusterActionDecode(SSdbRaw *pRaw);
30
static int32_t  mndClusterActionInsert(SSdb *pSdb, SClusterObj *pCluster);
31
static int32_t  mndClusterActionDelete(SSdb *pSdb, SClusterObj *pCluster);
32
static int32_t  mndClusterActionUpdate(SSdb *pSdb, SClusterObj *pOldCluster, SClusterObj *pNewCluster);
33
static int32_t  mndCreateDefaultCluster(SMnode *pMnode);
34
static int32_t  mndRetrieveClusters(SRpcMsg *pMsg, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows);
35
static void     mndCancelGetNextCluster(SMnode *pMnode, void *pIter);
36
static int32_t  mndProcessUptimeTimer(SRpcMsg *pReq);
37
static int32_t  mndProcessConfigClusterReq(SRpcMsg *pReq);
38
static int32_t  mndProcessConfigClusterRsp(SRpcMsg *pReq);
39

40
int32_t mndInitCluster(SMnode *pMnode) {
1,929✔
41
  SSdbTable table = {
1,929✔
42
      .sdbType = SDB_CLUSTER,
43
      .keyType = SDB_KEY_INT64,
44
      .deployFp = (SdbDeployFp)mndCreateDefaultCluster,
45
      .encodeFp = (SdbEncodeFp)mndClusterActionEncode,
46
      .decodeFp = (SdbDecodeFp)mndClusterActionDecode,
47
      .insertFp = (SdbInsertFp)mndClusterActionInsert,
48
      .updateFp = (SdbUpdateFp)mndClusterActionUpdate,
49
      .deleteFp = (SdbDeleteFp)mndClusterActionDelete,
50
  };
51

52
  mndSetMsgHandle(pMnode, TDMT_MND_UPTIME_TIMER, mndProcessUptimeTimer);
1,929✔
53
  mndSetMsgHandle(pMnode, TDMT_MND_CONFIG_CLUSTER, mndProcessConfigClusterReq);
1,929✔
54
  mndSetMsgHandle(pMnode, TDMT_MND_CONFIG_CLUSTER_RSP, mndProcessConfigClusterRsp);
1,929✔
55
  mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_CLUSTER, mndRetrieveClusters);
1,929✔
56
  mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_CLUSTER, mndCancelGetNextCluster);
1,929✔
57

58
  return sdbSetTable(pMnode->pSdb, table);
1,929✔
59
}
60

61
void mndCleanupCluster(SMnode *pMnode) {}
1,929✔
62

63
int32_t mndGetClusterName(SMnode *pMnode, char *clusterName, int32_t len) {
2✔
64
  int32_t code = 0;
2✔
65
  SSdb   *pSdb = pMnode->pSdb;
2✔
66

67
  SClusterObj *pCluster = sdbAcquire(pSdb, SDB_CLUSTER, &pMnode->clusterId);
2✔
68
  if (pCluster == NULL) {
2!
69
    code = terrno;
×
70
    TAOS_RETURN(code);
×
71
  }
72

73
  tstrncpy(clusterName, pCluster->name, len);
2✔
74
  sdbRelease(pSdb, pCluster);
2✔
75
  return 0;
2✔
76
}
77

78
static SClusterObj *mndAcquireCluster(SMnode *pMnode, void **ppIter) {
114,698✔
79
  SSdb *pSdb = pMnode->pSdb;
114,698✔
80
  void *pIter = NULL;
114,698✔
81

82
  while (1) {
83
    SClusterObj *pCluster = NULL;
114,698✔
84
    pIter = sdbFetch(pSdb, SDB_CLUSTER, pIter, (void **)&pCluster);
114,698✔
85
    if (pIter == NULL) break;
114,698✔
86

87
    *ppIter = pIter;
110,618✔
88
    return pCluster;
110,618✔
89
  }
90

91
  return NULL;
4,080✔
92
}
93

94
static void mndReleaseCluster(SMnode *pMnode, SClusterObj *pCluster, void *pIter) {
110,618✔
95
  SSdb *pSdb = pMnode->pSdb;
110,618✔
96
  sdbCancelFetch(pSdb, pIter);
110,618✔
97
  sdbRelease(pSdb, pCluster);
110,618✔
98
}
110,618✔
99

100
int64_t mndGetClusterId(SMnode *pMnode) {
104,145✔
101
  int64_t      clusterId = 0;
104,145✔
102
  void        *pIter = NULL;
104,145✔
103
  SClusterObj *pCluster = mndAcquireCluster(pMnode, &pIter);
104,145✔
104
  if (pCluster != NULL) {
104,145✔
105
    clusterId = pCluster->id;
100,155✔
106
    mndReleaseCluster(pMnode, pCluster, pIter);
100,155✔
107
  }
108

109
  return clusterId;
104,145✔
110
}
111

112
int64_t mndGetClusterCreateTime(SMnode *pMnode) {
6,301✔
113
  int64_t      createTime = 0;
6,301✔
114
  void        *pIter = NULL;
6,301✔
115
  SClusterObj *pCluster = mndAcquireCluster(pMnode, &pIter);
6,301✔
116
  if (pCluster != NULL) {
6,301✔
117
    createTime = pCluster->createdTime;
6,211✔
118
    mndReleaseCluster(pMnode, pCluster, pIter);
6,211✔
119
  }
120

121
  return createTime;
6,301✔
122
}
123

124
static int32_t mndGetClusterUpTimeImp(SClusterObj *pCluster) {
4,250✔
125
#if 0
126
  int32_t upTime = taosGetTimestampSec() - pCluster->updateTime / 1000;
127
  upTime = upTime + pCluster->upTime;
128
  return upTime;
129
#else
130
  return pCluster->upTime;
4,250✔
131
#endif
132
}
133

134
int64_t mndGetClusterUpTime(SMnode *pMnode) {
4,237✔
135
  int64_t      upTime = 0;
4,237✔
136
  void        *pIter = NULL;
4,237✔
137
  SClusterObj *pCluster = mndAcquireCluster(pMnode, &pIter);
4,237✔
138
  if (pCluster != NULL) {
4,237!
139
    upTime = mndGetClusterUpTimeImp(pCluster);
4,237✔
140
    mndReleaseCluster(pMnode, pCluster, pIter);
4,237✔
141
  }
142

143
  return upTime;
4,237✔
144
}
145

146
static SSdbRaw *mndClusterActionEncode(SClusterObj *pCluster) {
4,985✔
147
  int32_t code = 0;
4,985✔
148
  int32_t lino = 0;
4,985✔
149
  terrno = TSDB_CODE_OUT_OF_MEMORY;
4,985✔
150

151
  SSdbRaw *pRaw = sdbAllocRaw(SDB_CLUSTER, CLUSTER_VER_NUMBE, sizeof(SClusterObj) + CLUSTER_RESERVE_SIZE);
4,985✔
152
  if (pRaw == NULL) goto _OVER;
4,985!
153

154
  int32_t dataPos = 0;
4,985✔
155
  SDB_SET_INT64(pRaw, dataPos, pCluster->id, _OVER)
4,985!
156
  SDB_SET_INT64(pRaw, dataPos, pCluster->createdTime, _OVER)
4,985!
157
  SDB_SET_INT64(pRaw, dataPos, pCluster->updateTime, _OVER)
4,985!
158
  SDB_SET_BINARY(pRaw, dataPos, pCluster->name, TSDB_CLUSTER_ID_LEN, _OVER)
4,985!
159
  SDB_SET_INT32(pRaw, dataPos, pCluster->upTime, _OVER)
4,985!
160
  SDB_SET_RESERVE(pRaw, dataPos, CLUSTER_RESERVE_SIZE, _OVER)
4,985!
161
  SDB_SET_DATALEN(pRaw, dataPos, _OVER);
4,985!
162

163
  terrno = 0;
4,985✔
164

165
_OVER:
4,985✔
166
  if (terrno != 0) {
4,985!
167
    mError("cluster:%" PRId64 ", failed to encode to raw:%p since %s", pCluster->id, pRaw, terrstr());
×
168
    sdbFreeRaw(pRaw);
×
169
    return NULL;
×
170
  }
171

172
  mTrace("cluster:%" PRId64 ", encode to raw:%p, row:%p", pCluster->id, pRaw, pCluster);
4,985✔
173
  return pRaw;
4,985✔
174
}
175

176
static SSdbRow *mndClusterActionDecode(SSdbRaw *pRaw) {
1,938✔
177
  int32_t code = 0;
1,938✔
178
  int32_t lino = 0;
1,938✔
179
  terrno = TSDB_CODE_OUT_OF_MEMORY;
1,938✔
180
  SClusterObj *pCluster = NULL;
1,938✔
181
  SSdbRow     *pRow = NULL;
1,938✔
182

183
  int8_t sver = 0;
1,938✔
184
  if (sdbGetRawSoftVer(pRaw, &sver) != 0) goto _OVER;
1,938!
185

186
  if (sver != CLUSTER_VER_NUMBE) {
1,938!
187
    terrno = TSDB_CODE_SDB_INVALID_DATA_VER;
×
188
    goto _OVER;
×
189
  }
190

191
  pRow = sdbAllocRow(sizeof(SClusterObj));
1,938✔
192
  if (pRow == NULL) goto _OVER;
1,938!
193

194
  pCluster = sdbGetRowObj(pRow);
1,938✔
195
  if (pCluster == NULL) goto _OVER;
1,938!
196

197
  int32_t dataPos = 0;
1,938✔
198
  SDB_GET_INT64(pRaw, dataPos, &pCluster->id, _OVER)
1,938!
199
  SDB_GET_INT64(pRaw, dataPos, &pCluster->createdTime, _OVER)
1,938!
200
  SDB_GET_INT64(pRaw, dataPos, &pCluster->updateTime, _OVER)
1,938!
201
  SDB_GET_BINARY(pRaw, dataPos, pCluster->name, TSDB_CLUSTER_ID_LEN, _OVER)
1,938!
202
  SDB_GET_INT32(pRaw, dataPos, &pCluster->upTime, _OVER)
1,938!
203
  SDB_GET_RESERVE(pRaw, dataPos, CLUSTER_RESERVE_SIZE, _OVER)
1,938!
204

205
  terrno = 0;
1,938✔
206

207
_OVER:
1,938✔
208
  if (terrno != 0) {
1,938!
209
    mError("cluster:%" PRId64 ", failed to decode from raw:%p since %s", pCluster == NULL ? 0 : pCluster->id, pRaw,
×
210
           terrstr());
211
    taosMemoryFreeClear(pRow);
×
212
    return NULL;
×
213
  }
214

215
  mTrace("cluster:%" PRId64 ", decode from raw:%p, row:%p", pCluster->id, pRaw, pCluster);
1,938✔
216
  return pRow;
1,938✔
217
}
218

219
static int32_t mndClusterActionInsert(SSdb *pSdb, SClusterObj *pCluster) {
1,929✔
220
  mTrace("cluster:%" PRId64 ", perform insert action, row:%p", pCluster->id, pCluster);
1,929✔
221
  pSdb->pMnode->clusterId = pCluster->id;
1,929✔
222
  pCluster->updateTime = taosGetTimestampMs();
1,929✔
223
  return 0;
1,929✔
224
}
225

226
static int32_t mndClusterActionDelete(SSdb *pSdb, SClusterObj *pCluster) {
1,938✔
227
  mTrace("cluster:%" PRId64 ", perform delete action, row:%p", pCluster->id, pCluster);
1,938✔
228
  return 0;
1,938✔
229
}
230

231
static int32_t mndClusterActionUpdate(SSdb *pSdb, SClusterObj *pOld, SClusterObj *pNew) {
9✔
232
  mTrace("cluster:%" PRId64 ", perform update action, old row:%p new row:%p, uptime from %d to %d", pOld->id, pOld,
9!
233
         pNew, pOld->upTime, pNew->upTime);
234
  pOld->upTime = pNew->upTime;
9✔
235
  pOld->updateTime = taosGetTimestampMs();
9✔
236
  return 0;
9✔
237
}
238

239
static int32_t mndCreateDefaultCluster(SMnode *pMnode) {
1,426✔
240
  SClusterObj clusterObj = {0};
1,426✔
241
  clusterObj.createdTime = taosGetTimestampMs();
1,426✔
242
  clusterObj.updateTime = clusterObj.createdTime;
1,426✔
243

244
  int32_t code = taosGetSystemUUIDLen(clusterObj.name, TSDB_CLUSTER_ID_LEN);
1,426✔
245
  if (code != 0) {
1,426!
246
    tstrncpy(clusterObj.name, "tdengine3.0", sizeof(clusterObj.name));
×
247
    mError("failed to get name from system, set to default val %s", clusterObj.name);
×
248
  }
249

250
  clusterObj.id = mndGenerateUid(clusterObj.name, TSDB_CLUSTER_ID_LEN);
1,426✔
251
  clusterObj.id = (clusterObj.id >= 0 ? clusterObj.id : -clusterObj.id);
1,426✔
252
  pMnode->clusterId = clusterObj.id;
1,426✔
253
  mInfo("cluster:%" PRId64 ", name is %s", clusterObj.id, clusterObj.name);
1,426!
254

255
  SSdbRaw *pRaw = mndClusterActionEncode(&clusterObj);
1,426✔
256
  if (pRaw == NULL) {
1,426!
257
    code = terrno;
×
258
    TAOS_RETURN(code);
×
259
  }
260
  code = sdbSetRawStatus(pRaw, SDB_STATUS_READY);
1,426✔
261
  if (code != 0) {
1,426!
262
    sdbFreeRaw(pRaw);
×
263
    TAOS_RETURN(code);
×
264
  }
265

266
  mInfo("cluster:%" PRId64 ", will be created when deploying, raw:%p", clusterObj.id, pRaw);
1,426!
267

268
  STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, NULL, "create-cluster");
1,426✔
269
  if (pTrans == NULL) {
1,426!
270
    sdbFreeRaw(pRaw);
×
271
    mError("cluster:%" PRId64 ", failed to create since %s", clusterObj.id, terrstr());
×
272
    code = terrno;
×
273
    TAOS_RETURN(code);
×
274
  }
275
  mInfo("trans:%d, used to create cluster:%" PRId64, pTrans->id, clusterObj.id);
1,426!
276

277
  if ((code = mndTransAppendCommitlog(pTrans, pRaw)) != 0) {
1,426!
278
    mError("trans:%d, failed to commit redo log since %s", pTrans->id, terrstr());
×
279
    mndTransDrop(pTrans);
×
280
    TAOS_RETURN(code);
×
281
  }
282
  code = sdbSetRawStatus(pRaw, SDB_STATUS_READY);
1,426✔
283
  if (code != 0) {
1,426!
284
    sdbFreeRaw(pRaw);
×
285
    mndTransDrop(pTrans);
×
286
    TAOS_RETURN(code);
×
287
  }
288

289
  if ((code = mndTransPrepare(pMnode, pTrans)) != 0) {
1,426!
290
    mError("trans:%d, failed to prepare since %s", pTrans->id, terrstr());
×
291
    mndTransDrop(pTrans);
×
292
    TAOS_RETURN(code);
×
293
  }
294

295
  mndTransDrop(pTrans);
1,426✔
296
  return 0;
1,426✔
297
}
298

299
static int32_t mndRetrieveClusters(SRpcMsg *pMsg, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) {
13✔
300
  SMnode      *pMnode = pMsg->info.node;
13✔
301
  SSdb        *pSdb = pMnode->pSdb;
13✔
302
  int32_t      code = 0;
13✔
303
  int32_t      lino = 0;
13✔
304
  int32_t      numOfRows = 0;
13✔
305
  int32_t      cols = 0;
13✔
306
  SClusterObj *pCluster = NULL;
13✔
307

308
  while (numOfRows < rows) {
26!
309
    pShow->pIter = sdbFetch(pSdb, SDB_CLUSTER, pShow->pIter, (void **)&pCluster);
26✔
310
    if (pShow->pIter == NULL) break;
26✔
311

312
    cols = 0;
13✔
313
    SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
13✔
314
    COL_DATA_SET_VAL_GOTO((const char *)&pCluster->id, false, pCluster, pShow->pIter, _OVER);
13!
315

316
    char buf[tListLen(pCluster->name) + VARSTR_HEADER_SIZE] = {0};
13✔
317
    STR_WITH_MAXSIZE_TO_VARSTR(buf, pCluster->name, pShow->pMeta->pSchemas[cols].bytes);
13✔
318

319
    pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
13✔
320
    COL_DATA_SET_VAL_GOTO(buf, false, pCluster, pShow->pIter, _OVER);
13!
321

322
    int32_t upTime = mndGetClusterUpTimeImp(pCluster);
13✔
323
    pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
13✔
324
    COL_DATA_SET_VAL_GOTO((const char *)&upTime, false, pCluster, pShow->pIter, _OVER);
13!
325

326
    pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
13✔
327
    COL_DATA_SET_VAL_GOTO((const char *)&pCluster->createdTime, false, pCluster, pShow->pIter, _OVER);
13!
328

329
    char ver[12] = {0};
13✔
330
    STR_WITH_MAXSIZE_TO_VARSTR(ver, tsVersionName, pShow->pMeta->pSchemas[cols].bytes);
13✔
331
    pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
13✔
332
    COL_DATA_SET_VAL_GOTO((const char *)ver, false, pCluster, pShow->pIter, _OVER);
13!
333

334
    pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
13✔
335
    if (tsExpireTime <= 0) {
13!
336
      colDataSetNULL(pColInfo, numOfRows);
×
337
    } else {
338
      COL_DATA_SET_VAL_GOTO((const char *)&tsExpireTime, false, pCluster, pShow->pIter, _OVER);
13!
339
    }
340

341
    sdbRelease(pSdb, pCluster);
13✔
342
    numOfRows++;
13✔
343
  }
344

345
  pShow->numOfRows += numOfRows;
13✔
346

347
_OVER:
13✔
348
  if (code != 0) {
13!
349
    mError("failed to retrieve cluster info at line %d since %s", lino, tstrerror(code));
×
350
    TAOS_RETURN(code);
×
351
  }
352
  return numOfRows;
13✔
353
}
354

355
static void mndCancelGetNextCluster(SMnode *pMnode, void *pIter) {
×
356
  SSdb *pSdb = pMnode->pSdb;
×
357
  sdbCancelFetchByType(pSdb, pIter, SDB_CLUSTER);
×
358
}
×
359

360
static int32_t mndProcessUptimeTimer(SRpcMsg *pReq) {
9✔
361
  SMnode      *pMnode = pReq->info.node;
9✔
362
  SClusterObj  clusterObj = {0};
9✔
363
  void        *pIter = NULL;
9✔
364
  SClusterObj *pCluster = mndAcquireCluster(pMnode, &pIter);
9✔
365
  if (pCluster != NULL) {
9!
366
    (void)memcpy(&clusterObj, pCluster, sizeof(SClusterObj));
9✔
367
    clusterObj.upTime += tsUptimeInterval;
9✔
368
    mndReleaseCluster(pMnode, pCluster, pIter);
9✔
369
  }
370

371
  if (clusterObj.id <= 0) {
9!
372
    mError("can't get cluster info while update uptime");
×
373
    return 0;
×
374
  }
375

376
  int32_t code = 0;
9✔
377
  mInfo("update cluster uptime to %d", clusterObj.upTime);
9!
378
  STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pReq, "update-uptime");
9✔
379
  if (pTrans == NULL) {
9!
380
    code = terrno;
×
381
    TAOS_RETURN(code);
×
382
  }
383

384
  SSdbRaw *pCommitRaw = mndClusterActionEncode(&clusterObj);
9✔
385
  if (pCommitRaw == NULL) {
9!
386
    mError("trans:%d, failed to append commit log since %s", pTrans->id, terrstr());
×
387
    mndTransDrop(pTrans);
×
388
    code = terrno;
×
389
    TAOS_RETURN(code);
×
390
  }
391

392
  if ((code = mndTransAppendCommitlog(pTrans, pCommitRaw)) != 0) {
9!
393
    mError("trans:%d, failed to append commit log since %s", pTrans->id, terrstr());
×
394
    mndTransDrop(pTrans);
×
395
    TAOS_RETURN(code);
×
396
  }
397
  code = sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY);
9✔
398
  if (code != 0) {
9!
399
    sdbFreeRaw(pCommitRaw);
×
400
    mndTransDrop(pTrans);
×
401
    TAOS_RETURN(code);
×
402
  }
403

404
  if ((code = mndTransPrepare(pMnode, pTrans)) != 0) {
9!
405
    mError("trans:%d, failed to prepare since %s", pTrans->id, terrstr());
×
406
    mndTransDrop(pTrans);
×
407
    TAOS_RETURN(code);
×
408
  }
409

410
  mndTransDrop(pTrans);
9✔
411
  return 0;
9✔
412
}
413

414
int32_t mndProcessConfigClusterReq(SRpcMsg *pReq) {
6✔
415
  int32_t         code = 0;
6✔
416
  SMnode         *pMnode = pReq->info.node;
6✔
417
  SMCfgClusterReq cfgReq = {0};
6✔
418
  if (tDeserializeSMCfgClusterReq(pReq->pCont, pReq->contLen, &cfgReq) != 0) {
6!
419
    code = TSDB_CODE_INVALID_MSG;
×
420
    TAOS_RETURN(code);
×
421
  }
422

423
  mInfo("cluster: start to config, option:%s, value:%s", cfgReq.config, cfgReq.value);
6!
424
  if ((code = mndCheckOperPrivilege(pMnode, pReq->info.conn.user, MND_OPER_CONFIG_CLUSTER)) != 0) {
6!
425
    goto _exit;
×
426
  }
427

428
  SClusterObj  clusterObj = {0};
6✔
429
  void        *pIter = NULL;
6✔
430
  SClusterObj *pCluster = mndAcquireCluster(pMnode, &pIter);
6✔
431
  if (!pCluster || pCluster->id <= 0) {
6!
432
    code = TSDB_CODE_APP_IS_STARTING;
×
433
    if (pCluster) mndReleaseCluster(pMnode, pCluster, pIter);
×
434
    goto _exit;
×
435
  }
436
  (void)memcpy(&clusterObj, pCluster, sizeof(SClusterObj));
6✔
437
  mndReleaseCluster(pMnode, pCluster, pIter);
6✔
438

439
  if (strncmp(cfgReq.config, GRANT_ACTIVE_CODE, TSDB_DNODE_CONFIG_LEN) == 0) {
6!
440
#ifdef TD_ENTERPRISE
441
    if (0 != (code = mndProcessConfigGrantReq(pMnode, pReq, &cfgReq))) {
6✔
442
      goto _exit;
3✔
443
    }
444
#else
445
    code = TSDB_CODE_OPS_NOT_SUPPORT;
446
    goto _exit;
447
#endif
448
  } else {
449
    code = TSDB_CODE_OPS_NOT_SUPPORT;
×
450
    goto _exit;
×
451
  }
452

453
  {  // audit
454
    auditRecord(pReq, pMnode->clusterId, "alterCluster", "", "", cfgReq.sql,
3✔
455
                TMIN(cfgReq.sqlLen, GRANT_ACTIVE_HEAD_LEN << 1));
3✔
456
  }
457
_exit:
6✔
458
  tFreeSMCfgClusterReq(&cfgReq);
6✔
459
  if (code != 0) {
6✔
460
    mError("cluster: failed to config:%s %s since %s", cfgReq.config, cfgReq.value, tstrerror(code));
3!
461
  } else {
462
    mInfo("cluster: success to config:%s %s", cfgReq.config, cfgReq.value);
3!
463
  }
464
  TAOS_RETURN(code);
6✔
465
}
466

467
int32_t mndProcessConfigClusterRsp(SRpcMsg *pRsp) {
×
468
  mInfo("config rsp from cluster");
×
469
  return 0;
×
470
}
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