tglobal.c 34.2 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 tsMaxSQLStringLen = TSDB_MAX_ALLOWED_SQL_LEN;
82
int32_t tsMaxWildCardsLen = TSDB_PATTERN_STRING_DEFAULT_LEN;
83 84
int32_t tsMaxRegexStringLen = TSDB_REGEX_STRING_DEFAULT_LEN;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

174

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

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

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

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

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

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

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

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

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

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

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

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

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

  return false;
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

S
slguan 已提交
597 598 599 600 601 602 603 604
  cfg.option = "maxSQLLength";
  cfg.ptr = &tsMaxSQLStringLen;
  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_BYTE;
605
  taosAddConfigOption(cfg);
S
slguan 已提交
606

607 608
  cfg.option = "maxWildCardsLength";
  cfg.ptr = &tsMaxWildCardsLen;
609 610 611
  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;
612
  cfg.maxValue = TSDB_MAX_FIELD_LEN;
613 614
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_BYTE;
615
  taosAddConfigOption(cfg);
616

617 618 619 620 621 622 623 624
  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;
625
  taosAddConfigOption(cfg);
626

S
slguan 已提交
627 628 629 630 631 632 633 634
  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;
635
  taosAddConfigOption(cfg);
S
slguan 已提交
636

H
Haojun Liao 已提交
637 638 639 640 641
  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 已提交
642
  cfg.maxValue = 500000000000.0f;
H
Haojun Liao 已提交
643 644
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_BYTE;
645
  taosAddConfigOption(cfg);
H
Haojun Liao 已提交
646

H
Haojun Liao 已提交
647 648
  cfg.option = "retrieveBlockingModel";
  cfg.ptr = &tsRetrieveBlockingModel;
649 650 651 652 653 654
  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;
655
  taosAddConfigOption(cfg);
656

657 658
  cfg.option = "keepColumnName";
  cfg.ptr = &tsKeepOriginalColumnName;
S
Shengliang Guan 已提交
659
  cfg.valType = TAOS_CFG_VTYPE_INT8;
660 661 662 663 664
  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;
665
  taosAddConfigOption(cfg);
666

S
slguan 已提交
667 668 669 670
  // locale & charset
  cfg.option = "timezone";
  cfg.ptr = tsTimezone;
  cfg.valType = TAOS_CFG_VTYPE_STRING;
671
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW | TSDB_CFG_CTYPE_B_CLIENT;
S
slguan 已提交
672 673
  cfg.minValue = 0;
  cfg.maxValue = 0;
S
Shengliang Guan 已提交
674
  cfg.ptrLength = TSDB_TIMEZONE_LEN;
S
slguan 已提交
675
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
676
  taosAddConfigOption(cfg);
S
slguan 已提交
677 678 679 680

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

  cfg.option = "charset";
  cfg.ptr = tsCharset;
  cfg.valType = TAOS_CFG_VTYPE_STRING;
691
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW | TSDB_CFG_CTYPE_B_CLIENT;
S
slguan 已提交
692 693
  cfg.minValue = 0;
  cfg.maxValue = 0;
S
Shengliang Guan 已提交
694
  cfg.ptrLength = TSDB_LOCALE_LEN;
S
slguan 已提交
695
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
696
  taosAddConfigOption(cfg);
S
slguan 已提交
697 698 699 700 701 702 703 704 705 706

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

709 710
  cfg.option = "maxConnections";
  cfg.ptr = &tsMaxConnections;
S
slguan 已提交
711 712
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
713
  cfg.minValue = 1;
714
  cfg.maxValue = 100000;
S
slguan 已提交
715 716
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
717
  taosAddConfigOption(cfg);
S
slguan 已提交
718 719 720 721 722

  cfg.option = "minimalLogDirGB";
  cfg.ptr = &tsMinimalLogDirGB;
  cfg.valType = TAOS_CFG_VTYPE_FLOAT;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
723
  cfg.minValue = 0.001f;
S
slguan 已提交
724 725 726
  cfg.maxValue = 10000000;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_GB;
727
  taosAddConfigOption(cfg);
S
slguan 已提交
728 729

  cfg.option = "minimalTmpDirGB";
H
Haojun Liao 已提交
730
  cfg.ptr = &tsReservedTmpDirectorySpace;
S
slguan 已提交
731 732
  cfg.valType = TAOS_CFG_VTYPE_FLOAT;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
733
  cfg.minValue = 0.001f;
S
slguan 已提交
734 735 736
  cfg.maxValue = 10000000;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_GB;
737
  taosAddConfigOption(cfg);
S
slguan 已提交
738 739 740 741 742

  cfg.option = "minimalDataDirGB";
  cfg.ptr = &tsMinimalDataDirGB;
  cfg.valType = TAOS_CFG_VTYPE_FLOAT;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
743
  cfg.minValue = 0.001f;
S
slguan 已提交
744 745 746
  cfg.maxValue = 10000000;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_GB;
747
  taosAddConfigOption(cfg);
S
TD-2498  
Shengliang Guan 已提交
748 749 750

  cfg.option = "slaveQuery";
  cfg.ptr = &tsEnableSlaveQuery;
