tglobal.c 33.7 KB
Newer Older
S
slguan 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
/*
 * Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
 *
 * This program is free software: you can use, redistribute, and/or modify
 * it under the terms of the GNU Affero General Public License, version 3
 * or later ("AGPL"), as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

#define _DEFAULT_SOURCE
#include "os.h"
S
Shengliang Guan 已提交
18

S
slguan 已提交
19 20
#include "taosdef.h"
#include "taoserror.h"
S
Shengliang Guan 已提交
21
#include "tcompare.h"
S
slguan 已提交
22
#include "tconfig.h"
S
Shengliang Guan 已提交
23
#include "tep.h"
S
slguan 已提交
24
#include "tglobal.h"
S
Shengliang Guan 已提交
25
#include "tlocale.h"
S
Shengliang Guan 已提交
26 27 28 29
#include "tlog.h"
#include "ttimezone.h"
#include "tutil.h"
#include "ulog.h"
S
slguan 已提交
30

S
Shengliang Guan 已提交
31 32 33 34 35
// cluster
char     tsFirst[TSDB_EP_LEN] = {0};
char     tsSecond[TSDB_EP_LEN] = {0};
char     tsLocalFqdn[TSDB_FQDN_LEN] = {0};
char     tsLocalEp[TSDB_EP_LEN] = {0};  // Local End Point, hostname:port
J
jtao1735 已提交
36
uint16_t tsServerPort = 6030;
S
Shengliang Guan 已提交
37
int32_t  tsStatusInterval = 1;  // second
S
Shengliang Guan 已提交
38
int8_t   tsEnableTelemetryReporting = 0;
H
Hui Li 已提交
39
char     tsEmail[TSDB_FQDN_LEN] = {0};
S
Shengliang Guan 已提交
40
int32_t  tsNumOfSupportVnodes = 128;
H
Hui Li 已提交
41

S
Shengliang Guan 已提交
42
// common
S
Shengliang Guan 已提交
43 44 45 46
int32_t tsRpcTimer = 300;
int32_t tsRpcMaxTime = 600;  // seconds;
int32_t tsRpcForceTcp = 1;   // disable this, means query, show command use udp protocol as default
int32_t tsMaxShellConns = 50000;
S
Shengliang 已提交
47
int32_t tsMaxConnections = 50000;
S
Shengliang Guan 已提交
48
int32_t tsShellActivityTimer = 3;  // second
H
Haojun Liao 已提交
49
float   tsNumOfThreadsPerCore = 1.0f;
50
int32_t tsNumOfCommitThreads = 4;
51
float   tsRatioOfQueryCores = 1.0f;
S
Shengliang Guan 已提交
52
int8_t  tsDaylight = 0;
S
Shengliang Guan 已提交
53
int8_t  tsEnableCoreFile = 0;
S
Shengliang Guan 已提交
54
int32_t tsMaxBinaryDisplayWidth = 30;
S
Shengliang Guan 已提交
55 56 57
int8_t  tsEnableSlaveQuery = 1;
int8_t  tsEnableAdjustMaster = 1;
int8_t  tsPrintAuth = 0;
S
Shengliang Guan 已提交
58 59 60 61 62 63 64 65
/*
 * denote if the server needs to compress response message at the application layer to client, including query rsp,
 * metricmeta rsp, and multi-meter query rsp message body. The client compress the submit message to server.
 *
 * 0: all data are compressed
 * -1: all data are not compressed
 * other values: if the message payload size is greater than the tsCompressMsgSize, the message will be compressed.
 */
D
dapan1121 已提交
66
int32_t tsCompressMsgSize = -1;
S
Shengliang Guan 已提交
67

68
/* denote if server needs to compress the retrieved column data before adding to the rpc response message body.
69 70
 * 0: all data are compressed
 * -1: all data are not compressed
71
 * other values: if any retrieved column size is greater than the tsCompressColData, all data will be compressed.
72
 */
73
int32_t tsCompressColData = -1;
74

75 76 77 78 79
/*
 * denote if 3.0 query pattern compatible for 2.0
 */
int32_t tsCompatibleModel = 1;

S
Shengliang Guan 已提交
80
// client
81
int32_t tsMaxWildCardsLen = TSDB_PATTERN_STRING_DEFAULT_LEN;
82 83
int32_t tsMaxRegexStringLen = TSDB_REGEX_STRING_DEFAULT_LEN;

S
Shengliang Guan 已提交
84
int8_t tsTscEnableRecordSql = 0;
S
slguan 已提交
85

S
Shengliang Guan 已提交
86 87 88 89 90 91 92
// the maximum number of results for projection query on super table that are returned from
// one virtual node, to order according to timestamp
int32_t tsMaxNumOfOrderedResults = 100000;

// 10 ms for sliding time, the value will changed in case of time precision changed
int32_t tsMinSlidingTime = 10;

93
// the maxinum number of distict query result
S
Shengliang Guan 已提交
94
int32_t tsMaxNumOfDistinctResults = 1000 * 10000;
95

96 97
// 1 us for interval time range, changed accordingly
int32_t tsMinIntervalTime = 1;
S
Shengliang Guan 已提交
98 99 100 101 102 103 104 105

// 20sec, the maximum value of stream computing delay, changed accordingly
int32_t tsMaxStreamComputDelay = 20000;

// 10sec, the first stream computing delay time after system launched successfully, changed accordingly
int32_t tsStreamCompStartDelay = 10000;

// the stream computing delay time after executing failed, change accordingly
S
Shengliang Guan 已提交
106
int32_t tsRetryStreamCompDelay = 10 * 1000;
S
Shengliang Guan 已提交
107 108

// The delayed computing ration. 10% of the whole computing time window by default.
109
float tsStreamComputDelayRatio = 0.1f;
S
Shengliang Guan 已提交
110 111 112 113

int32_t tsProjectExecInterval = 10000;   // every 10sec, the projection will be executed once
int64_t tsMaxRetentWindow = 24 * 3600L;  // maximum time window tolerance

H
Haojun Liao 已提交
114 115 116 117 118
// the maximum allowed query buffer size during query processing for each data node.
// -1 no limit (default)
// 0  no query allowed, queries are disabled
// positive value (in MB)
int32_t tsQueryBufferSize = -1;
119
int64_t tsQueryBufferSizeBytes = -1;
H
Haojun Liao 已提交
120

H
Haojun Liao 已提交
121 122
// in retrieve blocking model, the retrieve threads will wait for the completion of the query processing.
int32_t tsRetrieveBlockingModel = 0;
123

