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

taosdata / TDengine / #3548

04 Dec 2024 01:03PM UTC coverage: 59.846% (-0.8%) from 60.691%
#3548

push

travis-ci

web-flow
Merge pull request #29033 from taosdata/fix/calculate-vnode-memory-used

fix/calculate-vnode-memory-used

118484 of 254183 branches covered (46.61%)

Branch coverage included in aggregate %.

199691 of 277471 relevant lines covered (71.97%)

18794141.86 hits per line

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

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

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

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

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

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

91
  return NULL;
3,606✔
92
}
93

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

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

109
  return clusterId;
100,446✔
110
}
111

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

121
  return createTime;
53,791✔
122
}
123

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

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

143
  return upTime;
3,196✔
144
}
145

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

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

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

163
  terrno = 0;
4,197✔
164

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

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

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

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

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

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

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

205
  terrno = 0;
1,779✔
206

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

410
  mndTransDrop(pTrans);
78✔
411
  return 0;
78✔
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, terrstr());
×
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

© 2025 Coveralls, Inc