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

taosdata / TDengine / #4875

09 Dec 2025 01:22AM UTC coverage: 64.472% (-0.2%) from 64.623%
#4875

push

travis-ci

guanshengliang
fix: temporarily disable memory leak detection for UDF tests (#33856)

162014 of 251293 relevant lines covered (64.47%)

104318075.66 hits per line

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

57.92
/source/dnode/mnode/impl/src/mndConfig.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 "mndConfig.h"
19
#include "mndDnode.h"
20
#include "mndMnode.h"
21
#include "mndPrivilege.h"
22
#include "mndSync.h"
23
#include "mndTrans.h"
24
#include "mndUser.h"
25
#include "tutil.h"
26
#include "tcompare.h"
27

28
#define CFG_VER_NUMBER    1
29
#define CFG_RESERVE_SIZE  63
30
#define CFG_ALTER_TIMEOUT 3 * 1000
31

32
// Sync timeout ratio constants
33
#define SYNC_TIMEOUT_DIVISOR       4
34
#define SYNC_TIMEOUT_ELECT_DIVISOR 2
35
#define SYNC_TIMEOUT_SR_DIVISOR    4
36
#define SYNC_TIMEOUT_HB_DIVISOR    8
37

38
static int32_t mndMCfgGetValInt32(SMCfgDnodeReq *pInMCfgReq, int32_t optLen, int32_t *pOutValue);
39
static int32_t mndProcessShowVariablesReq(SRpcMsg *pReq);
40
static int32_t mndProcessConfigDnodeReq(SRpcMsg *pReq);
41
static int32_t mndProcessConfigDnodeRsp(SRpcMsg *pRsp);
42
static int32_t mndProcessConfigReq(SRpcMsg *pReq);
43
static int32_t mndInitWriteCfg(SMnode *pMnode);
44
static int32_t mndSendRebuildReq(SMnode *pMnode);
45
static int32_t mndTryRebuildConfigSdbRsp(SRpcMsg *pRsp);
46
static int32_t initConfigArrayFromSdb(SMnode *pMnode, SArray *array);
47
static int32_t mndTryRebuildConfigSdb(SRpcMsg *pReq);
48
static void    cfgArrayCleanUp(SArray *array);
49
static void    cfgObjArrayCleanUp(SArray *array);
50
int32_t        compareSConfigItemArrays(SMnode *pMnode, const SArray *dArray, SArray *diffArray);
51

52
static int32_t mndConfigUpdateTrans(SMnode *pMnode, const char *name, char *pValue, ECfgDataType dtype,
53
                                    int32_t tsmmConfigVersion);
54
static int32_t mndConfigUpdateTransWithDnode(SMnode *pMnode, const char *name, char *pValue, ECfgDataType dtype,
55
                                             int32_t tsmmConfigVersion, int32_t dnodeId, SDCfgDnodeReq *pDcfgReq);
56
static int32_t mndFindConfigsToAdd(SMnode *pMnode, SArray *addArray);
57
static int32_t mndFindConfigsToDelete(SMnode *pMnode, SArray *deleteArray);
58
static int32_t mndExecuteConfigSyncTrans(SMnode *pMnode, SArray *addArray, SArray *deleteArray);
59

60
int32_t mndSetCreateConfigCommitLogs(STrans *pTrans, SConfigObj *obj);
61
int32_t mndSetDeleteConfigCommitLogs(STrans *pTrans, SConfigObj *item);
62
int32_t mndSetCreateConfigPrepareLogs(STrans *pTrans, SConfigObj *obj);
63

64
int32_t mndInitConfig(SMnode *pMnode) {
504,155✔
65
  int32_t   code = 0;
504,155✔
66
  SSdbTable table = {.sdbType = SDB_CFG,
504,155✔
67
                     .keyType = SDB_KEY_BINARY,
68
                     .encodeFp = (SdbEncodeFp)mnCfgActionEncode,
69
                     .decodeFp = (SdbDecodeFp)mndCfgActionDecode,
70
                     .insertFp = (SdbInsertFp)mndCfgActionInsert,
71
                     .updateFp = (SdbUpdateFp)mndCfgActionUpdate,
72
                     .deleteFp = (SdbDeleteFp)mndCfgActionDelete,
73
                     .deployFp = (SdbDeployFp)mndCfgActionDeploy,
74
                     .afterRestoredFp = (SdbAfterRestoredFp)mndCfgActionAfterRestored};
75

76
  mndSetMsgHandle(pMnode, TDMT_MND_CONFIG, mndProcessConfigReq);
504,155✔
77
  mndSetMsgHandle(pMnode, TDMT_MND_CONFIG_DNODE, mndProcessConfigDnodeReq);
504,155✔
78
  mndSetMsgHandle(pMnode, TDMT_DND_CONFIG_DNODE_RSP, mndTransProcessRsp);
504,155✔
79
  mndSetMsgHandle(pMnode, TDMT_MND_SHOW_VARIABLES, mndProcessShowVariablesReq);
504,155✔
80
  mndSetMsgHandle(pMnode, TDMT_MND_CONFIG_SDB, mndTryRebuildConfigSdb);
504,155✔
81
  mndSetMsgHandle(pMnode, TDMT_MND_CONFIG_SDB_RSP, mndTryRebuildConfigSdbRsp);
504,155✔
82

83
  return sdbSetTable(pMnode->pSdb, table);
504,155✔
84
}
85

86
SSdbRaw *mnCfgActionEncode(SConfigObj *obj) {
134,523,879✔
87
  int32_t  code = 0;
134,523,879✔
88
  int32_t  lino = 0;
134,523,879✔
89
  void    *buf = NULL;
134,523,879✔
90
  SSdbRaw *pRaw = NULL;
134,523,879✔
91

92
  SEncoder encoder;
133,938,161✔
93
  tEncoderInit(&encoder, NULL, 0);
134,523,879✔
94
  if ((code = tEncodeSConfigObj(&encoder, obj)) < 0) {
134,523,879✔
95
    tEncoderClear(&encoder);
×
96
    TSDB_CHECK_CODE(code, lino, _over);
×
97
  }
98

99
  int32_t tlen = encoder.pos;
134,523,879✔
100
  tEncoderClear(&encoder);
134,523,879✔
101

102
  int32_t size = sizeof(int32_t) + tlen;
134,523,879✔
103
  pRaw = sdbAllocRaw(SDB_CFG, CFG_VER_NUMBER, size);
134,523,879✔
104
  TSDB_CHECK_NULL(pRaw, code, lino, _over, terrno);
134,523,879✔
105

106
  buf = taosMemoryMalloc(tlen);
134,523,879✔
107
  TSDB_CHECK_NULL(buf, code, lino, _over, terrno);
134,523,879✔
108

109
  tEncoderInit(&encoder, buf, tlen);
134,523,879✔
110
  if ((code = tEncodeSConfigObj(&encoder, obj)) < 0) {
134,523,879✔
111
    tEncoderClear(&encoder);
×
112
    TSDB_CHECK_CODE(code, lino, _over);
×
113
  }
114

115
  tEncoderClear(&encoder);
134,523,879✔
116

117
  int32_t dataPos = 0;
134,523,879✔
118
  SDB_SET_INT32(pRaw, dataPos, tlen, _over);
134,523,879✔
119
  SDB_SET_BINARY(pRaw, dataPos, buf, tlen, _over);
134,523,879✔
120
  SDB_SET_DATALEN(pRaw, dataPos, _over);
134,523,879✔
121

122
_over:
134,523,879✔
123
  taosMemoryFreeClear(buf);
134,523,879✔
124
  if (code != TSDB_CODE_SUCCESS) {
134,523,879✔
125
    mError("cfg:%s, failed to encode to raw:%p at line:%d since %s", obj->name, pRaw, lino, tstrerror(code));
×
126
    sdbFreeRaw(pRaw);
×
127
    terrno = code;
×
128
    return NULL;
×
129
  }
130

131
  terrno = 0;
134,523,879✔
132
  mTrace("cfg:%s, encode to raw:%p, row:%p", obj->name, pRaw, obj);
134,523,879✔
133
  return pRaw;
134,523,879✔
134
}
135

136
SSdbRow *mndCfgActionDecode(SSdbRaw *pRaw) {
54,278,208✔
137
  int32_t     code = 0;
54,278,208✔
138
  int32_t     lino = 0;
54,278,208✔
139
  SSdbRow    *pRow = NULL;
54,278,208✔
140
  SConfigObj *pObj = NULL;
54,278,208✔
141
  void       *buf = NULL;
54,278,208✔
142
  int8_t      sver = 0;
54,278,208✔
143
  int32_t     tlen;
53,924,787✔
144
  int32_t     dataPos = 0;
54,278,208✔
145

146
  code = sdbGetRawSoftVer(pRaw, &sver);
54,278,208✔
147
  TSDB_CHECK_CODE(code, lino, _over);
54,278,208✔
148

149
  if (sver != CFG_VER_NUMBER) {
54,278,208✔
150
    terrno = TSDB_CODE_SDB_INVALID_DATA_VER;
×
151
    goto _over;
×
152
  }
153

154
  pRow = sdbAllocRow(sizeof(SConfigObj));
54,278,208✔
155
  TSDB_CHECK_NULL(pRow, code, lino, _over, terrno);
54,278,208✔
156

157
  pObj = sdbGetRowObj(pRow);
54,278,208✔
158
  TSDB_CHECK_NULL(pObj, code, lino, _over, terrno);
54,278,208✔
159

160
  SDB_GET_INT32(pRaw, dataPos, &tlen, _over);
54,278,208✔
161

162
  buf = taosMemoryMalloc(tlen + 1);
54,278,208✔
163
  TSDB_CHECK_NULL(buf, code, lino, _over, terrno);
54,278,208✔
164

165
  SDB_GET_BINARY(pRaw, dataPos, buf, tlen, _over);
54,278,208✔
166

167
  SDecoder decoder;
53,924,787✔
168
  tDecoderInit(&decoder, buf, tlen + 1);
54,278,208✔
169
  code = tDecodeSConfigObj(&decoder, pObj);
54,278,208✔
170
  tDecoderClear(&decoder);
54,278,208✔
171

172
  if (code < 0) {
54,278,208✔
173
    tFreeSConfigObj(pObj);
×
174
  }
175

176
_over:
54,278,208✔
177
  taosMemoryFreeClear(buf);
54,278,208✔
178

179
  if (code != TSDB_CODE_SUCCESS) {
54,278,208✔
180
    mError("cfg:%s, failed to decode from raw:%p since %s at:%d", pObj->name, pRaw, tstrerror(code), lino);
×
181
    taosMemoryFreeClear(pRow);
×
182
    terrno = code;
×
183
    return NULL;
×
184
  } else {
185
    mTrace("config:%s, decode from raw:%p, row:%p", pObj->name, pRaw, pObj);
54,278,208✔
186
    terrno = 0;
54,278,208✔
187
    return pRow;
54,278,208✔
188
  }
189
}
190

191
static int32_t mndCfgActionInsert(SSdb *pSdb, SConfigObj *obj) {
53,917,043✔
192
  mTrace("cfg:%s, perform insert action, row:%p", obj->name, obj);
53,917,043✔
193
  return 0;
53,917,043✔
194
}
195

196
static int32_t mndCfgActionDelete(SSdb *pSdb, SConfigObj *obj) {
54,219,251✔
197
  mTrace("cfg:%s, perform delete action, row:%p", obj->name, obj);
54,219,251✔
198
  tFreeSConfigObj(obj);
54,219,251✔
199
  return 0;
54,219,251✔
200
}
201

202
static int32_t mndCfgActionUpdate(SSdb *pSdb, SConfigObj *pOld, SConfigObj *pNew) {
361,165✔
203
  mTrace("cfg:%s, perform update action, old row:%p new row:%p", pOld->name, pOld, pNew);
361,165✔
204
  switch (pNew->dtype) {
361,165✔
205
    case CFG_DTYPE_NONE:
×
206
      break;
×
207
    case CFG_DTYPE_BOOL:
35,759✔
208
      pOld->bval = pNew->bval;
35,759✔
209
      break;
35,759✔
210
    case CFG_DTYPE_INT32:
299,534✔
211
      pOld->i32 = pNew->i32;
299,534✔
212
      break;
299,534✔
213
    case CFG_DTYPE_INT64:
13,776✔
214
      pOld->i64 = pNew->i64;
13,776✔
215
      break;
13,776✔
216
    case CFG_DTYPE_FLOAT:
4,608✔
217
    case CFG_DTYPE_DOUBLE:
218
      pOld->fval = pNew->fval;
4,608✔
219
      break;
4,608✔
220
    case CFG_DTYPE_STRING:
7,488✔
221
    case CFG_DTYPE_DIR:
222
    case CFG_DTYPE_LOCALE:
223
    case CFG_DTYPE_CHARSET:
224
    case CFG_DTYPE_TIMEZONE:
225
      taosMemoryFree(pOld->str);
7,488✔
226
      pOld->str = taosStrdup(pNew->str);
7,488✔
227
      if (pOld->str == NULL) {
7,488✔
228
        return terrno;
×
229
      }
230
      break;
7,488✔
231
  }
232
  return TSDB_CODE_SUCCESS;
361,165✔
233
}
234

235
static int32_t mndCfgActionDeploy(SMnode *pMnode) { return mndInitWriteCfg(pMnode); }
328,429✔
236

237
static int32_t mndCfgActionAfterRestored(SMnode *pMnode) { return mndSendRebuildReq(pMnode); }
268,202✔
238

239
static int32_t mndProcessConfigReq(SRpcMsg *pReq) {
703,538✔
240
  SMnode    *pMnode = pReq->info.node;
703,538✔
241
  SConfigReq configReq = {0};
703,538✔
242
  int32_t    code = TSDB_CODE_SUCCESS;
703,538✔
243
  SArray    *array = NULL;
703,538✔
244
  bool       needFree = false;
703,538✔
245
  code = tDeserializeSConfigReq(pReq->pCont, pReq->contLen, &configReq);
703,538✔
246
  if (code != 0) {
703,538✔
247
    mError("failed to deserialize config req, since %s", terrstr());
×
248
    goto _OVER;
×
249
  }
250

251
  SConfigObj *vObj = sdbAcquire(pMnode->pSdb, SDB_CFG, "tsmmConfigVersion");
703,538✔
252
  if (vObj == NULL) {
703,538✔
253
    mInfo("failed to acquire mnd config version, since %s", terrstr());
×
254
    goto _OVER;
×
255
  }
256

257
  array = taosArrayInit(16, sizeof(SConfigItem));
703,538✔
258
  if (array == NULL) {
703,538✔
259
    code = TSDB_CODE_OUT_OF_MEMORY;
×
260
    goto _OVER;
×
261
  }
262
  SConfigRsp configRsp = {0};
703,538✔
263
  configRsp.cver = vObj->i32;
703,538✔
264

265
  if (configReq.cver == vObj->i32) {
703,538✔
266
    configRsp.isVersionVerified = 1;
172,053✔
267
  } else {
268
    code = initConfigArrayFromSdb(pMnode, array);
531,485✔
269
    if (code != 0) {
531,485✔
270
      mError("failed to init config array from sdb, since %s", tstrerror(code));
×
271
      goto _OVER;
×
272
    }
273
    configRsp.array = array;
531,485✔
274
  }
275

276
  int32_t contLen = tSerializeSConfigRsp(NULL, 0, &configRsp);
703,538✔
277
  if (contLen < 0) {
703,538✔
278
    code = contLen;
×
279
    goto _OVER;
×
280
  }
281
  void *pHead = rpcMallocCont(contLen);
703,538✔
282
  if (pHead == NULL) {
703,538✔
283
    code = TSDB_CODE_OUT_OF_MEMORY;
×
284
    goto _OVER;
×
285
  }
286
  contLen = tSerializeSConfigRsp(pHead, contLen, &configRsp);
703,538✔
287
  if (contLen < 0) {
703,538✔
288
    rpcFreeCont(pHead);
×
289
    code = contLen;
×
290
    goto _OVER;
×
291
  }
292
  pReq->info.rspLen = contLen;
703,538✔
293
  pReq->info.rsp = pHead;
703,538✔
294

295
_OVER:
703,538✔
296
  if (code != 0) {
703,538✔
297
    mError("failed to process config req, since %s", tstrerror(code));
×
298
  }
299
  sdbRelease(pMnode->pSdb, vObj);
703,538✔
300
  cfgArrayCleanUp(array);
703,538✔
301
  tFreeSConfigReq(&configReq);
703,538✔
302
  return code;
703,538✔
303
}
304

305
int32_t mndInitWriteCfg(SMnode *pMnode) {
328,429✔
306
  int    code = 0;
328,429✔
307
  size_t sz = 0;
328,429✔
308

309
  mInfo("init write cfg to sdb");
328,429✔
310
  STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, NULL, "init-write-config");
328,429✔
311
  if (pTrans == NULL) {
328,429✔
312
    mError("failed to init write cfg in create trans, since %s", terrstr());
×
313
    goto _OVER;
×
314
  }
315

316
  // encode mnd config version
317
  SConfigObj versionObj = mndInitConfigVersion();
328,429✔
318
  if ((code = mndSetCreateConfigCommitLogs(pTrans, &versionObj)) != 0) {
328,429✔
319
    mError("failed to init mnd config version, since %s", tstrerror(code));
×
320
    tFreeSConfigObj(&versionObj);
×
321
    goto _OVER;
×
322
  }
323
  tFreeSConfigObj(&versionObj);
328,429✔
324
  sz = taosArrayGetSize(taosGetGlobalCfg(tsCfg));
328,429✔
325

326
  for (int i = 0; i < sz; ++i) {
35,141,903✔
327
    SConfigItem *item = taosArrayGet(taosGetGlobalCfg(tsCfg), i);
34,813,474✔
328
    SConfigObj   obj;
34,653,096✔
329
    if ((code = mndInitConfigObj(item, &obj)) != 0) {
34,813,474✔
330
      goto _OVER;
×
331
    }
332
    if ((code = mndSetCreateConfigCommitLogs(pTrans, &obj)) != 0) {
34,813,474✔
333
      mError("failed to init mnd config:%s, since %s", item->name, tstrerror(code));
×
334
      tFreeSConfigObj(&obj);
×
335
      goto _OVER;
×
336
    }
337
    tFreeSConfigObj(&obj);
34,813,474✔
338
  }
339
  if ((code = mndTransPrepare(pMnode, pTrans)) != 0) goto _OVER;
328,429✔
340

341
_OVER:
328,429✔
342
  if (code != 0) {
328,429✔
343
    mError("failed to init write cfg, since %s", tstrerror(code));
×
344
  }
345
  mndTransDrop(pTrans);
328,429✔
346
  return code;
328,429✔
347
}
348