124
// last_row(*), first(*), last_row(ts, col1, col2) query, the result fields will be the original column name
S
Shengliang Guan 已提交
125 126 127 128
int8_t tsKeepOriginalColumnName = 0;

// long query death-lock
int8_t tsDeadLockKillQuery = 0;
129

S
Shengliang Guan 已提交
130
// tsdb config
Y
yihaoDeng 已提交
131 132 133
// For backward compatibility
bool tsdbForceKeepFile = false;

S
Shengliang Guan 已提交
134
int32_t tsDiskCfgNum = 0;
S
TD-1767  
Shengliang Guan 已提交
135 136 137 138

#ifndef _STORAGE
SDiskCfg tsDiskCfg[1];
#else
S
Shengliang Guan 已提交
139
SDiskCfg tsDiskCfg[TFS_MAX_DISKS];
S
TD-1767  
Shengliang Guan 已提交
140
#endif
S
Shengliang Guan 已提交
141 142 143 144 145 146 147

/*
 * minimum scale for whole system, millisecond by default
 * for TSDB_TIME_PRECISION_MILLI: 86400000L
 *     TSDB_TIME_PRECISION_MICRO: 86400000000L
 *     TSDB_TIME_PRECISION_NANO:  86400000000000L
 */
148
int64_t tsTickPerDay[] = {86400000L, 86400000000L, 86400000000000L};
S
Shengliang Guan 已提交
149 150

// system info
S
Shengliang Guan 已提交
151 152 153 154 155 156 157 158
float    tsTotalTmpDirGB = 0;
float    tsTotalDataDirGB = 0;
float    tsAvailTmpDirectorySpace = 0;
float    tsAvailDataDirGB = 0;
float    tsUsedDataDirGB = 0;
float    tsReservedTmpDirectorySpace = 1.0f;
float    tsMinimalDataDirGB = 2.0f;
int32_t  tsTotalMemoryMB = 0;
159
uint32_t tsVersion = 0;
S
slguan 已提交
160

T
tickduan 已提交
161 162 163
//
// lossy compress 6
//
S
Shengliang Guan 已提交
164 165 166 167 168 169 170 171
char tsLossyColumns[32] = "";  // "float|double" means all float and double columns can be lossy compressed.  set empty
                               // can close lossy compress.
// below option can take effect when tsLossyColumns not empty
double   tsFPrecision = 1E-8;                   // float column precision
double   tsDPrecision = 1E-16;                  // double column precision
uint32_t tsMaxRange = 500;                      // max range
uint32_t tsCurRange = 100;                      // range
char     tsCompressor[32] = "ZSTD_COMPRESSOR";  // ZSTD_COMPRESSOR or GZIP_COMPRESSOR
T
tickduan 已提交
172

173

S
Shengliang Guan 已提交
174 175 176
int32_t (*monStartSystemFp)() = NULL;
void (*monStopSystemFp)() = NULL;
void (*monExecuteSQLFp)(char *sql) = NULL;
177

S
Shengliang Guan 已提交
178 179
char *qtypeStr[] = {"rpc", "fwd", "wal", "cq", "query"};

S
slguan 已提交
180 181 182
static pthread_once_t tsInitGlobalCfgOnce = PTHREAD_ONCE_INIT;

void taosSetAllDebugFlag() {
S
Shengliang Guan 已提交
183
  if (debugFlag != 0) {
guanshengliang's avatar
guanshengliang 已提交
184
    mDebugFlag = debugFlag;
guanshengliang's avatar
guanshengliang 已提交
185 186
    dDebugFlag = debugFlag;
    vDebugFlag = debugFlag;
guanshengliang's avatar
guanshengliang 已提交
187
    jniDebugFlag = debugFlag;
S
Shengliang Guan 已提交
188
    qDebugFlag = debugFlag;
guanshengliang's avatar
guanshengliang 已提交
189 190 191
    rpcDebugFlag = debugFlag;
    uDebugFlag = debugFlag;
    sDebugFlag = debugFlag;
S
Shengliang Guan 已提交
192
    wDebugFlag = debugFlag;
193
    tsdbDebugFlag = debugFlag;
S
TD-1520  
Shengliang Guan 已提交
194
    cqDebugFlag = debugFlag;
S
Shengliang Guan 已提交
195
    uInfo("all debug flag are set to %d", debugFlag);
S
slguan 已提交
196 197 198
  }
}

S
Shengliang Guan 已提交
199
int32_t taosCfgDynamicOptions(char *msg) {
S
Shengliang Guan 已提交
200 201 202
  char   *option, *value;
  int32_t olen, vlen;
  int32_t vint = 0;
S
slguan 已提交
203 204

  paGetToken(msg, &option, &olen);
S
Shengliang Guan 已提交
205
  if (olen == 0) return -1;
S
slguan 已提交
206 207 208 209 210 211 212 213

  paGetToken(option + olen + 1, &value, &vlen);
  if (vlen == 0)
    vint = 135;
  else {
    vint = atoi(value);
  }

214
  uInfo("change dynamic option: %s, value: %d", option, vint);
S
slguan 已提交
215 216 217

  for (int32_t i = 0; i < tsGlobalConfigNum; ++i) {
    SGlobalCfg *cfg = tsGlobalConfig + i;
S
Shengliang Guan 已提交
218
    // if (!(cfg->cfgType & TSDB_CFG_CTYPE_B_LOG)) continue;
S
Shengliang Guan 已提交
219
    if (cfg->valType != TAOS_CFG_VTYPE_INT32 && cfg->valType != TAOS_CFG_VTYPE_INT8) continue;
S
Shengliang Guan 已提交
220

S
Shengliang Guan 已提交
221
    int32_t cfgLen = (int32_t)strlen(cfg->option);
222
    if (cfgLen != olen) continue;
T
tickduan 已提交
223 224 225 226 227 228
    if (strncasecmp(option, cfg->option, olen) != 0) continue;
    if (cfg->valType == TAOS_CFG_VTYPE_INT32) {
      *((int32_t *)cfg->ptr) = vint;
    } else {
      *((int8_t *)cfg->ptr) = (int8_t)vint;
    }
T
tickduan 已提交
229

S
slguan 已提交
230
    if (strncasecmp(cfg->option, "monitor", olen) == 0) {
231
      if (1 == vint) {
S
Shengliang Guan 已提交
232 233
        if (monStartSystemFp) {
          (*monStartSystemFp)();
234
          uInfo("monitor is enabled");
235 236
        } else {
          uError("monitor can't be updated, for monitor not initialized");
237 238
        }
      } else {
S
Shengliang Guan 已提交
239 240
        if (monStopSystemFp) {
          (*monStopSystemFp)();
241
          uInfo("monitor is disabled");
242 243
        } else {
          uError("monitor can't be updated, for monitor not initialized");
244 245
        }
      }
S
Shengliang Guan 已提交
246
      return 0;
S
slguan 已提交
247
    }
Y
yihaoDeng 已提交
248
    if (strncasecmp(cfg->option, "debugFlag", olen) == 0) {
S
Shengliang Guan 已提交
249
      taosSetAllDebugFlag();
Y
yihaoDeng 已提交
250
    }
S
Shengliang Guan 已提交
251
    return 0;
S
slguan 已提交
252 253 254 255
  }

  if (strncasecmp(option, "resetlog", 8) == 0) {
    taosResetLog();
256
    taosPrintCfg();
S
Shengliang Guan 已提交
257
    return 0;
S
slguan 已提交
258 259 260
  }

  if (strncasecmp(option, "resetQueryCache", 15) == 0) {
S
Shengliang Guan 已提交
261 262
    if (monExecuteSQLFp) {
      (*monExecuteSQLFp)("resetQueryCache");
263 264 265 266
      uInfo("resetquerycache is executed");
    } else {
      uError("resetquerycache can't be executed, for monitor not started");
    }
S
slguan 已提交
267 268 269 270 271
  }

  return false;
}

