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 22
#include "tcompare.h"
#include "tep.h"
S
slguan 已提交
23
#include "tglobal.h"
S
Shengliang Guan 已提交
24
#include "tlocale.h"
S
Shengliang Guan 已提交
25 26 27 28
#include "tlog.h"
#include "ttimezone.h"
#include "tutil.h"
#include "ulog.h"
S
slguan 已提交
29

S
Shengliang Guan 已提交
30 31 32 33 34
// 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 已提交
35
uint16_t tsServerPort = 6030;
S
Shengliang Guan 已提交
36
int32_t  tsStatusInterval = 1;  // second
S
Shengliang Guan 已提交
37
int8_t   tsEnableTelemetryReporting = 0;
H
Hui Li 已提交
38
char     tsEmail[TSDB_FQDN_LEN] = {0};
S
Shengliang Guan 已提交
39
int32_t  tsNumOfSupportVnodes = 128;
H
Hui Li 已提交
40

S
Shengliang Guan 已提交
41
// common
S
Shengliang Guan 已提交
42 43 44 45
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 已提交
46
int32_t tsMaxConnections = 50000;
S
Shengliang Guan 已提交
47
int32_t tsShellActivityTimer = 3;  // second
H
Haojun Liao 已提交
48
float   tsNumOfThreadsPerCore = 1.0f;
49
int32_t tsNumOfCommitThreads = 4;
50
float   tsRatioOfQueryCores = 1.0f;
S
Shengliang Guan 已提交
51
int8_t  tsDaylight = 0;
S
Shengliang Guan 已提交
52
int8_t  tsEnableCoreFile = 0;
S
Shengliang Guan 已提交
53
int32_t tsMaxBinaryDisplayWidth = 30;
S
Shengliang Guan 已提交
54 55 56
int8_t  tsEnableSlaveQuery = 1;
int8_t  tsEnableAdjustMaster = 1;
int8_t  tsPrintAuth = 0;
S
Shengliang Guan 已提交
57 58 59 60 61 62 63 64
/*
 * 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 已提交
65
int32_t tsCompressMsgSize = -1;
S
Shengliang Guan 已提交
66

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

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

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

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

S
Shengliang Guan 已提交
85 86 87 88 89 90 91
// 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;

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

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

// 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 已提交
105
int32_t tsRetryStreamCompDelay = 10 * 1000;
S
Shengliang Guan 已提交
106 107

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

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

H
Haojun Liao 已提交
113 114 115 116 117
// 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;
118
int64_t tsQueryBufferSizeBytes = -1;
H
Haojun Liao 已提交
119

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

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

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

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

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

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

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

// system info
S
Shengliang Guan 已提交
150 151 152 153 154 155 156 157
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;
158
uint32_t tsVersion = 0;
S
slguan 已提交
159

T
tickduan 已提交
160 161 162
//
// lossy compress 6
//
S
Shengliang Guan 已提交
163 164 165 166 167 168 169 170
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 已提交
171

172

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

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

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

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

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

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

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

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

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

S
Shengliang Guan 已提交
220
    int32_t cfgLen = (int32_t)strlen(cfg->option);
221
    if (cfgLen != olen) continue;
T
tickduan 已提交
222 223 224 225 226 227
    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 已提交
228

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

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

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

  return false;
}

S
TD-1767  
Shengliang Guan 已提交
271 272 273 274 275 276 277 278 279
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 已提交
280 281 282 283 284 285
  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 已提交
286 287 288 289 290
}

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

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

304
static void doInitGlobalConfig(void) {
S
TD-1057  
Shengliang Guan 已提交
305
  osInit();
S
TD-1652  
Shengliang Guan 已提交
306
  srand(taosSafeRand());
S
config  
Shengliang Guan 已提交
307
#if 0
S
slguan 已提交
308
  SGlobalCfg cfg = {0};
S
Shengliang Guan 已提交
309

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

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

331 332 333 334 335 336 337 338
  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;
339
  taosAddConfigOption(cfg);
340

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

S
Shengliang Guan 已提交
352 353 354 355 356 357 358 359 360 361
  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 已提交
362 363 364 365 366 367 368 369 370
  // 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;
371
  taosAddConfigOption(cfg);
S
slguan 已提交
372 373

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

S
slguan 已提交
383
  cfg.option = "scriptDir";
S
slguan 已提交
384
  cfg.ptr = tsScriptDir;
S
slguan 已提交
385 386 387 388 389 390
  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;
391
  taosAddConfigOption(cfg);
S
slguan 已提交
392 393

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

  // 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;
412
  taosAddConfigOption(cfg);
S
slguan 已提交
413

S
TD-2067  
Shengliang Guan 已提交
414 415 416 417 418 419 420 421
  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;
422
  taosAddConfigOption(cfg);
S
TD-2067  
Shengliang Guan 已提交
423

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

434 435 436 437
  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 已提交
438 439
  cfg.minValue = 10 * 10000;
  cfg.maxValue = 10000 * 10000;
440 441
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
442
  taosAddConfigOption(cfg);
H
Hui Li 已提交
443

B
Bomin Zhang 已提交
444 445
  cfg.option = "telemetryReporting";
  cfg.ptr = &tsEnableTelemetryReporting;
S
Shengliang Guan 已提交
446
  cfg.valType = TAOS_CFG_VTYPE_INT8;
B
Bomin Zhang 已提交
447 448 449 450 451
  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;
452
  taosAddConfigOption(cfg);
B
Bomin Zhang 已提交
453

S
slguan 已提交
454 455
  // timer
  cfg.option = "maxTmrCtrl";
S
Shengliang Guan 已提交
456
  cfg.ptr = &tsMaxTmrCtrl;
S
slguan 已提交
457 458 459 460 461 462
  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;
463
  taosAddConfigOption(cfg);
S
slguan 已提交
464 465 466 467 468 469 470 471 472

  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;
473
  taosAddConfigOption(cfg);
S
slguan 已提交
474

张宏权 已提交
475 476 477 478 479 480 481 482
  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;
483
  taosAddConfigOption(cfg);
张宏权 已提交
484

S
slguan 已提交
485 486 487 488 489 490 491 492
  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;
493
  taosAddConfigOption(cfg);
S
slguan 已提交
494 495 496 497 498 499 500 501 502

  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;
503
  taosAddConfigOption(cfg);
S
slguan 已提交
504 505 506 507 508 509 510 511 512

  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;
513
  taosAddConfigOption(cfg);
S
slguan 已提交
514 515 516 517 518 519 520 521 522

  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;
523
  taosAddConfigOption(cfg);
S
slguan 已提交
524 525 526 527 528

  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 已提交
529
  cfg.minValue = 1;
S
slguan 已提交
530 531 532
  cfg.maxValue = 1000000;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_MS;
533
  taosAddConfigOption(cfg);
S
slguan 已提交
534 535 536 537 538 539 540 541 542

  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;
543
  taosAddConfigOption(cfg);
S
slguan 已提交
544 545 546 547 548 549 550 551 552

  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;
553
  taosAddConfigOption(cfg);
S
slguan 已提交
554 555

  cfg.option = "retryStreamCompDelay";
556
  cfg.ptr = &tsRetryStreamCompDelay;
S
slguan 已提交
557 558 559 560 561 562 563
  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;

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

  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 已提交
580
  cfg.maxValue = 100000000.0f;
S
slguan 已提交
581 582
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
583
  taosAddConfigOption(cfg);
S
slguan 已提交
584

585 586
  cfg.option = "compressColData";
  cfg.ptr = &tsCompressColData;
587 588 589 590
  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;
591 592
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
593
  taosAddConfigOption(cfg);
594

595 596
  cfg.option = "maxWildCardsLength";
  cfg.ptr = &tsMaxWildCardsLen;
597 598 599
  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;
600
  cfg.maxValue = TSDB_MAX_FIELD_LEN;
601 602
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_BYTE;
603
  taosAddConfigOption(cfg);
604

605 606 607 608 609 610 611 612
  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;
613
  taosAddConfigOption(cfg);
614

S
slguan 已提交
615 616 617 618 619 620 621 622
  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;
623
  taosAddConfigOption(cfg);
S
slguan 已提交
624

H
Haojun Liao 已提交
625 626 627 628 629
  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 已提交
630
  cfg.maxValue = 500000000000.0f;
H
Haojun Liao 已提交
631 632
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_BYTE;
633
  taosAddConfigOption(cfg);
H
Haojun Liao 已提交
634

H
Haojun Liao 已提交
635 636
  cfg.option = "retrieveBlockingModel";
  cfg.ptr = &tsRetrieveBlockingModel;
637 638 639 640 641 642
  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;
643
  taosAddConfigOption(cfg);
644

645 646
  cfg.option = "keepColumnName";
  cfg.ptr = &tsKeepOriginalColumnName;
S
Shengliang Guan 已提交
647
  cfg.valType = TAOS_CFG_VTYPE_INT8;
648 649 650 651 652
  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;
653
  taosAddConfigOption(cfg);
654

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

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

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

  // 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;
695
  taosAddConfigOption(cfg);
S
slguan 已提交
696

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

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

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

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

  cfg.option = "slaveQuery";
  cfg.ptr = &tsEnableSlaveQuery;
S
Shengliang Guan 已提交
739 740 741 742 743 744
  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;
745
  taosAddConfigOption(cfg);
S
Shengliang Guan 已提交
746

S
slguan 已提交
747 748 749 750 751
  // 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 已提交
752
  cfg.minValue = 1000;
S
slguan 已提交
753 754 755
  cfg.maxValue = 2000000000;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
756
  taosAddConfigOption(cfg);
S
slguan 已提交
757

758
  cfg.option = "logKeepDays";
S
TD-1263  
Shengliang Guan 已提交
759
  cfg.ptr = &tsLogKeepDays;
760 761
  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 已提交
762
  cfg.minValue = -365000;
S
TD-1263  
Shengliang Guan 已提交
763
  cfg.maxValue = 365000;
764 765
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
766
  taosAddConfigOption(cfg);
767

S
slguan 已提交
768 769
  cfg.option = "asyncLog";
  cfg.ptr = &tsAsyncLog;
S
Shengliang Guan 已提交
770
  cfg.valType = TAOS_CFG_VTYPE_INT8;
S
slguan 已提交
771 772 773 774 775
  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;
776
  taosAddConfigOption(cfg);
S
slguan 已提交
777 778 779 780 781 782 783 784 785

  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;
786
  taosAddConfigOption(cfg);
S
slguan 已提交
787 788

  cfg.option = "mDebugFlag";
guanshengliang's avatar
guanshengliang 已提交
789
  cfg.ptr = &mDebugFlag;
S
slguan 已提交
790 791 792 793 794 795
  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;
796
  taosAddConfigOption(cfg);
S
slguan 已提交
797 798

  cfg.option = "dDebugFlag";
799
  cfg.ptr = &dDebugFlag;
S
slguan 已提交
800 801 802 803 804 805
  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;
806
  taosAddConfigOption(cfg);
S
slguan 已提交
807

J
jtao1735 已提交
808 809 810 811 812 813 814 815
  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;
816
  taosAddConfigOption(cfg);
J
jtao1735 已提交
817

S
Shengliang Guan 已提交
818 819 820 821 822 823 824 825
  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;
826
  taosAddConfigOption(cfg);
S
Shengliang Guan 已提交
827

S
slguan 已提交
828 829 830 831 832 833 834 835
  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;
836
  taosAddConfigOption(cfg);
S
slguan 已提交
837 838 839 840 841 842 843 844 845

  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;
846
  taosAddConfigOption(cfg);
S
slguan 已提交
847 848

  cfg.option = "cDebugFlag";
guanshengliang's avatar
guanshengliang 已提交
849
  cfg.ptr = &cDebugFlag;
S
slguan 已提交
850 851 852 853 854 855
  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;
856
  taosAddConfigOption(cfg);
S
slguan 已提交
857 858

  cfg.option = "jniDebugFlag";
guanshengliang's avatar
guanshengliang 已提交
859
  cfg.ptr = &jniDebugFlag;
S
slguan 已提交
860 861 862 863 864 865
  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;
866
  taosAddConfigOption(cfg);
S
slguan 已提交
867 868 869 870 871 872 873 874 875

  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;
876
  taosAddConfigOption(cfg);
S
slguan 已提交
877 878

  cfg.option = "qDebugFlag";
guanshengliang's avatar
guanshengliang 已提交
879
  cfg.ptr = &qDebugFlag;
S
slguan 已提交
880 881 882 883 884 885
  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;
886
  taosAddConfigOption(cfg);
S
slguan 已提交
887

S
Shengliang Guan 已提交
888 889 890 891 892 893 894 895
  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;
896
  taosAddConfigOption(cfg);
S
Shengliang Guan 已提交
897

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

S
TD-1520  
Shengliang Guan 已提交
908 909 910 911 912 913 914 915
  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;
916
  taosAddConfigOption(cfg);
S
TD-1520  
Shengliang Guan 已提交
917

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

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

  // 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;
947
  taosAddConfigOption(cfg);
S
slguan 已提交
948 949 950 951 952 953 954 955 956

  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;
957
  taosAddConfigOption(cfg);
S
slguan 已提交
958 959 960 961 962 963 964 965 966

  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;
967
  taosAddConfigOption(cfg);
S
slguan 已提交
968 969 970 971 972 973 974 975 976

  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;
977
  taosAddConfigOption(cfg);
978 979 980 981 982 983

  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;
984
  cfg.maxValue = 65536;
985 986
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
987
  taosAddConfigOption(cfg);
988 989 990 991 992 993 994

  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 已提交
995
  cfg.ptrLength = PATH_MAX;
996
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
997
  taosAddConfigOption(cfg);
998

S
Shengliang Guan 已提交
999
  // enable kill long query
1000 1001 1002 1003 1004 1005 1006 1007
  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;
1008
  taosAddConfigOption(cfg);
1009

T
tickduan 已提交
1010
#ifdef TD_TSZ
T
tickduan 已提交
1011
  // lossy compress
T
tickduan 已提交
1012
  cfg.option = "lossyColumns";
T
tickduan 已提交
1013 1014 1015 1016 1017 1018 1019
  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;
1020
  taosAddConfigOption(cfg);
T
tickduan 已提交
1021 1022 1023 1024 1025

  cfg.option = "fPrecision";
  cfg.ptr = &fPrecision;
  cfg.valType = TAOS_CFG_VTYPE_DOUBLE;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG;
T
tickduan 已提交
1026
  cfg.minValue = MIN_FLOAT;
S
config  
Shengliang Guan 已提交
1027
  cfg.maxValue = 100000;
T
tickduan 已提交
1028 1029
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
T
tickduan 已提交
1030

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

  cfg.option = "dPrecision";
  cfg.ptr = &dPrecision;
  cfg.valType = TAOS_CFG_VTYPE_DOUBLE;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG;
S
config  
Shengliang Guan 已提交
1037 1038
  cfg.minValue = 100000;
  cfg.maxValue = 0;
T
tickduan 已提交
1039 1040
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
1041
  taosAddConfigOption(cfg);
T
tickduan 已提交
1042

T
tickduan 已提交
1043 1044
  cfg.option = "maxRange";
  cfg.ptr = &maxRange;
T
tickduan 已提交
1045 1046 1047 1048 1049 1050
  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;
1051
  taosAddConfigOption(cfg);
T
tickduan 已提交
1052

T
tickduan 已提交
1053
  cfg.option = "range";
T
tickduan 已提交
1054
  cfg.ptr = &curRange;
T
tickduan 已提交
1055 1056 1057 1058 1059 1060
  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;
1061
  taosAddConfigOption(cfg);
1062 1063
  assert(tsGlobalConfigNum == TSDB_CFG_MAX_NUM);
#else
S
Shengliang Guan 已提交
1064
  // assert(tsGlobalConfigNum == TSDB_CFG_MAX_NUM - 5);
1065
#endif
S
config  
Shengliang Guan 已提交
1066 1067

#endif
S
slguan 已提交
1068 1069
}

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

1072
int32_t taosCheckAndPrintCfg() {
S
config  
Shengliang Guan 已提交
1073 1074
#if 0

H
Haojun Liao 已提交
1075
  SEp ep = {0};
S
Shengliang Guan 已提交
1076
  if (debugFlag & DEBUG_TRACE || debugFlag & DEBUG_DEBUG || debugFlag & DEBUG_DUMP) {
guanshengliang's avatar
guanshengliang 已提交
1077 1078
    taosSetAllDebugFlag();
  }
S
Shengliang Guan 已提交
1079

H
Hui Li 已提交
1080 1081 1082 1083
  if (tsLocalFqdn[0] == 0) {
    taosGetFqdn(tsLocalFqdn);
  }

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

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

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

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

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

S
slguan 已提交
1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119
  taosGetSystemInfo();

  tsSetLocale();

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

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

1120
  if (tsQueryBufferSize >= 0) {
D
fix bug  
dapan1121 已提交
1121
    tsQueryBufferSizeBytes = tsQueryBufferSize * 1048576UL;
1122 1123
  }

1124 1125
  uInfo("   check global cfg completed");
  uInfo("==================================");
1126
  taosPrintCfg();
S
config  
Shengliang Guan 已提交
1127
#endif
S
TD-1663  
Shengliang Guan 已提交
1128
  return 0;
S
slguan 已提交
1129
}
J
jtao1735 已提交
1130

1131 1132 1133 1134
/*
 * alter dnode 1 balance "vnode:1-dnode:2"
 */

S
Shengliang Guan 已提交
1135
bool taosCheckBalanceCfgOptions(const char *option, int32_t *vnodeId, int32_t *dnodeId) {
1136
  int len = (int)strlen(option);
1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150
  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 已提交
1151 1152 1153
  *vnodeId = strtol(option + 6, NULL, 10);
  *dnodeId = strtol(option + pos + 6, NULL, 10);
  if (*vnodeId <= 1 || *dnodeId <= 0) {
1154 1155 1156 1157
    return false;
  }

  return true;
1158
}