349
int32_t mndSendRebuildReq(SMnode *pMnode) {
268,202✔
350
  int32_t code = 0;
268,202✔
351

352
  SRpcMsg rpcMsg = {.pCont = NULL,
268,202✔
353
                    .contLen = 0,
354
                    .msgType = TDMT_MND_CONFIG_SDB,
355
                    .info.ahandle = 0,
356
                    .info.notFreeAhandle = 1,
357
                    .info.refId = 0,
358
                    .info.noResp = 0,
359
                    .info.handle = 0};
360
  SEpSet  epSet = {0};
268,202✔
361

362
  mndGetMnodeEpSet(pMnode, &epSet);
268,202✔
363

364
  code = tmsgSendReq(&epSet, &rpcMsg);
268,202✔
365
  if (code != 0) {
268,202✔
366
    mError("failed to send rebuild config req, since %s", tstrerror(code));
×
367
  }
368
  return code;
268,202✔
369
}
370

371
static int32_t mndTryRebuildConfigSdb(SRpcMsg *pReq) {
267,867✔
372
  SMnode *pMnode = pReq->info.node;
267,867✔
373
  if (!mndIsLeader(pMnode)) {
267,867✔
374
    return TSDB_CODE_SUCCESS;
×
375
  }
376

377
  int32_t     code = 0;
267,867✔
378
  SConfigObj *vObj = NULL;
267,867✔
379
  SArray     *addArray = NULL;
267,867✔
380
  SArray     *deleteArray = NULL;
267,867✔
381

382
  vObj = sdbAcquire(pMnode->pSdb, SDB_CFG, "tsmmConfigVersion");
267,867✔
383
  if (vObj == NULL) {
267,867✔
384
    code = mndInitWriteCfg(pMnode);
×
385
    if (code < 0) {
×
386
      mError("failed to init write cfg, since %s", tstrerror(code));
×
387
    } else {
388
      mInfo("failed to acquire mnd config version, try to rebuild config in sdb.");
×
389
    }
390
    goto _exit;
×
391
  }
392

393
  addArray = taosArrayInit(4, sizeof(SConfigObj));
267,867✔
394
  deleteArray = taosArrayInit(4, sizeof(SConfigObj));
267,867✔
395
  if (addArray == NULL || deleteArray == NULL) {
267,867✔
396
    code = TSDB_CODE_OUT_OF_MEMORY;
×
397
    goto _exit;
×
398
  }
399

400
  // Find configs to add and delete
401
  if ((code = mndFindConfigsToAdd(pMnode, addArray)) != 0) {
267,867✔
402
    mError("failed to find configs to add, since %s", tstrerror(code));
×
403
    goto _exit;
×
404
  }
405

406
  if ((code = mndFindConfigsToDelete(pMnode, deleteArray)) != 0) {
267,867✔
407
    mError("failed to find configs to delete, since %s", tstrerror(code));
×
408
    goto _exit;
×
409
  }
410

411
  // Execute the sync transaction
412
  if ((code = mndExecuteConfigSyncTrans(pMnode, addArray, deleteArray)) != 0) {
267,867✔
413
    mError("failed to execute config sync transaction, since %s", tstrerror(code));
×
414
    goto _exit;
×
415
  }
416

417
_exit:
267,867✔
418
  if (code != 0) {
267,867✔
419
    mError("failed to try rebuild config in sdb, since %s", tstrerror(code));
×
420
  }
421
  sdbRelease(pMnode->pSdb, vObj);
267,867✔
422
  cfgObjArrayCleanUp(addArray);
267,867✔
423
  cfgObjArrayCleanUp(deleteArray);
267,867✔
424
  TAOS_RETURN(code);
267,867✔
425
}
426