S
Shengliang Guan 已提交
751 752 753 754 755 756
  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;
757
  taosAddConfigOption(cfg);
S
Shengliang Guan 已提交
758

S
slguan 已提交
759 760 761 762 763
  // 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 已提交
764
  cfg.minValue = 1000;
S
slguan 已提交
765 766 767
  cfg.maxValue = 2000000000;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
768
  taosAddConfigOption(cfg);
S
slguan 已提交
769

770
  cfg.option = "logKeepDays";
S
TD-1263  
Shengliang Guan 已提交
771
  cfg.ptr = &tsLogKeepDays;
772 773
  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 已提交
774
  cfg.minValue = -365000;
S
TD-1263  
Shengliang Guan 已提交
775
  cfg.maxValue = 365000;
776 777
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
778
  taosAddConfigOption(cfg);
779

S
slguan 已提交
780 781
  cfg.option = "asyncLog";
  cfg.ptr = &tsAsyncLog;
S
Shengliang Guan 已提交
782
  cfg.valType = TAOS_CFG_VTYPE_INT8;
S
slguan 已提交
783 784 785 786 787
  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;
788
  taosAddConfigOption(cfg);
S
slguan 已提交
789 790 791 792 793 794 795 796 797

  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;
798
  taosAddConfigOption(cfg);
S
slguan 已提交
799 800

  cfg.option = "mDebugFlag";
guanshengliang's avatar
guanshengliang 已提交
801
  cfg.ptr = &mDebugFlag;
S
slguan 已提交
802 803 804 805 806 807
  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;
808
  taosAddConfigOption(cfg);
S
slguan 已提交
809 810

  cfg.option = "dDebugFlag";
811
  cfg.ptr = &dDebugFlag;
S
slguan 已提交
812 813 814 815 816 817
  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;
818
  taosAddConfigOption(cfg);
S
slguan 已提交
819

J
jtao1735 已提交
820 821 822 823 824 825 826 827
  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;
828
  taosAddConfigOption(cfg);
J
jtao1735 已提交
829

S
Shengliang Guan 已提交
830 831 832 833 834 835 836 837
  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;
838
  taosAddConfigOption(cfg);
S
Shengliang Guan 已提交
839

S
slguan 已提交
840 841 842 843 844 845 846 847
  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;
848
  taosAddConfigOption(cfg);
S
slguan 已提交
849 850 851 852 853 854 855 856 857

  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;
858
  taosAddConfigOption(cfg);
S
slguan 已提交
859 860

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

  cfg.option = "jniDebugFlag";
guanshengliang's avatar
guanshengliang 已提交
871
  cfg.ptr = &jniDebugFlag;
S
slguan 已提交
872 873 874 875 876 877
  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;
878
  taosAddConfigOption(cfg);
S
slguan 已提交
879 880 881 882 883 884 885 886 887

  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;
888
  taosAddConfigOption(cfg);
S
slguan 已提交
889 890

  cfg.option = "qDebugFlag";
guanshengliang's avatar
guanshengliang 已提交
891
  cfg.ptr = &qDebugFlag;
S
slguan 已提交
892 893 894 895 896 897
  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;
898
  taosAddConfigOption(cfg);
S
slguan 已提交
899

S
Shengliang Guan 已提交
900 901 902 903 904 905 906 907
  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;
908
  taosAddConfigOption(cfg);
S
Shengliang Guan 已提交
909

910 911 912
  cfg.option = "tsdbDebugFlag";
  cfg.ptr = &tsdbDebugFlag;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
913
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG;
914 915 916 917
  cfg.minValue = 0;
  cfg.maxValue = 255;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
918
  taosAddConfigOption(cfg);
919

S
TD-1520  
Shengliang Guan 已提交
920 921 922 923 924 925 926 927
  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;
928
  taosAddConfigOption(cfg);
S
TD-1520  
Shengliang Guan 已提交
929

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

  cfg.option = "enableCoreFile";
  cfg.ptr = &tsEnableCoreFile;
S
Shengliang Guan 已提交
942
  cfg.valType = TAOS_CFG_VTYPE_INT8;
S
slguan 已提交
943 944 945 946 947
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG;
  cfg.minValue = 0;
  cfg.maxValue = 1;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
948
  taosAddConfigOption(cfg);
S
slguan 已提交
949 950 951 952 953 954 955 956 957 958

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

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

  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;
979
  taosAddConfigOption(cfg);
S
slguan 已提交
980 981 982 983 984 985 986 987 988

  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;
989
  taosAddConfigOption(cfg);
990 991 992 993 994 995

  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;
996
  cfg.maxValue = 65536;
997 998
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
999
  taosAddConfigOption(cfg);
1000 1001 1002 1003 1004 1005 1006

  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 已提交
1007
  cfg.ptrLength = PATH_MAX;
1008
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
1009
  taosAddConfigOption(cfg);
1010

S
Shengliang Guan 已提交
1011
  // enable kill long query
1012 1013 1014 1015 1016 1017 1018 1019
  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;