S
TD-1767  
Shengliang Guan 已提交
272 273 274 275 276 277 278 279 280
void taosAddDataDir(int index, char *v1, int level, int primary) {
  tstrncpy(tsDiskCfg[index].dir, v1, TSDB_FILENAME_LEN);
  tsDiskCfg[index].level = level;
  tsDiskCfg[index].primary = primary;
  uTrace("dataDir:%s, level:%d primary:%d is configured", v1, level, primary);
}

#ifndef _STORAGE
void taosReadDataDirCfg(char *v1, char *v2, char *v3) {
S
TD-1767  
Shengliang Guan 已提交
281 282 283 284 285 286
  if (tsDiskCfgNum == 1) {
    SDiskCfg *cfg = &tsDiskCfg[0];
    uInfo("dataDir:%s, level:%d primary:%d is replaced by %s", cfg->dir, cfg->level, cfg->primary, v1);
  }
  taosAddDataDir(0, v1, 0, 1);
  tsDiskCfgNum = 1;
S
TD-1767  
Shengliang Guan 已提交
287 288 289 290 291
}

void taosPrintDataDirCfg() {
  for (int i = 0; i < tsDiskCfgNum; ++i) {
    SDiskCfg *cfg = &tsDiskCfg[i];
S
TD-1767  
Shengliang Guan 已提交
292
    uInfo(" dataDir: %s", cfg->dir);
S
TD-1767  
Shengliang Guan 已提交
293 294
  }
}
S
TD-1767  
Shengliang Guan 已提交
295
#endif
S
TD-1767  
Shengliang Guan 已提交
296 297 298 299 300

static void taosCheckDataDirCfg() {
  if (tsDiskCfgNum <= 0) {
    taosAddDataDir(0, tsDataDir, 0, 1);
    tsDiskCfgNum = 1;
S
TD-1767  
Shengliang Guan 已提交
301
    uTrace("dataDir:%s, level:0 primary:1 is configured by default", tsDataDir);
S
TD-1767  
Shengliang Guan 已提交
302 303 304
  }
}