427
int32_t mndSetCreateConfigCommitLogs(STrans *pTrans, SConfigObj *item) {
35,179,937✔
428
  int32_t  code = 0;
35,179,937✔
429
  SSdbRaw *pCommitRaw = mnCfgActionEncode(item);
35,179,937✔
430
  if (pCommitRaw == NULL) {
35,179,937✔
431
    code = terrno;
×
432
    TAOS_RETURN(code);
×
433
  }
434
  if ((code = mndTransAppendCommitlog(pTrans, pCommitRaw)) != 0) {
35,179,937✔
435
    taosMemoryFree(pCommitRaw);
×
436
    TAOS_RETURN(code);
×
437
  }
438
  if ((code = sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY)) != 0) TAOS_RETURN(code);
35,179,937✔
439
  return TSDB_CODE_SUCCESS;
35,179,937✔
440
}
441

442
int32_t mndSetDeleteConfigCommitLogs(STrans *pTrans, SConfigObj *item) {
×
443
  int32_t  code = 0;
×
444
  SSdbRaw *pCommitRaw = mnCfgActionEncode(item);
×
445
  if (pCommitRaw == NULL) {
×
446
    code = terrno;
×
447
    TAOS_RETURN(code);
×
448
  }
449
  if ((code = mndTransAppendCommitlog(pTrans, pCommitRaw)) != 0) {
×
450
    taosMemoryFree(pCommitRaw);
×
451
    TAOS_RETURN(code);
×
452
  }
453
  if ((code = sdbSetRawStatus(pCommitRaw, SDB_STATUS_DROPPED)) != 0) TAOS_RETURN(code);
×
454
  return TSDB_CODE_SUCCESS;
×
455
}
456

457
int32_t mndSetCreateConfigPrepareLogs(STrans *pTrans, SConfigObj *item) {
38,034✔
458
  int32_t  code = 0;
38,034✔
459
  SSdbRaw *pPrepareRaw = mnCfgActionEncode(item);
38,034✔
460
  if (pPrepareRaw == NULL) {
38,034✔
461
    code = terrno;
×
462
    TAOS_RETURN(code);
×
463
  }
464
  if ((code = mndTransAppendPrepareLog(pTrans, pPrepareRaw)) != 0) {
38,034✔
465
    taosMemoryFree(pPrepareRaw);
×
466
    TAOS_RETURN(code);
×
467
  }
468
  if ((code = sdbSetRawStatus(pPrepareRaw, SDB_STATUS_READY)) != 0) TAOS_RETURN(code);
38,034✔
469
  return TSDB_CODE_SUCCESS;
38,034✔
470
}
471

472
static int32_t mndFindConfigsToAdd(SMnode *pMnode, SArray *addArray) {
267,867✔
473
  int32_t code = 0;
267,867✔
474
  int32_t sz = taosArrayGetSize(taosGetGlobalCfg(tsCfg));
267,867✔
475

476
  for (int i = 0; i < sz; ++i) {
28,661,769✔
477
    SConfigItem *item = taosArrayGet(taosGetGlobalCfg(tsCfg), i);
28,393,902✔
478
    SConfigObj  *obj = sdbAcquire(pMnode->pSdb, SDB_CFG, item->name);
28,393,902✔
479
    if (obj == NULL) {
28,393,902✔
480
      mInfo("config:%s, not exist in sdb, will add it", item->name);
×
481
      SConfigObj newObj;
×
482
      if ((code = mndInitConfigObj(item, &newObj)) != 0) {
×
483
        TAOS_RETURN(code);
×
484
      }
485
      if (NULL == taosArrayPush(addArray, &newObj)) {
×
486
        tFreeSConfigObj(&newObj);
×
487
        TAOS_RETURN(terrno);
×
488
      }
489
    } else {
490
      sdbRelease(pMnode->pSdb, obj);
28,393,902✔
491
    }
492
  }
493

494
  TAOS_RETURN(TSDB_CODE_SUCCESS);
267,867✔
495
}
496