1020
  taosAddConfigOption(cfg);
1021

T
tickduan 已提交
1022
#ifdef TD_TSZ
T
tickduan 已提交
1023
  // lossy compress
T
tickduan 已提交
1024
  cfg.option = "lossyColumns";
T
tickduan 已提交
1025 1026 1027 1028 1029 1030 1031
  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;
1032
  taosAddConfigOption(cfg);
T
tickduan 已提交
1033 1034 1035 1036 1037

  cfg.option = "fPrecision";
  cfg.ptr = &fPrecision;
  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;
T
tickduan 已提交
1042

1043
  taosAddConfigOption(cfg);
T
tickduan 已提交
1044 1045 1046 1047 1048

  cfg.option = "dPrecision";
  cfg.ptr = &dPrecision;
  cfg.valType = TAOS_CFG_VTYPE_DOUBLE;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG;
T
tickduan 已提交
1049 1050
  cfg.minValue = MIN_FLOAT;
  cfg.maxValue = MAX_FLOAT;
T
tickduan 已提交
1051 1052
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
1053
  taosAddConfigOption(cfg);
T
tickduan 已提交
1054

T
tickduan 已提交
1055 1056
  cfg.option = "maxRange";
  cfg.ptr = &maxRange;
T
tickduan 已提交
1057 1058 1059 1060 1061 1062
  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;
1063
  taosAddConfigOption(cfg);
T
tickduan 已提交
1064

T
tickduan 已提交
1065
  cfg.option = "range";
T
tickduan 已提交
1066
  cfg.ptr = &curRange;
T
tickduan 已提交
1067 1068 1069 1070 1071 1072
  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;
1073
  taosAddConfigOption(cfg);
1074 1075
  assert(tsGlobalConfigNum == TSDB_CFG_MAX_NUM);
#else
S
Shengliang Guan 已提交
1076
  // assert(tsGlobalConfigNum == TSDB_CFG_MAX_NUM - 5);
1077
#endif
S
slguan 已提交
1078 1079
}

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

1082
int32_t taosCheckAndPrintCfg() {
S
Shengliang Guan 已提交
1083
  char     fqdn[TSDB_FQDN_LEN];
1084 1085
  uint16_t port;

S
Shengliang Guan 已提交
1086
  if (debugFlag & DEBUG_TRACE || debugFlag & DEBUG_DEBUG || debugFlag & DEBUG_DUMP) {
guanshengliang's avatar
guanshengliang 已提交
1087 1088
    taosSetAllDebugFlag();
  }
S
Shengliang Guan 已提交
1089

H
Hui Li 已提交
1090 1091 1092 1093
  if (tsLocalFqdn[0] == 0) {
    taosGetFqdn(tsLocalFqdn);
  }

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

S
slguan 已提交
1097 1098
  if (tsFirst[0] == 0) {
    strcpy(tsFirst, tsLocalEp);
1099 1100
  } else {
    taosGetFqdnPortFromEp(tsFirst, fqdn, &port);
R
root 已提交
1101
    snprintf(tsFirst, sizeof(tsFirst), "%s:%u", fqdn, port);
S
slguan 已提交
1102 1103
  }

J
jtao1735 已提交
1104 1105
  if (tsSecond[0] == 0) {
    strcpy(tsSecond, tsLocalEp);
1106 1107
  } else {
    taosGetFqdnPortFromEp(tsSecond, fqdn, &port);
R
root 已提交
1108
    snprintf(tsSecond, sizeof(tsSecond), "%s:%u", fqdn, port);
S
slguan 已提交
1109
  }
1110

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

1113
  if (taosDirExist(tsTempDir) != 0) {
D
fix bug  
dapan1121 已提交
1114 1115
    return -1;
  }
S
Shengliang Guan 已提交
1116

S
slguan 已提交
1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129
  taosGetSystemInfo();

  tsSetLocale();

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

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

1130
  if (tsQueryBufferSize >= 0) {
D
fix bug  
dapan1121 已提交
1131
    tsQueryBufferSizeBytes = tsQueryBufferSize * 1048576UL;
1132 1133
  }

1134 1135
  uInfo("   check global cfg completed");
  uInfo("==================================");
1136
  taosPrintCfg();
S
TD-1663  
Shengliang Guan 已提交
1137

S
TD-1663  
Shengliang Guan 已提交
1138
  return 0;
S
slguan 已提交
1139
}
J
jtao1735 已提交
1140

1141 1142 1143 1144
/*
 * alter dnode 1 balance "vnode:1-dnode:2"
 */

S
Shengliang Guan 已提交
1145
bool taosCheckBalanceCfgOptions(const char *option, int32_t *vnodeId, int32_t *dnodeId) {
1146
  int len = (int)strlen(option);
1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160
  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 已提交
1161 1162 1163
  *vnodeId = strtol(option + 6, NULL, 10);
  *dnodeId = strtol(option + pos + 6, NULL, 10);
  if (*vnodeId <= 1 || *dnodeId <= 0) {
1164 1165 1166 1167
    return false;
  }

  return true;
1168
}