305
static void doInitGlobalConfig(void) {
S
TD-1057  
Shengliang Guan 已提交
306
  osInit();
S
TD-1652  
Shengliang Guan 已提交
307 308
  srand(taosSafeRand());

S
slguan 已提交
309
  SGlobalCfg cfg = {0};
S
Shengliang Guan 已提交
310

S
slguan 已提交
311
  // ip address
H
Hui Li 已提交
312
  cfg.option = "firstEp";
S
slguan 已提交
313 314
  cfg.ptr = tsFirst;
  cfg.valType = TAOS_CFG_VTYPE_STRING;
S
slguan 已提交
315 316 317
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT;
  cfg.minValue = 0;
  cfg.maxValue = 0;
陶建辉(Jeff)'s avatar
陶建辉(Jeff) 已提交
318
  cfg.ptrLength = TSDB_EP_LEN;
S
slguan 已提交
319
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
320
  taosAddConfigOption(cfg);
S
slguan 已提交
321

H
Hui Li 已提交
322
  cfg.option = "secondEp";
J
jtao1735 已提交
323
  cfg.ptr = tsSecond;
S
slguan 已提交
324
  cfg.valType = TAOS_CFG_VTYPE_STRING;
S
slguan 已提交
325 326 327
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT;
  cfg.minValue = 0;
  cfg.maxValue = 0;
陶建辉(Jeff)'s avatar
陶建辉(Jeff) 已提交
328
  cfg.ptrLength = TSDB_EP_LEN;
S
slguan 已提交
329
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
330
  taosAddConfigOption(cfg);
S
slguan 已提交
331

332 333 334 335 336 337 338 339
  cfg.option = "fqdn";
  cfg.ptr = tsLocalFqdn;
  cfg.valType = TAOS_CFG_VTYPE_STRING;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT;
  cfg.minValue = 0;
  cfg.maxValue = 0;
  cfg.ptrLength = TSDB_FQDN_LEN;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
340
  taosAddConfigOption(cfg);
341

S
slguan 已提交
342
  // port
J
jtao1735 已提交
343 344
  cfg.option = "serverPort";
  cfg.ptr = &tsServerPort;
345
  cfg.valType = TAOS_CFG_VTYPE_UINT16;
S
slguan 已提交
346 347
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW | TSDB_CFG_CTYPE_B_CLIENT;
  cfg.minValue = 1;
348
  cfg.maxValue = 65056;
S
slguan 已提交
349 350
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
351
  taosAddConfigOption(cfg);
S
slguan 已提交
352

S
Shengliang Guan 已提交
353 354 355 356 357 358 359 360 361 362
  cfg.option = "supportVnodes";
  cfg.ptr = &tsNumOfSupportVnodes;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW | TSDB_CFG_CTYPE_B_CLIENT;
  cfg.minValue = 0;
  cfg.maxValue = 65536;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
  taosAddConfigOption(cfg);

S
slguan 已提交
363 364 365 366 367 368 369 370 371
  // directory
  cfg.option = "configDir";
  cfg.ptr = configDir;
  cfg.valType = TAOS_CFG_VTYPE_DIRECTORY;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT;
  cfg.minValue = 0;
  cfg.maxValue = 0;
  cfg.ptrLength = TSDB_FILENAME_LEN;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
372
  taosAddConfigOption(cfg);
S
slguan 已提交
373 374

  cfg.option = "logDir";
S
slguan 已提交
375
  cfg.ptr = tsLogDir;
S
slguan 已提交
376 377
  cfg.valType = TAOS_CFG_VTYPE_DIRECTORY;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT | TSDB_CFG_CTYPE_B_LOG;
378 379 380 381
  cfg.minValue = 0;
  cfg.maxValue = 0;
  cfg.ptrLength = TSDB_FILENAME_LEN;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
382
  taosAddConfigOption(cfg);
383

S
slguan 已提交
384
  cfg.option = "scriptDir";
S
slguan 已提交
385
  cfg.ptr = tsScriptDir;
S
slguan 已提交
386 387 388 389 390 391
  cfg.valType = TAOS_CFG_VTYPE_DIRECTORY;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT;
  cfg.minValue = 0;
  cfg.maxValue = 0;
  cfg.ptrLength = TSDB_FILENAME_LEN;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
392
  taosAddConfigOption(cfg);
S
slguan 已提交
393 394

  cfg.option = "dataDir";
S
slguan 已提交
395
  cfg.ptr = tsDataDir;
S
TD-1767  
Shengliang Guan 已提交
396
  cfg.valType = TAOS_CFG_VTYPE_DATA_DIRCTORY;
S
slguan 已提交
397 398 399 400 401
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG;
  cfg.minValue = 0;
  cfg.maxValue = 0;
  cfg.ptrLength = TSDB_FILENAME_LEN;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
402
  taosAddConfigOption(cfg);
S
slguan 已提交
403 404 405 406 407 408 409 410 411 412

  // dnode configs
  cfg.option = "numOfThreadsPerCore";
  cfg.ptr = &tsNumOfThreadsPerCore;
  cfg.valType = TAOS_CFG_VTYPE_FLOAT;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT;
  cfg.minValue = 0;
  cfg.maxValue = 10;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
413
  taosAddConfigOption(cfg);
S
slguan 已提交
414

S
TD-2067  
Shengliang Guan 已提交
415 416 417 418 419 420 421 422
  cfg.option = "numOfCommitThreads";
  cfg.ptr = &tsNumOfCommitThreads;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG;
  cfg.minValue = 1;
  cfg.maxValue = 100;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
423
  taosAddConfigOption(cfg);
S
TD-2067  
Shengliang Guan 已提交
424

425 426
  cfg.option = "ratioOfQueryCores";
  cfg.ptr = &tsRatioOfQueryCores;
S
slguan 已提交
427 428
  cfg.valType = TAOS_CFG_VTYPE_FLOAT;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG;
429 430
  cfg.minValue = 0.0f;
  cfg.maxValue = 2.0f;
S
slguan 已提交
431 432
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
433
  taosAddConfigOption(cfg);
S
slguan 已提交
434

435 436 437 438
  cfg.option = "maxNumOfDistinctRes";
  cfg.ptr = &tsMaxNumOfDistinctResults;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW | TSDB_CFG_CTYPE_B_CLIENT;
S
Shengliang Guan 已提交
439 440
  cfg.minValue = 10 * 10000;
  cfg.maxValue = 10000 * 10000;
441 442
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
443
  taosAddConfigOption(cfg);
H
Hui Li 已提交
444

B
Bomin Zhang 已提交
445 446
  cfg.option = "telemetryReporting";
  cfg.ptr = &tsEnableTelemetryReporting;
S
Shengliang Guan 已提交
447
  cfg.valType = TAOS_CFG_VTYPE_INT8;
B
Bomin Zhang 已提交
448 449 450 451 452
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
  cfg.minValue = 0;
  cfg.maxValue = 1;
  cfg.ptrLength = 1;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
453
  taosAddConfigOption(cfg);
B
Bomin Zhang 已提交
454

S
slguan 已提交
455 456
  // timer
  cfg.option = "maxTmrCtrl";
S
Shengliang Guan 已提交
457
  cfg.ptr = &tsMaxTmrCtrl;
S
slguan 已提交
458 459 460 461 462 463
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
  cfg.minValue = 8;
  cfg.maxValue = 2048;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
464
  taosAddConfigOption(cfg);
S
slguan 已提交
465 466 467 468 469 470 471 472 473

  cfg.option = "rpcTimer";
  cfg.ptr = &tsRpcTimer;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT;
  cfg.minValue = 100;
  cfg.maxValue = 3000;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_MS;
474
  taosAddConfigOption(cfg);
S
slguan 已提交
475

张宏权 已提交
476 477 478 479 480 481 482 483
  cfg.option = "rpcForceTcp";
  cfg.ptr = &tsRpcForceTcp;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT;
  cfg.minValue = 0;
  cfg.maxValue = 1;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
484
  taosAddConfigOption(cfg);
张宏权 已提交
485

S
slguan 已提交
486 487 488 489 490 491 492 493
  cfg.option = "rpcMaxTime";
  cfg.ptr = &tsRpcMaxTime;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT;
  cfg.minValue = 100;
  cfg.maxValue = 7200;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_SECOND;
494
  taosAddConfigOption(cfg);
S
slguan 已提交
495 496 497 498 499 500 501 502 503

  cfg.option = "statusInterval";
  cfg.ptr = &tsStatusInterval;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
  cfg.minValue = 1;
  cfg.maxValue = 10;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_SECOND;
504
  taosAddConfigOption(cfg);
S
slguan 已提交
505 506 507 508 509 510 511 512 513

  cfg.option = "shellActivityTimer";
  cfg.ptr = &tsShellActivityTimer;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT;
  cfg.minValue = 1;
  cfg.maxValue = 120;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_SECOND;
514
  taosAddConfigOption(cfg);
S
slguan 已提交
515 516 517 518 519 520 521 522 523

  cfg.option = "minSlidingTime";
  cfg.ptr = &tsMinSlidingTime;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
  cfg.minValue = 10;
  cfg.maxValue = 1000000;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_MS;
524
  taosAddConfigOption(cfg);
S
slguan 已提交
525 526 527 528 529

  cfg.option = "minIntervalTime";
  cfg.ptr = &tsMinIntervalTime;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
H
Haojun Liao 已提交
530
  cfg.minValue = 1;
S
slguan 已提交
531 532 533
  cfg.maxValue = 1000000;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_MS;
534
  taosAddConfigOption(cfg);
S
slguan 已提交
535 536 537 538 539 540 541 542 543

  cfg.option = "maxStreamCompDelay";
  cfg.ptr = &tsMaxStreamComputDelay;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
  cfg.minValue = 10;
  cfg.maxValue = 1000000000;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_MS;
544
  taosAddConfigOption(cfg);
S
slguan 已提交
545 546 547 548 549 550 551 552 553

  cfg.option = "maxFirstStreamCompDelay";
  cfg.ptr = &tsStreamCompStartDelay;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
  cfg.minValue = 1000;
  cfg.maxValue = 1000000000;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_MS;
554
  taosAddConfigOption(cfg);
S
slguan 已提交
555 556

  cfg.option = "retryStreamCompDelay";
557
  cfg.ptr = &tsRetryStreamCompDelay;
S
slguan 已提交
558 559 560 561 562 563 564
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
  cfg.minValue = 10;
  cfg.maxValue = 1000000000;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_MS;

565
  taosAddConfigOption(cfg);
S
slguan 已提交
566 567 568 569
  cfg.option = "streamCompDelayRatio";
  cfg.ptr = &tsStreamComputDelayRatio;
  cfg.valType = TAOS_CFG_VTYPE_FLOAT;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
570 571
  cfg.minValue = 0.1f;
  cfg.maxValue = 0.9f;
S
slguan 已提交
572 573
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
574
  taosAddConfigOption(cfg);
S
slguan 已提交
575 576 577 578 579 580

  cfg.option = "compressMsgSize";
  cfg.ptr = &tsCompressMsgSize;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT | TSDB_CFG_CTYPE_B_SHOW;
  cfg.minValue = -1;
D
dapan1121 已提交
581
  cfg.maxValue = 100000000.0f;
S
slguan 已提交
582 583
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
584
  taosAddConfigOption(cfg);
S
slguan 已提交
585

586 587
  cfg.option = "compressColData";
  cfg.ptr = &tsCompressColData;
588 589 590 591
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT | TSDB_CFG_CTYPE_B_SHOW;
  cfg.minValue = -1;
  cfg.maxValue = 100000000.0f;
592 593
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
594
  taosAddConfigOption(cfg);
595

596 597
  cfg.option = "maxWildCardsLength";
  cfg.ptr = &tsMaxWildCardsLen;
598 599 600
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT | TSDB_CFG_CTYPE_B_SHOW;
  cfg.minValue = 0;
601
  cfg.maxValue = TSDB_MAX_FIELD_LEN;
602 603
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_BYTE;
604
  taosAddConfigOption(cfg);
605

606 607 608 609 610 611 612 613
  cfg.option = "maxRegexStringLen";
  cfg.ptr = &tsMaxRegexStringLen;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT | TSDB_CFG_CTYPE_B_SHOW;
  cfg.minValue = 0;
  cfg.maxValue = TSDB_MAX_FIELD_LEN;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_BYTE;
614
  taosAddConfigOption(cfg);
615

S
slguan 已提交
616 617 618 619 620 621 622 623
  cfg.option = "maxNumOfOrderedRes";
  cfg.ptr = &tsMaxNumOfOrderedResults;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT | TSDB_CFG_CTYPE_B_SHOW;
  cfg.minValue = TSDB_MAX_SQL_LEN;
  cfg.maxValue = TSDB_MAX_ALLOWED_SQL_LEN;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
624
  taosAddConfigOption(cfg);
S
slguan 已提交
625

H
Haojun Liao 已提交
626 627 628 629 630
  cfg.option = "queryBufferSize";
  cfg.ptr = &tsQueryBufferSize;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
  cfg.minValue = -1;
H
Haojun Liao 已提交
631
  cfg.maxValue = 500000000000.0f;
H
Haojun Liao 已提交
632 633
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_BYTE;
634
  taosAddConfigOption(cfg);
H
Haojun Liao 已提交
635

H
Haojun Liao 已提交
636 637
  cfg.option = "retrieveBlockingModel";
  cfg.ptr = &tsRetrieveBlockingModel;
638 639 640 641 642 643
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
  cfg.minValue = 0;
  cfg.maxValue = 1;
  cfg.ptrLength = 1;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
644
  taosAddConfigOption(cfg);
645

646 647
  cfg.option = "keepColumnName";
  cfg.ptr = &tsKeepOriginalColumnName;
S
Shengliang Guan 已提交
648
  cfg.valType = TAOS_CFG_VTYPE_INT8;
649 650 651 652 653
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW | TSDB_CFG_CTYPE_B_CLIENT;
  cfg.minValue = 0;
  cfg.maxValue = 1;
  cfg.ptrLength = 1;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
654
  taosAddConfigOption(cfg);
655

S
slguan 已提交
656 657 658 659
  // locale & charset
  cfg.option = "timezone";
  cfg.ptr = tsTimezone;
  cfg.valType = TAOS_CFG_VTYPE_STRING;
660
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW | TSDB_CFG_CTYPE_B_CLIENT;
S
slguan 已提交
661 662
  cfg.minValue = 0;
  cfg.maxValue = 0;
S
Shengliang Guan 已提交
663
  cfg.ptrLength = TSDB_TIMEZONE_LEN;
S
slguan 已提交
664
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
665
  taosAddConfigOption(cfg);
S
slguan 已提交
666 667 668 669

  cfg.option = "locale";
  cfg.ptr = tsLocale;
  cfg.valType = TAOS_CFG_VTYPE_STRING;
670
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW | TSDB_CFG_CTYPE_B_CLIENT;
S
slguan 已提交
671 672
  cfg.minValue = 0;
  cfg.maxValue = 0;
S
Shengliang Guan 已提交
673
  cfg.ptrLength = TSDB_LOCALE_LEN;
S
slguan 已提交
674
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
675
  taosAddConfigOption(cfg);
S
slguan 已提交
676 677 678 679

  cfg.option = "charset";
  cfg.ptr = tsCharset;
  cfg.valType = TAOS_CFG_VTYPE_STRING;
680
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW | TSDB_CFG_CTYPE_B_CLIENT;
S
slguan 已提交
681 682
  cfg.minValue = 0;
  cfg.maxValue = 0;
S
Shengliang Guan 已提交
683
  cfg.ptrLength = TSDB_LOCALE_LEN;
S
slguan 已提交
684
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
685
  taosAddConfigOption(cfg);
S
slguan 已提交
686 687 688 689 690 691 692 693 694 695

  // connect configs
  cfg.option = "maxShellConns";
  cfg.ptr = &tsMaxShellConns;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
  cfg.minValue = 10;
  cfg.maxValue = 50000000;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
696
  taosAddConfigOption(cfg);
S
slguan 已提交
697

698 699
  cfg.option = "maxConnections";
  cfg.ptr = &tsMaxConnections;
S
slguan 已提交
700 701
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
702
  cfg.minValue = 1;
703
  cfg.maxValue = 100000;
S
slguan 已提交
704 705
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
706
  taosAddConfigOption(cfg);
S
slguan 已提交
707 708 709 710 711

  cfg.option = "minimalLogDirGB";
  cfg.ptr = &tsMinimalLogDirGB;
  cfg.valType = TAOS_CFG_VTYPE_FLOAT;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
712
  cfg.minValue = 0.001f;
S
slguan 已提交
713 714 715
  cfg.maxValue = 10000000;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_GB;
716
  taosAddConfigOption(cfg);
S
slguan 已提交
717 718

  cfg.option = "minimalTmpDirGB";
H
Haojun Liao 已提交
719
  cfg.ptr = &tsReservedTmpDirectorySpace;
S
slguan 已提交
720 721
  cfg.valType = TAOS_CFG_VTYPE_FLOAT;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
722
  cfg.minValue = 0.001f;
S
slguan 已提交
723 724 725
  cfg.maxValue = 10000000;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_GB;
726
  taosAddConfigOption(cfg);
S
slguan 已提交
727 728 729 730 731

  cfg.option = "minimalDataDirGB";
  cfg.ptr = &tsMinimalDataDirGB;
  cfg.valType = TAOS_CFG_VTYPE_FLOAT;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
732
  cfg.minValue = 0.001f;
S
slguan 已提交
733 734 735
  cfg.maxValue = 10000000;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_GB;
736
  taosAddConfigOption(cfg);
S
TD-2498  
Shengliang Guan 已提交
737 738 739

  cfg.option = "slaveQuery";
  cfg.ptr = &tsEnableSlaveQuery;
S
Shengliang Guan 已提交
740 741 742 743 744 745
  cfg.valType = TAOS_CFG_VTYPE_INT8;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
  cfg.minValue = 0;
  cfg.maxValue = 1;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
746
  taosAddConfigOption(cfg);
S
Shengliang Guan 已提交
747

S
slguan 已提交
748 749 750 751 752
  // debug flag
  cfg.option = "numOfLogLines";
  cfg.ptr = &tsNumOfLogLines;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG | TSDB_CFG_CTYPE_B_CLIENT;
S
TD-1263  
Shengliang Guan 已提交
753
  cfg.minValue = 1000;
S
slguan 已提交
754 755 756
  cfg.maxValue = 2000000000;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
757
  taosAddConfigOption(cfg);
S
slguan 已提交
758

759
  cfg.option = "logKeepDays";
S
TD-1263  
Shengliang Guan 已提交
760
  cfg.ptr = &tsLogKeepDays;
761 762
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG | TSDB_CFG_CTYPE_B_CLIENT;
S
TD-1574  
Shengliang Guan 已提交
763
  cfg.minValue = -365000;
S
TD-1263  
Shengliang Guan 已提交
764
  cfg.maxValue = 365000;
765 766
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
767
  taosAddConfigOption(cfg);
768

S
slguan 已提交
769 770
  cfg.option = "asyncLog";
  cfg.ptr = &tsAsyncLog;
S
Shengliang Guan 已提交
771
  cfg.valType = TAOS_CFG_VTYPE_INT8;
S
slguan 已提交
772 773 774 775 776
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG | TSDB_CFG_CTYPE_B_CLIENT;
  cfg.minValue = 0;
  cfg.maxValue = 1;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
777
  taosAddConfigOption(cfg);
S
slguan 已提交
778 779 780 781 782 783 784 785 786

  cfg.option = "debugFlag";
  cfg.ptr = &debugFlag;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG | TSDB_CFG_CTYPE_B_CLIENT;
  cfg.minValue = 0;
  cfg.maxValue = 255;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
787
  taosAddConfigOption(cfg);
S
slguan 已提交
788 789

  cfg.option = "mDebugFlag";
guanshengliang's avatar
guanshengliang 已提交
790
  cfg.ptr = &mDebugFlag;
S
slguan 已提交
791 792 793 794 795 796
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG;
  cfg.minValue = 0;
  cfg.maxValue = 255;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
797
  taosAddConfigOption(cfg);
S
slguan 已提交
798 799

  cfg.option = "dDebugFlag";
800
  cfg.ptr = &dDebugFlag;
S
slguan 已提交
801 802 803 804 805 806
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG;
  cfg.minValue = 0;
  cfg.maxValue = 255;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
807
  taosAddConfigOption(cfg);
S
slguan 已提交
808

J
jtao1735 已提交
809 810 811 812 813 814 815 816
  cfg.option = "sDebugFlag";
  cfg.ptr = &sDebugFlag;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG;
  cfg.minValue = 0;
  cfg.maxValue = 255;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
817
  taosAddConfigOption(cfg);
J
jtao1735 已提交
818

S
Shengliang Guan 已提交
819 820 821 822 823 824 825 826
  cfg.option = "wDebugFlag";
  cfg.ptr = &wDebugFlag;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG;
  cfg.minValue = 0;
  cfg.maxValue = 255;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
827
  taosAddConfigOption(cfg);
S
Shengliang Guan 已提交
828

S
slguan 已提交
829 830 831 832 833 834 835 836
  cfg.option = "rpcDebugFlag";
  cfg.ptr = &rpcDebugFlag;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG | TSDB_CFG_CTYPE_B_CLIENT;
  cfg.minValue = 0;
  cfg.maxValue = 255;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
837
  taosAddConfigOption(cfg);
S
slguan 已提交
838 839 840 841 842 843 844 845 846

  cfg.option = "tmrDebugFlag";
  cfg.ptr = &tmrDebugFlag;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG | TSDB_CFG_CTYPE_B_CLIENT;
  cfg.minValue = 0;
  cfg.maxValue = 255;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
847
  taosAddConfigOption(cfg);
S
slguan 已提交
848 849

  cfg.option = "cDebugFlag";
guanshengliang's avatar
guanshengliang 已提交
850
  cfg.ptr = &cDebugFlag;
S
slguan 已提交
851 852 853 854 855 856
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG | TSDB_CFG_CTYPE_B_CLIENT;
  cfg.minValue = 0;
  cfg.maxValue = 255;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
857
  taosAddConfigOption(cfg);
S
slguan 已提交
858 859

  cfg.option = "jniDebugFlag";
guanshengliang's avatar
guanshengliang 已提交
860
  cfg.ptr = &jniDebugFlag;
S
slguan 已提交
861 862 863 864 865 866
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG | TSDB_CFG_CTYPE_B_CLIENT;
  cfg.minValue = 0;
  cfg.maxValue = 255;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
867
  taosAddConfigOption(cfg);
S
slguan 已提交
868 869 870 871 872 873 874 875 876

  cfg.option = "uDebugFlag";
  cfg.ptr = &uDebugFlag;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG | TSDB_CFG_CTYPE_B_CLIENT;
  cfg.minValue = 0;
  cfg.maxValue = 255;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
877
  taosAddConfigOption(cfg);
S
slguan 已提交
878 879

  cfg.option = "qDebugFlag";
guanshengliang's avatar
guanshengliang 已提交
880
  cfg.ptr = &qDebugFlag;
S
slguan 已提交
881 882 883 884 885 886
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG | TSDB_CFG_CTYPE_B_CLIENT;
  cfg.minValue = 0;
  cfg.maxValue = 255;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
887
  taosAddConfigOption(cfg);
S
slguan 已提交
888

S
Shengliang Guan 已提交
889 890 891 892 893 894 895 896
  cfg.option = "vDebugFlag";
  cfg.ptr = &vDebugFlag;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG;
  cfg.minValue = 0;
  cfg.maxValue = 255;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
897
  taosAddConfigOption(cfg);
S
Shengliang Guan 已提交
898

899 900 901
  cfg.option = "tsdbDebugFlag";
  cfg.ptr = &tsdbDebugFlag;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
902
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG;
903 904 905 906
  cfg.minValue = 0;
  cfg.maxValue = 255;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
907
  taosAddConfigOption(cfg);
908

S
TD-1520  
Shengliang Guan 已提交
909 910 911 912 913 914 915 916
  cfg.option = "cqDebugFlag";
  cfg.ptr = &cqDebugFlag;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG;
  cfg.minValue = 0;
  cfg.maxValue = 255;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
917
  taosAddConfigOption(cfg);
S
TD-1520  
Shengliang Guan 已提交
918

919
  cfg.option = "enableRecordSql";
S
slguan 已提交
920
  cfg.ptr = &tsTscEnableRecordSql;
S
Shengliang Guan 已提交
921
  cfg.valType = TAOS_CFG_VTYPE_INT8;
S
slguan 已提交
922 923 924 925 926
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG;
  cfg.minValue = 0;
  cfg.maxValue = 1;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
927
  taosAddConfigOption(cfg);
S
slguan 已提交
928 929 930

  cfg.option = "enableCoreFile";
  cfg.ptr = &tsEnableCoreFile;
S
Shengliang Guan 已提交
931
  cfg.valType = TAOS_CFG_VTYPE_INT8;
S
slguan 已提交
932 933 934 935 936
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG;
  cfg.minValue = 0;
  cfg.maxValue = 1;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
937
  taosAddConfigOption(cfg);
S
slguan 已提交
938 939 940 941 942 943 944 945 946 947

  // version info
  cfg.option = "gitinfo";
  cfg.ptr = gitinfo;
  cfg.valType = TAOS_CFG_VTYPE_STRING;
  cfg.cfgType = TSDB_CFG_CTYPE_B_SHOW | TSDB_CFG_CTYPE_B_CLIENT;
  cfg.minValue = 0;
  cfg.maxValue = 0;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
948
  taosAddConfigOption(cfg);
S
slguan 已提交
949 950 951 952 953 954 955 956 957

  cfg.option = "gitinfoOfInternal";
  cfg.ptr = gitinfoOfInternal;
  cfg.valType = TAOS_CFG_VTYPE_STRING;
  cfg.cfgType = TSDB_CFG_CTYPE_B_SHOW | TSDB_CFG_CTYPE_B_CLIENT;
  cfg.minValue = 0;
  cfg.maxValue = 0;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
958
  taosAddConfigOption(cfg);
S
slguan 已提交
959 960 961 962 963 964 965 966 967

  cfg.option = "buildinfo";
  cfg.ptr = buildinfo;
  cfg.valType = TAOS_CFG_VTYPE_STRING;
  cfg.cfgType = TSDB_CFG_CTYPE_B_SHOW | TSDB_CFG_CTYPE_B_CLIENT;
  cfg.minValue = 0;
  cfg.maxValue = 0;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
968
  taosAddConfigOption(cfg);
S
slguan 已提交
969 970 971 972 973 974 975 976 977

  cfg.option = "version";
  cfg.ptr = version;
  cfg.valType = TAOS_CFG_VTYPE_STRING;
  cfg.cfgType = TSDB_CFG_CTYPE_B_SHOW | TSDB_CFG_CTYPE_B_CLIENT;
  cfg.minValue = 0;
  cfg.maxValue = 0;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
978
  taosAddConfigOption(cfg);
979 980 981 982 983 984

  cfg.option = "maxBinaryDisplayWidth";
  cfg.ptr = &tsMaxBinaryDisplayWidth;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT;
  cfg.minValue = 1;
985
  cfg.maxValue = 65536;
986 987
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
988
  taosAddConfigOption(cfg);
989 990 991 992 993 994 995

  cfg.option = "tempDir";
  cfg.ptr = tsTempDir;
  cfg.valType = TAOS_CFG_VTYPE_STRING;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT;
  cfg.minValue = 0;
  cfg.maxValue = 0;
S
Shengliang Guan 已提交
996
  cfg.ptrLength = PATH_MAX;
997
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
998
  taosAddConfigOption(cfg);
999

S
Shengliang Guan 已提交
1000
  // enable kill long query
1001 1002 1003 1004 1005 1006 1007 1008
  cfg.option = "deadLockKillQuery";
  cfg.ptr = &tsDeadLockKillQuery;
  cfg.valType = TAOS_CFG_VTYPE_INT8;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
  cfg.minValue = 0;
  cfg.maxValue = 1;
  cfg.ptrLength = 1;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
1009
  taosAddConfigOption(cfg);
1010

T
tickduan 已提交
1011
#ifdef TD_TSZ
T
tickduan 已提交
1012
  // lossy compress
T
tickduan 已提交
1013
  cfg.option = "lossyColumns";
T
tickduan 已提交
1014 1015 1016 1017 1018 1019 1020
  cfg.ptr = lossyColumns;
  cfg.valType = TAOS_CFG_VTYPE_STRING;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG;
  cfg.minValue = 0;
  cfg.maxValue = 0;
  cfg.ptrLength = tListLen(lossyColumns);
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
1021
  taosAddConfigOption(cfg);
T
tickduan 已提交
1022 1023 1024 1025 1026

  cfg.option = "fPrecision";
  cfg.ptr = &fPrecision;
  cfg.valType = TAOS_CFG_VTYPE_DOUBLE;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG;
T
tickduan 已提交
1027 1028
  cfg.minValue = MIN_FLOAT;
  cfg.maxValue = MAX_FLOAT;
T
tickduan 已提交
1029 1030
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
T
tickduan 已提交
1031

1032
  taosAddConfigOption(cfg);
T
tickduan 已提交
1033 1034 1035 1036 1037

  cfg.option = "dPrecision";
  cfg.ptr = &dPrecision;
  cfg.valType = TAOS_CFG_VTYPE_DOUBLE;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG;
T
tickduan 已提交
1038 1039
  cfg.minValue = MIN_FLOAT;
  cfg.maxValue = MAX_FLOAT;
T
tickduan 已提交
1040 1041
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
1042
  taosAddConfigOption(cfg);
T
tickduan 已提交
1043

T
tickduan 已提交
1044 1045
  cfg.option = "maxRange";
  cfg.ptr = &maxRange;
T
tickduan 已提交
1046 1047 1048 1049 1050 1051
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG;
  cfg.minValue = 0;
  cfg.maxValue = 65536;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
1052
  taosAddConfigOption(cfg);
T
tickduan 已提交
1053

T
tickduan 已提交
1054
  cfg.option = "range";
T
tickduan 已提交
1055
  cfg.ptr = &curRange;
T
tickduan 已提交
1056 1057 1058 1059 1060 1061
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG;
  cfg.minValue = 0;
  cfg.maxValue = 65536;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
1062
  taosAddConfigOption(cfg);
1063 1064
  assert(tsGlobalConfigNum == TSDB_CFG_MAX_NUM);
#else
S
Shengliang Guan 已提交
1065
  // assert(tsGlobalConfigNum == TSDB_CFG_MAX_NUM - 5);
1066
#endif
S
slguan 已提交
1067 1068
}