497
static int32_t mndFindConfigsToDelete(SMnode *pMnode, SArray *deleteArray) {
267,867✔
498
  int32_t     code = 0;
267,867✔
499
  int32_t     sz = taosArrayGetSize(taosGetGlobalCfg(tsCfg));
267,867✔
500
  SSdb       *pSdb = pMnode->pSdb;
267,867✔
501
  void       *pIter = NULL;
267,867✔
502
  SConfigObj *obj = NULL;
267,867✔
503

504
  while (1) {
28,661,769✔
505
    pIter = sdbFetch(pSdb, SDB_CFG, pIter, (void **)&obj);
28,929,636✔
506
    if (pIter == NULL) break;
28,929,636✔
507
    if (obj == NULL) {
28,661,769✔
508
      code = TSDB_CODE_OUT_OF_MEMORY;
×
509
      sdbCancelFetch(pSdb, pIter);
×
510
      TAOS_RETURN(code);
×
511
    }
512

513
    // Skip the version config
514
    if (strcasecmp(obj->name, "tsmmConfigVersion") == 0) {
28,661,769✔
515
      sdbRelease(pSdb, obj);
267,867✔
516
      continue;
267,867✔
517
    }
518

519
    // Check if this config exists in global config
520
    bool existsInGlobal = false;
28,393,902✔
521
    for (int i = 0; i < sz; ++i) {
1,519,073,757✔
522
      SConfigItem *item = taosArrayGet(taosGetGlobalCfg(tsCfg), i);
1,519,073,757✔
523
      if (strcasecmp(obj->name, item->name) == 0) {
1,519,073,757✔
524
        existsInGlobal = true;
28,393,902✔
525
        break;
28,393,902✔
526
      }
527
    }
528

529
    if (!existsInGlobal) {
28,393,902✔
530
      mInfo("config:%s, not exist in global config, will delete it from sdb", obj->name);
×
531
      SConfigObj deleteObj = {0};
×
532
      tstrncpy(deleteObj.name, obj->name, CFG_NAME_MAX_LEN);
×
533
      deleteObj.dtype = obj->dtype;
×
534

535
      // Copy the value based on type
536
      switch (obj->dtype) {
×
537
        case CFG_DTYPE_BOOL:
×
538
          deleteObj.bval = obj->bval;
×
539
          break;
×
540
        case CFG_DTYPE_INT32:
×
541
          deleteObj.i32 = obj->i32;
×
542
          break;
×
543
        case CFG_DTYPE_INT64:
×
544
          deleteObj.i64 = obj->i64;
×
545
          break;
×
546
        case CFG_DTYPE_FLOAT:
×
547
        case CFG_DTYPE_DOUBLE:
548
          deleteObj.fval = obj->fval;
×
549
          break;
×
550
        case CFG_DTYPE_STRING:
×
551
        case CFG_DTYPE_DIR:
552
        case CFG_DTYPE_LOCALE:
553
        case CFG_DTYPE_CHARSET:
554
        case CFG_DTYPE_TIMEZONE:
555
          deleteObj.str = taosStrdup(obj->str);
×
556
          if (deleteObj.str == NULL) {
×
557
            sdbCancelFetch(pSdb, pIter);
×
558
            sdbRelease(pSdb, obj);
×
559
            TAOS_RETURN(terrno);
×
560
          }
561
          break;
×
562
        default:
×
563
          break;
×
564
      }
565

566
      if (NULL == taosArrayPush(deleteArray, &deleteObj)) {
×
567
        tFreeSConfigObj(&deleteObj);
×
568
        sdbCancelFetch(pSdb, pIter);
×
569
        sdbRelease(pSdb, obj);
×
570
        TAOS_RETURN(terrno);
×
571
      }
572
    }
573

574
    sdbRelease(pSdb, obj);
28,393,902✔
575
  }
576

577
  TAOS_RETURN(TSDB_CODE_SUCCESS);
267,867✔
578
}
579

580
static int32_t mndExecuteConfigSyncTrans(SMnode *pMnode, SArray *addArray, SArray *deleteArray) {
267,867✔
581
  int32_t addSize = taosArrayGetSize(addArray);
267,867✔
582
  int32_t deleteSize = taosArrayGetSize(deleteArray);
267,867✔
583

584
  if (addSize == 0 && deleteSize == 0) {
267,867✔
585
    return TSDB_CODE_SUCCESS;
267,867✔
586
  }
587

588
  const char *transName = "sync-config";
×
589
  if (addSize > 0 && deleteSize > 0) {
×
590
    transName = "sync-config";
×
591
  } else if (addSize > 0) {
×
592
    transName = "add-config";
×
593
  } else {
594
    transName = "delete-config";
×
595
  }
596

597
  STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, NULL, transName);
×
598
  if (pTrans == NULL) {
×
599
    TAOS_RETURN(terrno);
×
600
  }
601

602
  int32_t code = 0;
×
603

604
  // Add new configs
605
  for (int i = 0; i < addSize; ++i) {
×
606
    SConfigObj *AddObj = taosArrayGet(addArray, i);
×
607
    if ((code = mndSetCreateConfigCommitLogs(pTrans, AddObj)) != 0) {
×
608
      mndTransDrop(pTrans);
×
609
      TAOS_RETURN(code);
×
610
    }
611
  }
612

613
  // Delete obsolete configs
614
  for (int i = 0; i < deleteSize; ++i) {
×
615
    SConfigObj *DelObj = taosArrayGet(deleteArray, i);
×
616
    if ((code = mndSetDeleteConfigCommitLogs(pTrans, DelObj)) != 0) {
×
617
      mndTransDrop(pTrans);
×
618
      TAOS_RETURN(code);
×
619
    }
620
  }
621

622
  if ((code = mndTransPrepare(pMnode, pTrans)) != 0) {
×
623
    mndTransDrop(pTrans);
×
624
    TAOS_RETURN(code);
×
625
  }
626

627
  mInfo("sync config to sdb, add nums:%d, delete nums:%d", addSize, deleteSize);
×
628
  mndTransDrop(pTrans);
×
629
  TAOS_RETURN(TSDB_CODE_SUCCESS);
×
630
}
631

632
static int32_t mndMCfg2DCfg(SMCfgDnodeReq *pMCfgReq, SDCfgDnodeReq *pDCfgReq) {
115,054✔
633
  int32_t code = 0;
115,054✔
634
  char   *p = pMCfgReq->config;
115,054✔
635
  while (*p) {
1,733,248✔
636
    if (*p == ' ') {
1,674,731✔
637
      break;
56,537✔
638
    }
639
    p++;
1,618,194✔
640
  }
641

642
  size_t optLen = p - pMCfgReq->config;
115,054✔
643
  tstrncpy(pDCfgReq->config, pMCfgReq->config, sizeof(pDCfgReq->config));
115,054✔
644
  pDCfgReq->config[optLen] = 0;
115,054✔
645

646
  if (' ' == pMCfgReq->config[optLen]) {
115,054✔
647
    // 'key value'
648
    if (strlen(pMCfgReq->value) != 0) goto _err;
56,537✔
649
    tstrncpy(pDCfgReq->value, p + 1, sizeof(pDCfgReq->value));
56,537✔
650
  } else {
651
    // 'key' 'value'
652
    if (strlen(pMCfgReq->value) == 0) goto _err;
58,517✔
653
    tstrncpy(pDCfgReq->value, pMCfgReq->value, sizeof(pDCfgReq->value));
57,540✔
654
  }
655

656
  TAOS_RETURN(code);
114,077✔
657

658
_err:
977✔
659
  mError("dnode:%d, failed to config since invalid conf:%s", pMCfgReq->dnodeId, pMCfgReq->config);
977✔
660
  code = TSDB_CODE_INVALID_CFG;
977✔
661
  TAOS_RETURN(code);
977✔
662
}
663

664
static int32_t mndBuildCfgDnodeRedoAction(STrans *pTrans, SDnodeObj *pDnode, SDCfgDnodeReq *pDcfgReq) {
21,033✔
665
  int32_t code = 0;
21,033✔
666
  SEpSet  epSet = mndGetDnodeEpset(pDnode);
21,033✔
667
  int32_t bufLen = tSerializeSDCfgDnodeReq(NULL, 0, pDcfgReq);
21,033✔
668
  void   *pBuf = taosMemoryMalloc(bufLen);
21,033✔
669

670
  if (pBuf == NULL) {
21,033✔
671
    code = terrno;
×
672
    return code;
×
673
  }
674

675
  if ((bufLen = tSerializeSDCfgDnodeReq(pBuf, bufLen, pDcfgReq)) <= 0) {
21,033✔
676
    code = bufLen;
×
677
    taosMemoryFree(pBuf);
×
678
    return code;
×
679
  }
680

681
  STransAction action = {
21,033✔
682
      .epSet = epSet,
683
      .pCont = pBuf,
684
      .contLen = bufLen,
685
      .msgType = TDMT_DND_CONFIG_DNODE,
686
      .acceptableCode = 0,
687
      .groupId = -1,
688
  };
689

690
  mInfo("dnode:%d, append redo action to trans, config:%s value:%s", pDnode->id, pDcfgReq->config, pDcfgReq->value);
21,033✔
691

692
  if ((code = mndTransAppendRedoAction(pTrans, &action)) != 0) {
21,033✔
693
    taosMemoryFree(pBuf);
×
694
    return code;
×
695
  }
696

697
  return code;
21,033✔
698
}
699

