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

taosdata / TDengine / #3559

18 Dec 2024 12:59AM UTC coverage: 59.805% (+0.03%) from 59.778%
#3559

push

travis-ci

web-flow
Merge pull request #29187 from taosdata/merge/mainto3.0

merge: main to 3.0 branch

132705 of 287544 branches covered (46.15%)

Branch coverage included in aggregate %.

87 of 95 new or added lines in 19 files covered. (91.58%)

1132 existing lines in 133 files now uncovered.

209591 of 284807 relevant lines covered (73.59%)

8125235.78 hits per line

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

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

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

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

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

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

91
  return NULL;
3,111✔
92
}
93

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

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

109
  return clusterId;
86,492✔
110
}
111

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

121
  return createTime;
4,507✔
122
}
123

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

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

143
  return upTime;
2,663✔
144
}
145

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

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

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

163
  terrno = 0;
3,824✔
164

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

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

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

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

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

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

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

205
  terrno = 0;
1,551✔
206

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

410
  mndTransDrop(pTrans);
33✔
411
  return 0;
33✔
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