S
Shengliang Guan 已提交
1069
void taosInitGlobalCfg() { pthread_once(&tsInitGlobalCfgOnce, doInitGlobalConfig); }
S
slguan 已提交
1070

1071
int32_t taosCheckAndPrintCfg() {
H
Haojun Liao 已提交
1072
  SEp ep = {0};
S
Shengliang Guan 已提交
1073
  if (debugFlag & DEBUG_TRACE || debugFlag & DEBUG_DEBUG || debugFlag & DEBUG_DUMP) {
guanshengliang's avatar
guanshengliang 已提交
1074 1075
    taosSetAllDebugFlag();
  }
S
Shengliang Guan 已提交
1076

H
Hui Li 已提交
1077 1078 1079 1080
  if (tsLocalFqdn[0] == 0) {
    taosGetFqdn(tsLocalFqdn);
  }

R
root 已提交
1081
  snprintf(tsLocalEp, sizeof(tsLocalEp), "%s:%u", tsLocalFqdn, tsServerPort);
1082
  uInfo("localEp is: %s", tsLocalEp);
S
slguan 已提交
1083

S
slguan 已提交
1084 1085
  if (tsFirst[0] == 0) {
    strcpy(tsFirst, tsLocalEp);
1086
  } else {
H
Haojun Liao 已提交
1087 1088
    taosGetFqdnPortFromEp(tsFirst, &ep);
    snprintf(tsFirst, sizeof(tsFirst), "%s:%u", ep.fqdn, ep.port);
S
slguan 已提交
1089 1090
  }

J
jtao1735 已提交
1091 1092
  if (tsSecond[0] == 0) {
    strcpy(tsSecond, tsLocalEp);
1093
  } else {
H
Haojun Liao 已提交
1094 1095
    taosGetFqdnPortFromEp(tsSecond, &ep);
    snprintf(tsSecond, sizeof(tsSecond), "%s:%u", ep.fqdn, ep.port);
S
slguan 已提交
1096
  }
1097

S
TD-1767  
Shengliang Guan 已提交
1098
  taosCheckDataDirCfg();
D
fix bug  
dapan1121 已提交
1099

1100
  if (taosDirExist(tsTempDir) != 0) {
D
fix bug  
dapan1121 已提交
1101 1102
    return -1;
  }
S
Shengliang Guan 已提交
1103

S
slguan 已提交
1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116
  taosGetSystemInfo();

  tsSetLocale();

  SGlobalCfg *cfg_timezone = taosGetConfigOption("timezone");
  if (cfg_timezone && cfg_timezone->cfgStatus == TAOS_CFG_CSTATUS_FILE) {
    tsSetTimeZone();
  }

  if (tsNumOfCores <= 0) {
    tsNumOfCores = 1;
  }

1117
  if (tsQueryBufferSize >= 0) {
D
fix bug  
dapan1121 已提交
1118
    tsQueryBufferSizeBytes = tsQueryBufferSize * 1048576UL;
1119 1120
  }

1121 1122
  uInfo("   check global cfg completed");
  uInfo("==================================");
1123
  taosPrintCfg();
S
TD-1663  
Shengliang Guan 已提交
1124

S
TD-1663  
Shengliang Guan 已提交
1125
  return 0;
S
slguan 已提交
1126
}
J
jtao1735 已提交
1127

1128 1129 1130 1131
/*
 * alter dnode 1 balance "vnode:1-dnode:2"
 */

S
Shengliang Guan 已提交
1132
bool taosCheckBalanceCfgOptions(const char *option, int32_t *vnodeId, int32_t *dnodeId) {
1133
  int len = (int)strlen(option);
1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147
  if (strncasecmp(option, "vnode:", 6) != 0) {
    return false;
  }

  int pos = 0;
  for (; pos < len; ++pos) {
    if (option[pos] == '-') break;
  }

  if (++pos >= len) return false;
  if (strncasecmp(option + pos, "dnode:", 6) != 0) {
    return false;
  }

S
Shengliang Guan 已提交
1148 1149 1150
  *vnodeId = strtol(option + 6, NULL, 10);
  *dnodeId = strtol(option + pos + 6, NULL, 10);
  if (*vnodeId <= 1 || *dnodeId <= 0) {
1151 1152 1153 1154
    return false;
  }

  return true;
1155
}