700
static int32_t mndSendCfgDnodeReq(SMnode *pMnode, int32_t dnodeId, SDCfgDnodeReq *pDcfgReq) {
70,519✔
701
  int32_t code = -1;
70,519✔
702
  SSdb   *pSdb = pMnode->pSdb;
70,519✔
703
  void   *pIter = NULL;
70,519✔
704

705
  int64_t curMs = taosGetTimestampMs();
70,519✔
706

707
  while (1) {
191,344✔
708
    SDnodeObj *pDnode = NULL;
261,863✔
709
    pIter = sdbFetch(pSdb, SDB_DNODE, pIter, (void **)&pDnode);
261,863✔
710
    if (pIter == NULL) break;
261,863✔
711

712
    if (pDnode->id == dnodeId || dnodeId == -1 || dnodeId == 0) {
191,689✔
713
      bool online = mndIsDnodeOnline(pDnode, curMs);
72,227✔
714
      if (!online) {
72,227✔
715
        mWarn("dnode:%d, is offline, skip to send config req", pDnode->id);
2,880✔
716
        continue;
2,880✔
717
      }
718
      SEpSet  epSet = mndGetDnodeEpset(pDnode);
69,347✔
719
      int32_t bufLen = tSerializeSDCfgDnodeReq(NULL, 0, pDcfgReq);
69,347✔
720
      void   *pBuf = rpcMallocCont(bufLen);
69,347✔
721

722
      if (pBuf == NULL) {
69,347✔
723
        sdbCancelFetch(pMnode->pSdb, pIter);
×
724
        sdbRelease(pMnode->pSdb, pDnode);
×
725
        code = TSDB_CODE_OUT_OF_MEMORY;
×
726
        return code;
×
727
      }
728

729
      if ((bufLen = tSerializeSDCfgDnodeReq(pBuf, bufLen, pDcfgReq)) <= 0) {
69,347✔
730
        sdbCancelFetch(pMnode->pSdb, pIter);
×
731
        sdbRelease(pMnode->pSdb, pDnode);
×
732
        code = bufLen;
×
733
        rpcFreeCont(pBuf);
×
734
        return code;
×
735
      }
736

737
      mInfo("dnode:%d, send config req to dnode, config:%s value:%s", pDnode->id, pDcfgReq->config, pDcfgReq->value);
69,347✔
738
      SRpcMsg rpcMsg = {.msgType = TDMT_DND_CONFIG_DNODE, .pCont = pBuf, .contLen = bufLen};
69,347✔
739
      SRpcMsg rpcRsp = {0};
69,347✔
740

741
      code = rpcSendRecvWithTimeout(pMnode->msgCb.statusRpc, &epSet, &rpcMsg, &rpcRsp, NULL, CFG_ALTER_TIMEOUT);
69,347✔
742
      if (code != 0) {
69,347✔
743
        mError("failed to send config req to dnode:%d, since %s", pDnode->id, tstrerror(code));
×
744
        sdbCancelFetch(pMnode->pSdb, pIter);
×
745
        sdbRelease(pMnode->pSdb, pDnode);
×
746
        return code;
×
747
      }
748

749
      code = rpcRsp.code;
69,347✔
750
      if (code != 0) {
69,347✔
751
        mError("failed to alter config %s,on dnode:%d, since %s", pDcfgReq->config, pDnode->id, tstrerror(code));
345✔
752
        sdbCancelFetch(pMnode->pSdb, pIter);
345✔
753
        sdbRelease(pMnode->pSdb, pDnode);
345✔
754
        return code;
345✔
755
      }
756
      rpcFreeCont(rpcRsp.pCont);
69,002✔
757
    }
758
    sdbRelease(pSdb, pDnode);
188,464✔
759
  }
760

761
  if (code == -1) {
70,174✔
762
    code = TSDB_CODE_MND_DNODE_NOT_EXIST;
1,428✔
763
  }
764
  TAOS_RETURN(code);
70,174✔
765
}
766

767
static int32_t mndProcessConfigDnodeReq(SRpcMsg *pReq) {
118,060✔
768
  int32_t       code = 0;
118,060✔
769
  int32_t       lino = -1;
118,060✔
770
  SMnode       *pMnode = pReq->info.node;
118,060✔
771
  SMCfgDnodeReq cfgReq = {0};
118,060✔
772
  SConfigObj   *vObj = sdbAcquire(pMnode->pSdb, SDB_CFG, "tsmmConfigVersion");
118,060✔
773
  if (vObj == NULL) {
118,060✔
774
    code = TSDB_CODE_SDB_OBJ_NOT_THERE;
×
775
    mInfo("failed to acquire mnd config version, since %s", tstrerror(code));
×
776
    goto _err_out;
×
777
  }
778

779
  TAOS_CHECK_RETURN(tDeserializeSMCfgDnodeReq(pReq->pCont, pReq->contLen, &cfgReq));
118,060✔
780
  int8_t updateWhiteList = 0;
118,060✔
781
  mInfo("dnode:%d, start to config, option:%s, value:%s", cfgReq.dnodeId, cfgReq.config, cfgReq.value);
118,060✔
782
  if ((code = mndCheckOperPrivilege(pMnode, pReq->info.conn.user, MND_OPER_CONFIG_DNODE)) != 0) {
118,060✔
783
    goto _err_out;
2,513✔
784
  }
785

786
  SDCfgDnodeReq dcfgReq = {0};
115,547✔
787
  if (strcasecmp(cfgReq.config, "resetlog") == 0) {
115,547✔
788
    tstrncpy(dcfgReq.config, "resetlog", 9);
493✔
789
    goto _send_req;
493✔
790
#ifdef TD_ENTERPRISE
791
  } else if (strncasecmp(cfgReq.config, "ssblocksize", 12) == 0) {
115,054✔
792
    int32_t optLen = strlen("ssblocksize");
×
793
    int32_t flag = -1;
×
794
    int32_t code = mndMCfgGetValInt32(&cfgReq, optLen, &flag);
×
795
    if (code < 0) {
×
796
      goto _err_out;
×
797
    }
798

799
    if (flag > 1024 * 1024 || (flag > -1 && flag < 1024) || flag < -1) {
×
800
      mError("dnode:%d, failed to config ssblocksize since value:%d. Valid range: -1 or [1024, 1024 * 1024]",
×
801
             cfgReq.dnodeId, flag);
802
      code = TSDB_CODE_INVALID_CFG;
×
803
      goto _err_out;
×
804
    }
805

806
    tstrncpy(dcfgReq.config, "ssblocksize", 12);
×
807
    snprintf(dcfgReq.value, TSDB_DNODE_VALUE_LEN, "%d", flag);
×
808
#endif
809
  } else {
810
    TAOS_CHECK_GOTO(mndMCfg2DCfg(&cfgReq, &dcfgReq), &lino, _err_out);
115,054✔
811
    if (strlen(dcfgReq.config) > TSDB_DNODE_CONFIG_LEN) {
114,077✔
812
      mError("dnode:%d, failed to config since config is too long", cfgReq.dnodeId);
×
813
      code = TSDB_CODE_INVALID_CFG;
×
814
      goto _err_out;
×
815
    }
816
    if (strncasecmp(dcfgReq.config, "enableWhiteList", strlen("enableWhiteList")) == 0) {
114,077✔
817
      updateWhiteList = 1;
544✔
818
    }
819

820
    CfgAlterType alterType = (cfgReq.dnodeId == 0 || cfgReq.dnodeId == -1) ? CFG_ALTER_ALL_DNODES : CFG_ALTER_DNODE;
114,077✔
821
    TAOS_CHECK_GOTO(cfgCheckRangeForDynUpdate(taosGetCfg(), dcfgReq.config, dcfgReq.value, true, alterType), &lino,
114,077✔
822
                    _err_out);
823
  }
824
  SConfigItem *pItem = cfgGetItem(taosGetCfg(), dcfgReq.config);
89,043✔
825
  // Update config in sdb.
826
  if (pItem == NULL) {
89,043✔
827
    mError("failed to find config:%s while process config dnode req", cfgReq.config);
×
828
    code = TSDB_CODE_CFG_NOT_FOUND;
×
829
    goto _err_out;
×
830
  }
831

832
  // Audit log
833
  {
834
    char obj[50] = {0};
89,043✔
835
    (void)tsnprintf(obj, sizeof(obj), "%d", cfgReq.dnodeId);
89,043✔
836
    auditRecord(pReq, pMnode->clusterId, "alterDnode", obj, "", cfgReq.sql, cfgReq.sqlLen);
89,043✔
837
  }
838

839
  dcfgReq.version = vObj->i32 + 1;
89,043✔
840

841
  if (pItem->category == CFG_CATEGORY_GLOBAL) {
89,043✔
842
    // Use transaction to update SDB and send to dnode atomically
843
    TAOS_CHECK_GOTO(mndConfigUpdateTransWithDnode(pMnode, dcfgReq.config, dcfgReq.value, pItem->dtype, dcfgReq.version,
19,017✔
844
                                                  cfgReq.dnodeId, &dcfgReq),
845
                    &lino, _err_out);
846
  } else {
847
    // For local config, still use the old method (only send to dnode)
848
    goto _send_req;
70,026✔
849
  }
850

851
  // For global config, transaction has handled everything, go to success
852
  goto _success;
19,017✔
853

854
_send_req:
70,519✔
855
  dcfgReq.version = vObj->i32;
70,519✔
856
  code = mndSendCfgDnodeReq(pMnode, cfgReq.dnodeId, &dcfgReq);
70,519✔
857
  if (code != 0) {
70,519✔
858
    mError("failed to send config req to dnode:%d, since %s", cfgReq.dnodeId, tstrerror(code));
1,773✔
859
    goto _err_out;
1,773✔
860
  }
861

862
_success:
87,763✔
863
  // dont care suss or succ;
864
  if (updateWhiteList) {
87,763✔
865
    int32_t dummy1 = mndRefreshUserIpWhiteList(pMnode);
272✔
866
    int32_t dummy2 = mndRefreshUserDateTimeWhiteList(pMnode);
272✔
867
    (void)dummy1;
868
    (void)dummy2;
869
  }
870
  tFreeSMCfgDnodeReq(&cfgReq);
87,763✔
871
  sdbRelease(pMnode->pSdb, vObj);
87,763✔
872
  TAOS_RETURN(code);
87,763✔
873

874
_err_out:
30,297✔
875
  mError("failed to process config dnode req, since %s", tstrerror(code));
30,297✔
876
  tFreeSMCfgDnodeReq(&cfgReq);
30,297✔
877
  sdbRelease(pMnode->pSdb, vObj);
30,297✔
878
  TAOS_RETURN(code);
30,297✔
879
}
880

881
static int32_t mndProcessConfigDnodeRsp(SRpcMsg *pRsp) {
×
882
  mInfo("config rsp from dnode");
×
883
  return 0;
×
884
}
885

886
static int32_t mndTryRebuildConfigSdbRsp(SRpcMsg *pRsp) {
267,887✔
887
  mInfo("rebuild config sdb rsp");
267,887✔
888
  return 0;
267,887✔
889
}
890

