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

taosdata / TDengine / #3581

15 Jan 2025 01:12AM UTC coverage: 63.809% (+0.3%) from 63.556%
#3581

push

travis-ci

web-flow
Merge pull request #29561 from taosdata/fix/TD-33504

fix:[TD-33504]add test case

141492 of 284535 branches covered (49.73%)

Branch coverage included in aggregate %.

219814 of 281694 relevant lines covered (78.03%)

19173854.68 hits per line

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

56.41
/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,851✔
41
  SSdbTable table = {
1,851✔
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,851✔
53
  mndSetMsgHandle(pMnode, TDMT_MND_CONFIG_CLUSTER, mndProcessConfigClusterReq);
1,851✔
54
  mndSetMsgHandle(pMnode, TDMT_MND_CONFIG_CLUSTER_RSP, mndProcessConfigClusterRsp);
1,851✔
55
  mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_CLUSTER, mndRetrieveClusters);
1,851✔
56
  mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_CLUSTER, mndCancelGetNextCluster);
1,851✔
57

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

61
void mndCleanupCluster(SMnode *pMnode) {}
1,850✔
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) {
173,233✔
79
  SSdb *pSdb = pMnode->pSdb;
173,233✔
80
  void *pIter = NULL;
173,233✔
81

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

87
    *ppIter = pIter;
169,368✔
88
    return pCluster;
169,368✔
89
  }
90

91
  return NULL;
3,919✔
92
}
93

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

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

109
  return clusterId;
111,218✔
110
}
111

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

121
  return createTime;
58,490✔
122
}
123

124
static int32_t mndGetClusterUpTimeImp(SClusterObj *pCluster) {
7,819✔
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;
7,819✔
131
#endif
132
}
133

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

143
  return upTime;
3,504✔
144
}
145

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

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

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

163
  terrno = 0;
4,696✔
164

165
_OVER:
4,696✔
166
  if (terrno != 0) {
4,696!
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,696✔
173
  return pRaw;
4,696✔
174
}
175

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

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

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

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

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

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

205
  terrno = 0;
1,942✔
206

207
_OVER:
1,942✔
208
  if (terrno != 0) {
1,942!
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,942✔
216
  return pRow;
1,942✔
217
}
218

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

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

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

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

244
  int32_t code = taosGetSystemUUIDLen(clusterObj.name, TSDB_CLUSTER_ID_LEN);
1,354✔
245
  if (code != 0) {
1,354!
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,354✔
251
  clusterObj.id = (clusterObj.id >= 0 ? clusterObj.id : -clusterObj.id);
1,354✔
252
  pMnode->clusterId = clusterObj.id;
1,354✔
253
  mInfo("cluster:%" PRId64 ", name is %s", clusterObj.id, clusterObj.name);
1,354!
254

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

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

268
  STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, NULL, "create-cluster");
1,354✔
269
  if (pTrans == NULL) {
1,354!
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,354!
276

277
  if ((code = mndTransAppendCommitlog(pTrans, pRaw)) != 0) {
1,354!
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,354✔
283
  if (code != 0) {
1,354!
284
    sdbFreeRaw(pRaw);
×
285
    mndTransDrop(pTrans);
×
286
    TAOS_RETURN(code);
×
287
  }
288

289
  if ((code = mndTransPrepare(pMnode, pTrans)) != 0) {
1,354!
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,354✔
296
  return 0;
1,354✔
297
}
298

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

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

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

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

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

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

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

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

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

341
    sdbRelease(pSdb, pCluster);
4,312✔
342
    numOfRows++;
4,327✔
343
  }
344

345
  pShow->numOfRows += numOfRows;
4,327✔
346

347
_OVER:
4,327✔
348
  if (code != 0) {
4,327!
349
    mError("failed to retrieve cluster info at line %d since %s", lino, tstrerror(code));
×
350
    TAOS_RETURN(code);
×
351
  }
352
  return numOfRows;
4,327✔
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) {
91✔
361
  SMnode      *pMnode = pReq->info.node;
91✔
362
  SClusterObj  clusterObj = {0};
91✔
363
  void        *pIter = NULL;
91✔
364
  SClusterObj *pCluster = mndAcquireCluster(pMnode, &pIter);
91✔
365
  if (pCluster != NULL) {
91!
366
    (void)memcpy(&clusterObj, pCluster, sizeof(SClusterObj));
91✔
367
    clusterObj.upTime += tsUptimeInterval;
91✔
368
    mndReleaseCluster(pMnode, pCluster, pIter);
91✔
369
  }
370

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

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

384
  SSdbRaw *pCommitRaw = mndClusterActionEncode(&clusterObj);
91✔
385
  if (pCommitRaw == NULL) {
91!
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) {
91!
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);
91✔
398
  if (code != 0) {
91!
399
    sdbFreeRaw(pCommitRaw);
×
400
    mndTransDrop(pTrans);
×
401
    TAOS_RETURN(code);
×
402
  }
403

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

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

414
int32_t mndProcessConfigClusterReq(SRpcMsg *pReq) {
×
415
  int32_t         code = 0;
×
416
  SMnode         *pMnode = pReq->info.node;
×
417
  SMCfgClusterReq cfgReq = {0};
×
418
  if (tDeserializeSMCfgClusterReq(pReq->pCont, pReq->contLen, &cfgReq) != 0) {
×
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);
×
424
  if ((code = mndCheckOperPrivilege(pMnode, pReq->info.conn.user, MND_OPER_CONFIG_CLUSTER)) != 0) {
×
425
    goto _exit;
×
426
  }
427

428
  SClusterObj  clusterObj = {0};
×
429
  void        *pIter = NULL;
×
430
  SClusterObj *pCluster = mndAcquireCluster(pMnode, &pIter);
×
431
  if (!pCluster || pCluster->id <= 0) {
×
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));
×
437
  mndReleaseCluster(pMnode, pCluster, pIter);
×
438

439
  if (strncmp(cfgReq.config, GRANT_ACTIVE_CODE, TSDB_DNODE_CONFIG_LEN) == 0) {
×
440
#ifdef TD_ENTERPRISE
441
    if (0 != (code = mndProcessConfigGrantReq(pMnode, pReq, &cfgReq))) {
×
442
      goto _exit;
×
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,
×
455
                TMIN(cfgReq.sqlLen, GRANT_ACTIVE_HEAD_LEN << 1));
×
456
  }
457
_exit:
×
458
  tFreeSMCfgClusterReq(&cfgReq);
×
459
  if (code != 0) {
×
460
    mError("cluster: failed to config:%s %s since %s", cfgReq.config, cfgReq.value, tstrerror(code));
×
461
  } else {
462
    mInfo("cluster: success to config:%s %s", cfgReq.config, cfgReq.value);
×
463
  }
464
  TAOS_RETURN(code);
×
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

© 2026 Coveralls, Inc