891
// Helper function to create and commit a config object
892
static int32_t mndCreateAndCommitConfigObj(STrans *pTrans, const char *srcName, const char *cfgName, char *value,
×
893
                                           int32_t *lino) {
894
  int32_t     code = 0;
×
895
  SConfigObj *pTmp = taosMemoryMalloc(sizeof(SConfigObj));
×
896
  if (pTmp == NULL) {
×
897
    code = terrno;
×
898
    return code;
×
899
  }
900

901
  pTmp->dtype = CFG_DTYPE_INT32;
×
902
  tstrncpy(pTmp->name, cfgName, CFG_NAME_MAX_LEN);
×
903
  code = mndUpdateObj(pTmp, srcName, value);
×
904
  if (code != 0) {
×
905
    tFreeSConfigObj(pTmp);
×
906
    taosMemoryFree(pTmp);
×
907
    return code;
×
908
  }
909

910
  code = mndSetCreateConfigCommitLogs(pTrans, pTmp);
×
911
  tFreeSConfigObj(pTmp);
×
912
  taosMemoryFree(pTmp);
×
913
  return code;
×
914
}
915

916
// Helper function to handle syncTimeout related config updates
917
static int32_t mndHandleSyncTimeoutConfigs(STrans *pTrans, const char *srcName, const char *pValue, int32_t *lino) {
×
918
  int32_t code = 0;
×
919
  int32_t syncTimeout = 0;
×
920
  char    tmp[10] = {0};
×
921

922
  if (sscanf(pValue, "%d", &syncTimeout) != 1) {
×
923
    syncTimeout = 0;
×
924
  }
925

926
  int32_t baseTimeout = syncTimeout - syncTimeout / SYNC_TIMEOUT_DIVISOR;
×
927

928
  // arbSetAssignedTimeoutMs = syncTimeout
929
  sprintf(tmp, "%d", syncTimeout);
×
930
  TAOS_CHECK_GOTO(mndCreateAndCommitConfigObj(pTrans, srcName, "arbSetAssignedTimeoutMs", tmp, lino), lino, _OVER);
×
931

932
  // arbHeartBeatIntervalMs = syncTimeout / 4
933
  sprintf(tmp, "%d", syncTimeout / SYNC_TIMEOUT_DIVISOR);
×
934
  TAOS_CHECK_GOTO(mndCreateAndCommitConfigObj(pTrans, srcName, "arbHeartBeatIntervalMs", tmp, lino), lino, _OVER);
×
935

936
  // arbCheckSyncIntervalMs = syncTimeout / 4
937
  TAOS_CHECK_GOTO(mndCreateAndCommitConfigObj(pTrans, srcName, "arbCheckSyncIntervalMs", tmp, lino), lino, _OVER);
×
938

939
  // syncVnodeElectIntervalMs = (syncTimeout - syncTimeout / 4) / 2
940
  sprintf(tmp, "%d", baseTimeout / SYNC_TIMEOUT_ELECT_DIVISOR);
×
941
  TAOS_CHECK_GOTO(mndCreateAndCommitConfigObj(pTrans, srcName, "syncVnodeElectIntervalMs", tmp, lino), lino, _OVER);
×
942

943
  // syncMnodeElectIntervalMs = (syncTimeout - syncTimeout / 4) / 2
944
  TAOS_CHECK_GOTO(mndCreateAndCommitConfigObj(pTrans, srcName, "syncMnodeElectIntervalMs", tmp, lino), lino, _OVER);
×
945

946
  // statusTimeoutMs = (syncTimeout - syncTimeout / 4) / 2
947
  TAOS_CHECK_GOTO(mndCreateAndCommitConfigObj(pTrans, srcName, "statusTimeoutMs", tmp, lino), lino, _OVER);
×
948

949
  // statusSRTimeoutMs = (syncTimeout - syncTimeout / 4) / 4
950
  sprintf(tmp, "%d", baseTimeout / SYNC_TIMEOUT_SR_DIVISOR);
×
951
  TAOS_CHECK_GOTO(mndCreateAndCommitConfigObj(pTrans, srcName, "statusSRTimeoutMs", tmp, lino), lino, _OVER);
×
952

953
  // syncVnodeHeartbeatIntervalMs = (syncTimeout - syncTimeout / 4) / 8
954
  sprintf(tmp, "%d", baseTimeout / SYNC_TIMEOUT_HB_DIVISOR);
×
955
  TAOS_CHECK_GOTO(mndCreateAndCommitConfigObj(pTrans, srcName, "syncVnodeHeartbeatIntervalMs", tmp, lino), lino, _OVER);
×
956

957
  // syncMnodeHeartbeatIntervalMs = (syncTimeout - syncTimeout / 4) / 8
958
  TAOS_CHECK_GOTO(mndCreateAndCommitConfigObj(pTrans, srcName, "syncMnodeHeartbeatIntervalMs", tmp, lino), lino, _OVER);
×
959

960
  // statusIntervalMs = (syncTimeout - syncTimeout / 4) / 8
961
  TAOS_CHECK_GOTO(mndCreateAndCommitConfigObj(pTrans, srcName, "statusIntervalMs", tmp, lino), lino, _OVER);
×
962

963
_OVER:
×
964
  return code;
×
965
}
966

967
// get int32_t value from 'SMCfgDnodeReq'
968
static int32_t mndMCfgGetValInt32(SMCfgDnodeReq *pMCfgReq, int32_t optLen, int32_t *pOutValue) {
×
969
  int32_t code = 0;
×
970
  if (' ' != pMCfgReq->config[optLen] && 0 != pMCfgReq->config[optLen]) {
×
971
    goto _err;
×
972
  }
973

974
  if (' ' == pMCfgReq->config[optLen]) {
×
975
    // 'key value'
976
    if (strlen(pMCfgReq->value) != 0) goto _err;
×
977
    *pOutValue = taosStr2Int32(pMCfgReq->config + optLen + 1, NULL, 10);
×
978
  } else {
979
    // 'key' 'value'
980
    if (strlen(pMCfgReq->value) == 0) goto _err;
×
981
    *pOutValue = taosStr2Int32(pMCfgReq->value, NULL, 10);
×
982
  }
983

984
  TAOS_RETURN(code);
×
985

986
_err:
×
987
  mError(" failed to set config since:%s", tstrerror(code));
×
988
  TAOS_RETURN(code);
×
989
}
990

991
static int32_t mndConfigUpdateTrans(SMnode *pMnode, const char *name, char *pValue, ECfgDataType dtype,
×
992
                                    int32_t tsmmConfigVersion) {
993
  int32_t     code = -1;
×
994
  int32_t     lino = -1;
×
995
  SConfigObj *pVersion = taosMemoryMalloc(sizeof(SConfigObj)), *pObj = taosMemoryMalloc(sizeof(SConfigObj));
×
996
  if (pVersion == NULL || pObj == NULL) {
×
997
    code = terrno;
×
998
    goto _OVER;
×
999
  }
1000
  tstrncpy(pVersion->name, "tsmmConfigVersion", CFG_NAME_MAX_LEN);
×
1001
  pVersion->dtype = CFG_DTYPE_INT32;
×
1002
  pVersion->i32 = tsmmConfigVersion;
×
1003

1004
  pObj->dtype = dtype;
×
1005
  tstrncpy(pObj->name, name, CFG_NAME_MAX_LEN);
×
1006

1007
  TAOS_CHECK_GOTO(mndUpdateObj(pObj, name, pValue), &lino, _OVER);
×
1008
  STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, NULL, "update-config");
×
1009
  if (pTrans == NULL) {
×
1010
    code = terrno;
×
1011
    goto _OVER;
×
1012
  }
1013
  mInfo("trans:%d, used to update config:%s to value:%s", pTrans->id, name, pValue);
×
1014
  TAOS_CHECK_GOTO(mndSetCreateConfigCommitLogs(pTrans, pVersion), &lino, _OVER);
×
1015
  TAOS_CHECK_GOTO(mndSetCreateConfigCommitLogs(pTrans, pObj), &lino, _OVER);
×
1016

1017
  if (taosStrncasecmp(name, "syncTimeout", CFG_NAME_MAX_LEN) == 0) {
×
1018
    TAOS_CHECK_GOTO(mndHandleSyncTimeoutConfigs(pTrans, name, pValue, &lino), &lino, _OVER);
×
1019
  }
1020
  if ((code = mndTransPrepare(pMnode, pTrans)) != 0) goto _OVER;
×
1021
  code = 0;
×
1022
_OVER:
×
1023
  if (code != 0) {
×
1024
    mError("failed to update config:%s to value:%s, since %s", name, pValue, tstrerror(code));
×
1025
  }
1026
  mndTransDrop(pTrans);
×
1027
  tFreeSConfigObj(pVersion);
×
1028
  taosMemoryFree(pVersion);
×
1029
  tFreeSConfigObj(pObj);
×
1030
  taosMemoryFree(pObj);
×
1031
  return code;
×
1032
}
1033

1034
static int32_t mndConfigUpdateTransWithDnode(SMnode *pMnode, const char *name, char *pValue, ECfgDataType dtype,
19,017✔
1035
                                             int32_t tsmmConfigVersion, int32_t dnodeId, SDCfgDnodeReq *pDcfgReq) {
1036
  int32_t     code = -1;
19,017✔
1037
  int32_t     lino = -1;
19,017✔
1038
  SConfigObj *pVersion = taosMemoryMalloc(sizeof(SConfigObj)), *pObj = taosMemoryMalloc(sizeof(SConfigObj));
19,017✔
1039
  if (pVersion == NULL || pObj == NULL) {
19,017✔
1040
    code = terrno;
×
1041
    goto _OVER;
×
1042
  }
1043
  tstrncpy(pVersion->name, "tsmmConfigVersion", CFG_NAME_MAX_LEN);
19,017✔
1044
  pVersion->dtype = CFG_DTYPE_INT32;
19,017✔
1045
  pVersion->i32 = tsmmConfigVersion;
19,017✔
1046

1047
  pObj->dtype = dtype;
19,017✔
1048
  tstrncpy(pObj->name, name, CFG_NAME_MAX_LEN);
19,017✔
1049

1050
  TAOS_CHECK_GOTO(mndUpdateObj(pObj, name, pValue), &lino, _OVER);
19,017✔
1051
  STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, NULL, "update-config-with-dnode");
19,017✔
1052
  if (pTrans == NULL) {
19,017✔
1053
    code = terrno;
×
1054
    goto _OVER;
×
1055
  }
1056
  mInfo("trans:%d, used to update config:%s to value:%s and send to dnode", pTrans->id, name, pValue);
19,017✔
1057

1058
  // Add prepare logs for SDB config updates (execute in PREPARE stage, before redo actions)
1059
  TAOS_CHECK_GOTO(mndSetCreateConfigPrepareLogs(pTrans, pVersion), &lino, _OVER);
19,017✔
1060
  TAOS_CHECK_GOTO(mndSetCreateConfigPrepareLogs(pTrans, pObj), &lino, _OVER);
19,017✔
1061

1062
  // Add commit logs for transaction persistence
1063
  TAOS_CHECK_GOTO(mndSetCreateConfigCommitLogs(pTrans, pVersion), &lino, _OVER);
19,017✔
1064
  TAOS_CHECK_GOTO(mndSetCreateConfigCommitLogs(pTrans, pObj), &lino, _OVER);
19,017✔
1065

1066
  if (taosStrncasecmp(name, "syncTimeout", CFG_NAME_MAX_LEN) == 0) {
19,017✔
1067
    TAOS_CHECK_GOTO(mndHandleSyncTimeoutConfigs(pTrans, name, pValue, &lino), &lino, _OVER);
×
1068
  }
1069

1070
  // Add redo actions to send config to dnodes
1071
  SSdb   *pSdb = pMnode->pSdb;
19,017✔
1072
  void   *pIter = NULL;
19,017✔
1073
  int64_t curMs = taosGetTimestampMs();
19,017✔
1074

1075
  while (1) {
21,033✔
1076
    SDnodeObj *pDnode = NULL;
40,050✔
1077
    pIter = sdbFetch(pSdb, SDB_DNODE, pIter, (void **)&pDnode);
40,050✔
1078
    if (pIter == NULL) break;
40,050✔
1079

1080
    if (pDnode->id == dnodeId || dnodeId == -1 || dnodeId == 0) {
21,033✔
1081
      bool online = mndIsDnodeOnline(pDnode, curMs);
21,033✔
1082
      if (!online) {
21,033✔
1083
        mWarn("dnode:%d, is offline, still add to trans for retry", pDnode->id);
576✔
1084
      }
1085

1086
      code = mndBuildCfgDnodeRedoAction(pTrans, pDnode, pDcfgReq);
21,033✔
1087
      if (code != 0) {
21,033✔
1088
        mError("failed to build config redo action for dnode:%d, since %s", pDnode->id, tstrerror(code));
×
1089
        sdbCancelFetch(pMnode->pSdb, pIter);
×
1090
        sdbRelease(pMnode->pSdb, pDnode);
×
1091
        goto _OVER;
×
1092
      }
1093
    }
1094
    sdbRelease(pSdb, pDnode);
21,033✔
1095
  }
1096

1097
  if ((code = mndTransPrepare(pMnode, pTrans)) != 0) goto _OVER;
19,017✔
1098
  code = 0;
19,017✔
1099

1100
_OVER:
19,017✔
1101
  if (code != 0) {
19,017✔
1102
    mError("failed to update config:%s to value:%s and send to dnode, since %s", name, pValue, tstrerror(code));
×
1103
  }
1104
  mndTransDrop(pTrans);
19,017✔
1105
  tFreeSConfigObj(pVersion);
19,017✔
1106
  taosMemoryFree(pVersion);
19,017✔
1107
  tFreeSConfigObj(pObj);
19,017✔
1108
  taosMemoryFree(pObj);
19,017✔
1109
  return code;
19,017✔
1110
}
1111

1112
static int32_t initConfigArrayFromSdb(SMnode *pMnode, SArray *array) {
531,485✔
1113
  int32_t     code = 0;
531,485✔
1114
  SSdb       *pSdb = pMnode->pSdb;
531,485✔
1115
  void       *pIter = NULL;
531,485✔
1116
  SConfigObj *obj = NULL;
531,485✔
1117

1118
  while (1) {
56,868,895✔
1119
    pIter = sdbFetch(pSdb, SDB_CFG, pIter, (void **)&obj);
57,400,380✔
1120
    if (pIter == NULL) break;
57,400,380✔
1121
    if (obj == NULL) {
56,868,895✔
1122
      code = TSDB_CODE_OUT_OF_MEMORY;
×
1123
      goto _exit;
×
1124
    }
1125
    if (strcasecmp(obj->name, "tsmmConfigVersion") == 0) {
56,868,895✔
1126
      sdbRelease(pSdb, obj);
531,485✔
1127
      continue;
531,485✔
1128
    }
1129
    SConfigItem item = {0};
56,337,410✔
1130
    item.dtype = obj->dtype;
56,337,410✔
1131
    item.name = taosStrdup(obj->name);
56,337,410✔
1132
    if (item.name == NULL) {
56,337,410✔
1133
      code = terrno;
×
1134
      sdbCancelFetch(pSdb, pIter);
×
1135
      sdbRelease(pSdb, obj);
×
1136
      goto _exit;
×
1137
    }
1138
    switch (obj->dtype) {
56,337,410✔
1139
      case CFG_DTYPE_NONE:
×
1140
        break;
×
1141
      case CFG_DTYPE_BOOL:
11,161,185✔
1142
        item.bval = obj->bval;
11,161,185✔
1143
        break;
11,161,185✔
1144
      case CFG_DTYPE_INT32:
30,826,130✔
1145
        item.i32 = obj->i32;
30,826,130✔
1146
        break;
30,826,130✔
1147
      case CFG_DTYPE_INT64:
3,188,910✔
1148
        item.i64 = obj->i64;
3,188,910✔
1149
        break;
3,188,910✔
1150
      case CFG_DTYPE_FLOAT:
1,062,970✔
1151
      case CFG_DTYPE_DOUBLE:
1152
        item.fval = obj->fval;
1,062,970✔
1153
        break;
1,062,970✔
1154
      case CFG_DTYPE_STRING:
10,098,215✔
1155
      case CFG_DTYPE_DIR:
1156
      case CFG_DTYPE_LOCALE:
1157
      case CFG_DTYPE_CHARSET:
1158
      case CFG_DTYPE_TIMEZONE:
1159
        item.str = taosStrdup(obj->str);
10,098,215✔
1160
        if (item.str == NULL) {
10,098,215✔
1161
          sdbCancelFetch(pSdb, pIter);
×
1162
          sdbRelease(pSdb, obj);
×
1163
          code = terrno;
×
1164
          goto _exit;
×
1165
        }
1166
        break;
10,098,215✔
1167
    }
1168
    if (taosArrayPush(array, &item) == NULL) {
56,337,410✔
1169
      sdbCancelFetch(pSdb, pIter);
×
1170
      sdbRelease(pSdb, obj);
×
1171
      code = TSDB_CODE_OUT_OF_MEMORY;
×
1172
      goto _exit;
×
1173
      break;
1174
    }
1175
    sdbRelease(pSdb, obj);
56,337,410✔
1176
  }
1177
_exit:
531,485✔
1178
  if (code != 0) {
531,485✔
1179
    mError("failed to init config array from sdb, since %s", tstrerror(code));
×
1180
  }
1181
  return code;
531,485✔
1182
}
1183

1184
static void cfgArrayCleanUp(SArray *array) {
703,538✔
1185
  if (array == NULL) {
703,538✔
1186
    return;
×
1187
  }
1188

1189
  int32_t sz = taosArrayGetSize(array);
703,538✔
1190
  for (int32_t i = 0; i < sz; ++i) {
57,040,948✔
1191
    SConfigItem *item = taosArrayGet(array, i);
56,337,410✔
1192
    if (item->dtype == CFG_DTYPE_STRING || item->dtype == CFG_DTYPE_DIR || item->dtype == CFG_DTYPE_LOCALE ||
56,337,410✔
1193
        item->dtype == CFG_DTYPE_CHARSET || item->dtype == CFG_DTYPE_TIMEZONE) {
47,302,165✔
1194
      taosMemoryFreeClear(item->str);
10,098,215✔
1195
    }
1196
    taosMemoryFreeClear(item->name);
56,337,410✔
1197
  }
1198

1199
  taosArrayDestroy(array);
703,538✔
1200
}
1201

1202
static void cfgObjArrayCleanUp(SArray *array) {
535,734✔
1203
  if (array == NULL) {
535,734✔
1204
    return;
×
1205
  }
1206
  int32_t sz = taosArrayGetSize(array);
535,734✔
1207
  for (int32_t i = 0; i < sz; ++i) {
535,734✔
1208
    SConfigObj *obj = taosArrayGet(array, i);
×
1209
    tFreeSConfigObj(obj);
×
1210
  }
1211
  taosArrayDestroy(array);
535,734✔
1212
}
1213

1214
static SArray *initVariablesFromItems(SArray *pItems, const char* likePattern) {
56,376✔
1215
  if (pItems == NULL) {
56,376✔
1216
    return NULL;
×
1217
  }
1218

1219
  int32_t sz = taosArrayGetSize(pItems);
56,376✔
1220

1221
  SArray *pInfos = taosArrayInit(sz, sizeof(SVariablesInfo));
56,376✔
1222
  if (pInfos == NULL) {
56,376✔
1223
    mError("failed to init array while init variables from items, since %s", tstrerror(terrno));
×
1224
    return NULL;
×
1225
  }
1226
  for (int32_t i = 0; i < sz; ++i) {
6,032,232✔
1227
    SConfigItem   *pItem = taosArrayGet(pItems, i);
5,975,856✔
1228
    SVariablesInfo info = {0};
5,975,856✔
1229
    tstrncpy(info.name, pItem->name, sizeof(info.name));
5,975,856✔
1230
    if (likePattern != NULL && rawStrPatternMatch(pItem->name, likePattern) != TSDB_PATTERN_MATCH) {
5,975,856✔
1231
      continue;
454,180✔
1232
    }
1233

1234
    // init info value
1235
    switch (pItem->dtype) {
5,521,676✔
1236
      case CFG_DTYPE_NONE:
×
1237
        break;
×
1238
      case CFG_DTYPE_BOOL:
1,092,568✔
1239
        tsnprintf(info.value, sizeof(info.value), "%d", pItem->bval);
1,092,568✔
1240
        break;
1,092,568✔
1241
      case CFG_DTYPE_INT32:
3,024,324✔
1242
        tsnprintf(info.value, sizeof(info.value), "%d", pItem->i32);
3,024,324✔
1243
        break;
3,024,324✔
1244
      case CFG_DTYPE_INT64:
311,928✔
1245
        tsnprintf(info.value, sizeof(info.value), "%" PRId64, pItem->i64);
311,928✔
1246
        break;
311,928✔
1247
      case CFG_DTYPE_FLOAT:
103,976✔
1248
      case CFG_DTYPE_DOUBLE:
1249
        tsnprintf(info.value, sizeof(info.value), "%f", pItem->fval);
103,976✔
1250
        break;
103,976✔
1251
      case CFG_DTYPE_STRING:
988,880✔
1252
      case CFG_DTYPE_DIR:
1253
      case CFG_DTYPE_LOCALE:
1254
      case CFG_DTYPE_CHARSET:
1255
      case CFG_DTYPE_TIMEZONE:
1256
        tsnprintf(info.value, sizeof(info.value), "%s", pItem->str);
988,880✔
1257
        break;
988,880✔
1258
    }
1259

1260
    // init info scope
1261
    switch (pItem->scope) {
5,521,676✔
1262
      case CFG_SCOPE_SERVER:
4,429,640✔
1263
        tstrncpy(info.scope, "server", sizeof(info.scope));
4,429,640✔
1264
        break;
4,429,640✔
1265
      case CFG_SCOPE_CLIENT:
×
1266
        tstrncpy(info.scope, "client", sizeof(info.scope));
×
1267
        break;
×
1268
      case CFG_SCOPE_BOTH:
1,092,036✔
1269
        tstrncpy(info.scope, "both", sizeof(info.scope));
1,092,036✔
1270
        break;
1,092,036✔
1271
      default:
×
1272
        tstrncpy(info.scope, "unknown", sizeof(info.scope));
×
1273
        break;
×
1274
    }
1275
    // init info category
1276
    switch (pItem->category) {
5,521,676✔
1277
      case CFG_CATEGORY_GLOBAL:
5,521,676✔
1278
        tstrncpy(info.category, "global", sizeof(info.category));
5,521,676✔
1279
        break;
5,521,676✔
1280
      case CFG_CATEGORY_LOCAL:
×
1281
        tstrncpy(info.category, "local", sizeof(info.category));
×
1282
        break;
×
1283
      default:
×
1284
        tstrncpy(info.category, "unknown", sizeof(info.category));
×
1285
        break;
×
1286
    }
1287
    if (NULL == taosArrayPush(pInfos, &info)) {
5,521,676✔
1288
      mError("failed to push info to array while init variables from items,since %s", tstrerror(terrno));
×
1289
      taosArrayDestroy(pInfos);
×
1290
      return NULL;
×
1291
    }
1292
  }
1293

1294
  return pInfos;
56,376✔
1295
}
1296

1297
static int32_t mndProcessShowVariablesReq(SRpcMsg *pReq) {
56,376✔
1298
  SShowVariablesRsp rsp = {0};
56,376✔
1299
  int32_t           code = TSDB_CODE_SUCCESS;
56,376✔
1300
  SShowVariablesReq req = {0};
56,376✔
1301
  SArray           *array = NULL;
56,376✔
1302

1303
  code = tDeserializeSShowVariablesReq(pReq->pCont, pReq->contLen, &req);
56,376✔
1304
  if (code != 0) {
56,376✔
1305
    mError("failed to deserialize config req, since %s", terrstr());
×
1306
    goto _OVER;
×
1307
  }
1308

1309
  if ((code = mndCheckOperPrivilege(pReq->info.node, pReq->info.conn.user, MND_OPER_SHOW_VARIABLES)) != 0) {
56,376✔
1310
    goto _OVER;
×
1311
  }
1312

1313
  SVariablesInfo info = {0};
56,376✔
1314
  char          *likePattern = req.opType == OP_TYPE_LIKE ? req.val : NULL;
56,376✔
1315
  rsp.variables = initVariablesFromItems(taosGetGlobalCfg(tsCfg), likePattern);
56,376✔
1316
  if (rsp.variables == NULL) {
56,376✔
1317
    code = terrno;
×
1318
    goto _OVER;
×
1319
  }
1320
  int32_t rspLen = tSerializeSShowVariablesRsp(NULL, 0, &rsp);
56,376✔
1321
  void   *pRsp = rpcMallocCont(rspLen);
56,376✔
1322
  if (pRsp == NULL) {
56,376✔
1323
    code = terrno;
×
1324
    goto _OVER;
×
1325
  }
1326

1327
  if ((rspLen = tSerializeSShowVariablesRsp(pRsp, rspLen, &rsp)) <= 0) {
56,376✔
1328
    rpcFreeCont(pRsp);
×
1329
    code = rspLen;
×
1330
    goto _OVER;
×
1331
  }
1332

1333
  pReq->info.rspLen = rspLen;
56,376✔
1334
  pReq->info.rsp = pRsp;
56,376✔
1335
  code = 0;
56,376✔
1336

1337
_OVER:
56,376✔
1338

1339
  if (code != 0) {
56,376✔
1340
    mError("failed to get show variables info since %s", tstrerror(code));
×
1341
  }
1342
  tFreeSShowVariablesReq(&req);
56,376✔
1343
  tFreeSShowVariablesRsp(&rsp);
56,376✔
1344
  TAOS_RETURN(code);
56,376✔
1345
}
1346

1347
int32_t compareSConfigItem(const SConfigObj *item1, SConfigItem *item2, bool *compare) {
×
1348
  *compare = true;
×
1349
  switch (item1->dtype) {
×
1350
    case CFG_DTYPE_BOOL:
×
1351
      if (item1->bval != item2->bval) {
×
1352
        item2->bval = item1->bval;
×
1353
        *compare = false;
×
1354
      }
1355
      break;
×
1356
    case CFG_DTYPE_FLOAT:
×
1357
      if (item1->fval != item2->fval) {
×
1358
        item2->fval = item1->fval;
×
1359
        *compare = false;
×
1360
      }
1361
      break;
×
1362
    case CFG_DTYPE_INT32:
×
1363
      if (item1->i32 != item2->i32) {
×
1364
        item2->i32 = item1->i32;
×
1365
        *compare = false;
×
1366
      }
1367
      break;
×
1368
    case CFG_DTYPE_INT64:
×
1369
      if (item1->i64 != item2->i64) {
×
1370
        item2->i64 = item1->i64;
×
1371
        *compare = false;
×
1372
      }
1373
      break;
×
1374
    case CFG_DTYPE_STRING:
×
1375
    case CFG_DTYPE_DIR:
1376
    case CFG_DTYPE_LOCALE:
1377
    case CFG_DTYPE_CHARSET:
1378
    case CFG_DTYPE_TIMEZONE:
1379
      if (strcmp(item1->str, item2->str) != 0) {
×
1380
        item2->str = taosStrdup(item1->str);
×
1381
        if (item2->str == NULL) {
×
1382
          return TSDB_CODE_OUT_OF_MEMORY;
×
1383
        }
1384
        *compare = false;
×
1385
      }
1386
      break;
×
1387
    default:
×
1388
      *compare = false;
×
1389
      return TSDB_CODE_INVALID_CFG;
×
1390
  }
1391
  return TSDB_CODE_SUCCESS;
×
1392
}
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