提交 f62e4b95 编写于 作者: S slguan

[TD-183]

上级 58c603d1
...@@ -48,11 +48,9 @@ extern int32_t tsEnableCoreFile; ...@@ -48,11 +48,9 @@ extern int32_t tsEnableCoreFile;
extern int32_t tsTotalMemoryMB; extern int32_t tsTotalMemoryMB;
extern int32_t tsVersion; extern int32_t tsVersion;
extern int tscEmbedded; extern int32_t tscEmbedded;
extern int64_t tsMsPerDay[2]; extern int64_t tsMsPerDay[2];
extern char tsMasterIp[]; extern char tsMasterIp[];
extern char tsSecondIp[]; extern char tsSecondIp[];
extern uint16_t tsMnodeDnodePort; extern uint16_t tsMnodeDnodePort;
...@@ -61,94 +59,88 @@ extern uint16_t tsDnodeShellPort; ...@@ -61,94 +59,88 @@ extern uint16_t tsDnodeShellPort;
extern uint16_t tsDnodeMnodePort; extern uint16_t tsDnodeMnodePort;
extern uint16_t tsSyncPort; extern uint16_t tsSyncPort;
extern int tsStatusInterval; extern int32_t tsStatusInterval;
extern int tsShellActivityTimer; extern int32_t tsShellActivityTimer;
extern int tsVnodePeerHBTimer; extern int32_t tsVnodePeerHBTimer;
extern int tsMgmtPeerHBTimer; extern int32_t tsMgmtPeerHBTimer;
extern int tsMeterMetaKeepTimer; extern int32_t tsMeterMetaKeepTimer;
extern int tsMetricMetaKeepTimer; extern int32_t tsMetricMetaKeepTimer;
extern float tsNumOfThreadsPerCore; extern float tsNumOfThreadsPerCore;
extern float tsRatioOfQueryThreads; extern float tsRatioOfQueryThreads;
extern char tsPublicIp[]; extern char tsPublicIp[];
extern char tsPrivateIp[]; extern char tsPrivateIp[];
extern short tsNumOfVnodesPerCore; extern int16_t tsNumOfVnodesPerCore;
extern short tsNumOfTotalVnodes; extern int16_t tsNumOfTotalVnodes;
extern short tsCheckHeaderFile;
extern uint32_t tsPublicIpInt; extern uint32_t tsPublicIpInt;
extern short tsAffectedRowsMod;
extern int tsSessionsPerVnode;
extern int tsAverageCacheBlocks;
extern int tsCacheBlockSize;
extern int tsRowsInFileBlock; extern int32_t tsMaxCacheSize;
extern float tsFileBlockMinPercent; extern int32_t tsSessionsPerVnode;
extern int16_t tsDaysPerFile;
extern short tsNumOfBlocksPerMeter; extern int32_t tsDaysToKeep;
extern short tsCommitTime; // seconds extern int32_t tsRowsInFileBlock;
extern short tsCommitLog; extern int16_t tsCommitTime; // seconds
extern short tsAsyncLog; extern int32_t tsTimePrecision;
extern short tsCompression; extern int16_t tsCompression;
extern short tsDaysPerFile; extern int16_t tsCommitLog;
extern int tsDaysToKeep; extern int32_t tsReplications;
extern int tsReplications;
extern int16_t tsAffectedRowsMod;
extern int tsNumOfMPeers; extern int32_t tsNumOfMPeers;
extern int tsMaxShellConns; extern int32_t tsMaxShellConns;
extern int tsMaxTables; extern int32_t tsMaxTables;
extern char tsLocalIp[]; extern char tsLocalIp[];
extern char tsDefaultDB[]; extern char tsDefaultDB[];
extern char tsDefaultUser[]; extern char tsDefaultUser[];
extern char tsDefaultPass[]; extern char tsDefaultPass[];
extern int tsMaxMeterConnections; extern int32_t tsMaxMeterConnections;
extern int tsMaxVnodeConnections; extern int32_t tsMaxVnodeConnections;
extern int tsMaxMgmtConnections; extern int32_t tsMaxMgmtConnections;
extern int tsBalanceMonitorInterval; extern int32_t tsBalanceMonitorInterval;
extern int tsBalanceStartInterval; extern int32_t tsBalanceStartInterval;
extern int tsBalancePolicy; extern int32_t tsOfflineThreshold;
extern int tsOfflineThreshold; extern int32_t tsMgmtEqualVnodeNum;
extern int tsMgmtEqualVnodeNum;
extern int32_t tsEnableHttpModule;
extern int tsEnableHttpModule; extern int32_t tsEnableMonitorModule;
extern int tsEnableMonitorModule;
extern int tsRestRowLimit; extern int32_t tsRestRowLimit;
extern int tsCompressMsgSize; extern int32_t tsMaxSQLStringLen;
extern int tsMaxSQLStringLen; extern int32_t tsCompressMsgSize;
extern int tsMaxNumOfOrderedResults; extern int32_t tsMaxNumOfOrderedResults;
extern char tsSocketType[4]; extern char tsSocketType[4];
extern int tsTimePrecision; extern int32_t tsMinSlidingTime;
extern int tsMinSlidingTime; extern int32_t tsMinIntervalTime;
extern int tsMinIntervalTime; extern int32_t tsMaxStreamComputDelay;
extern int tsMaxStreamComputDelay; extern int32_t tsStreamCompStartDelay;
extern int tsStreamCompStartDelay; extern int32_t tsStreamCompRetryDelay;
extern int tsStreamCompRetryDelay;
extern float tsStreamComputDelayRatio; // the delayed computing ration of the whole time window extern float tsStreamComputDelayRatio; // the delayed computing ration of the whole time window
extern int tsProjectExecInterval; extern int tsProjectExecInterval;
extern int64_t tsMaxRetentWindow; extern int64_t tsMaxRetentWindow;
extern char tsHttpIp[]; extern char tsHttpIp[];
extern uint16_t tsHttpPort; extern uint16_t tsHttpPort;
extern int tsHttpCacheSessions; extern int32_t tsHttpCacheSessions;
extern int tsHttpSessionExpire; extern int32_t tsHttpSessionExpire;
extern int tsHttpMaxThreads; extern int32_t tsHttpMaxThreads;
extern int tsHttpEnableCompress; extern int32_t tsHttpEnableCompress;
extern int tsHttpEnableRecordSql; extern int32_t tsHttpEnableRecordSql;
extern int tsTelegrafUseFieldNum; extern int32_t tsTelegrafUseFieldNum;
extern int tsTscEnableRecordSql; extern int32_t tsTscEnableRecordSql;
extern int tsAnyIp; extern int32_t tsAnyIp;
extern char tsMonitorDbName[]; extern char tsMonitorDbName[];
extern char tsInternalPass[]; extern char tsInternalPass[];
extern int tsMonitorInterval; extern int32_t tsMonitorInterval;
extern int tsNumOfLogLines; extern int32_t tsAsyncLog;
extern int32_t tsNumOfLogLines;
extern int32_t ddebugFlag; extern int32_t ddebugFlag;
extern int32_t mdebugFlag; extern int32_t mdebugFlag;
extern int32_t cdebugFlag; extern int32_t cdebugFlag;
......
...@@ -74,16 +74,15 @@ int32_t tsVnodePeerHBTimer = 1; // second ...@@ -74,16 +74,15 @@ int32_t tsVnodePeerHBTimer = 1; // second
int32_t tsMgmtPeerHBTimer = 1; // second int32_t tsMgmtPeerHBTimer = 1; // second
int32_t tsMeterMetaKeepTimer = 7200; // second int32_t tsMeterMetaKeepTimer = 7200; // second
int32_t tsMetricMetaKeepTimer = 600; // second int32_t tsMetricMetaKeepTimer = 600; // second
int tsRpcTimer = 300; int32_t tsRpcTimer = 300;
int tsRpcMaxTime = 600; // seconds; int32_t tsRpcMaxTime = 600; // seconds;
float tsNumOfThreadsPerCore = 1.0; float tsNumOfThreadsPerCore = 1.0;
float tsRatioOfQueryThreads = 0.5; float tsRatioOfQueryThreads = 0.5;
char tsPublicIp[TSDB_IPv4ADDR_LEN] = {0}; char tsPublicIp[TSDB_IPv4ADDR_LEN] = {0};
char tsPrivateIp[TSDB_IPv4ADDR_LEN] = {0}; char tsPrivateIp[TSDB_IPv4ADDR_LEN] = {0};
int16_t tsNumOfVnodesPerCore = 8; int16_t tsNumOfVnodesPerCore = 8;
int16_t tsNumOfTotalVnodes = TSDB_INVALID_VNODE_NUM; int16_t tsNumOfTotalVnodes = TSDB_INVALID_VNODE_NUM;
int16_t tsCheckHeaderFile = 0;
#ifdef _TD_ARM_32_ #ifdef _TD_ARM_32_
int32_t tsSessionsPerVnode = 100; int32_t tsSessionsPerVnode = 100;
...@@ -91,26 +90,22 @@ int32_t tsSessionsPerVnode = 100; ...@@ -91,26 +90,22 @@ int32_t tsSessionsPerVnode = 100;
int32_t tsSessionsPerVnode = 1000; int32_t tsSessionsPerVnode = 1000;
#endif #endif
int32_t tsCacheBlockSize = 16384; // 256 columns int32_t tsMaxCacheSize = 64; //64M
int32_t tsAverageCacheBlocks = TSDB_DEFAULT_AVG_BLOCKS; int16_t tsDaysPerFile = 10;
int32_t tsDaysToKeep = 3650;
int32_t tsRowsInFileBlock = 4096;
int16_t tsCommitTime = 3600; // seconds
int32_t tsTimePrecision = TSDB_TIME_PRECISION_MILLI;
int16_t tsCompression = TSDB_MAX_COMPRESSION_LEVEL;
int16_t tsCommitLog = 1;
int32_t tsReplications = TSDB_REPLICA_MIN_NUM;
/** /**
* Change the meaning of affected rows: * Change the meaning of affected rows:
* 0: affected rows not include those duplicate records * 0: affected rows not include those duplicate records
* 1: affected rows include those duplicate records * 1: affected rows include those duplicate records
*/ */
int16_t tsAffectedRowsMod = 0; int16_t tsAffectedRowsMod = 0;
int32_t tsRowsInFileBlock = 4096;
float tsFileBlockMinPercent = 0.05;
int16_t tsNumOfBlocksPerMeter = 100;
int16_t tsCommitTime = 3600; // seconds
int16_t tsCommitLog = 1;
int16_t tsCompression = TSDB_MAX_COMPRESSION_LEVEL;
int16_t tsDaysPerFile = 10;
int32_t tsDaysToKeep = 3650;
int32_t tsReplications = TSDB_REPLICA_MIN_NUM;
int32_t tsNumOfMPeers = 3; int32_t tsNumOfMPeers = 3;
int32_t tsMaxShellConns = 2000; int32_t tsMaxShellConns = 2000;
int32_t tsMaxTables = 100000; int32_t tsMaxTables = 100000;
...@@ -125,15 +120,16 @@ int32_t tsMaxVnodeConnections = 10000; ...@@ -125,15 +120,16 @@ int32_t tsMaxVnodeConnections = 10000;
int32_t tsBalanceMonitorInterval = 2; // seconds int32_t tsBalanceMonitorInterval = 2; // seconds
int32_t tsBalanceStartInterval = 300; // seconds int32_t tsBalanceStartInterval = 300; // seconds
int32_t tsBalancePolicy = 0; // 1-use sys.montor
int32_t tsOfflineThreshold = 864000; // seconds 10days int32_t tsOfflineThreshold = 864000; // seconds 10days
int32_t tsMgmtEqualVnodeNum = 4; int32_t tsMgmtEqualVnodeNum = 4;
int32_t tsEnableHttpModule = 1; int32_t tsEnableHttpModule = 1;
int32_t tsEnableMonitorModule = 0; int32_t tsEnableMonitorModule = 0;
int32_t tsRestRowLimit = 10240; int32_t tsRestRowLimit = 10240;
int32_t tsMaxSQLStringLen = TSDB_MAX_SQL_LEN; int32_t tsMaxSQLStringLen = TSDB_MAX_SQL_LEN;
int32_t tsNumOfLogLines = 10000000;
int32_t mdebugFlag = 135; int32_t mdebugFlag = 135;
int32_t sdbDebugFlag = 135; int32_t sdbDebugFlag = 135;
int32_t ddebugFlag = 131; int32_t ddebugFlag = 131;
...@@ -146,7 +142,6 @@ int32_t qdebugFlag = 131; ...@@ -146,7 +142,6 @@ int32_t qdebugFlag = 131;
int32_t rpcDebugFlag = 131; int32_t rpcDebugFlag = 131;
int32_t uDebugFlag = 131; int32_t uDebugFlag = 131;
int32_t debugFlag = 131; int32_t debugFlag = 131;
int tsNumOfLogLines = 10000000;
// the maximum number of results for projection query on super table that are returned from // the maximum number of results for projection query on super table that are returned from
// one virtual node, to order according to timestamp // one virtual node, to order according to timestamp
...@@ -165,9 +160,6 @@ int32_t tsCompressMsgSize = -1; ...@@ -165,9 +160,6 @@ int32_t tsCompressMsgSize = -1;
// use UDP by default[option: udp, tcp] // use UDP by default[option: udp, tcp]
char tsSocketType[4] = "udp"; char tsSocketType[4] = "udp";
// time precision, millisecond by default
int32_t tsTimePrecision = TSDB_TIME_PRECISION_MILLI;
// 10 ms for sliding time, the value will changed in case of time precision changed // 10 ms for sliding time, the value will changed in case of time precision changed
int32_t tsMinSlidingTime = 10; int32_t tsMinSlidingTime = 10;
...@@ -747,11 +739,11 @@ static void doInitGlobalConfig() { ...@@ -747,11 +739,11 @@ static void doInitGlobalConfig() {
taosInitConfigOption(cfg); taosInitConfigOption(cfg);
cfg.option = "cache"; cfg.option = "cache";
cfg.ptr = &tsCacheBlockSize; cfg.ptr = &tsMaxCacheSize;
cfg.valType = TAOS_CFG_VTYPE_INT32; cfg.valType = TAOS_CFG_VTYPE_INT32;
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW; cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
cfg.minValue = 100; cfg.minValue = 1;
cfg.maxValue = 1048576; cfg.maxValue = 100000;
cfg.ptrLength = 0; cfg.ptrLength = 0;
cfg.unitType = TAOS_CFG_UTYPE_BYTE; cfg.unitType = TAOS_CFG_UTYPE_BYTE;
taosInitConfigOption(cfg); taosInitConfigOption(cfg);
...@@ -766,36 +758,6 @@ static void doInitGlobalConfig() { ...@@ -766,36 +758,6 @@ static void doInitGlobalConfig() {
cfg.unitType = TAOS_CFG_UTYPE_NONE; cfg.unitType = TAOS_CFG_UTYPE_NONE;
taosInitConfigOption(cfg); taosInitConfigOption(cfg);
cfg.option = "fileBlockMinPercent";
cfg.ptr = &tsFileBlockMinPercent;
cfg.valType = TAOS_CFG_VTYPE_FLOAT;
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG;
cfg.minValue = 0;
cfg.maxValue = 1.0;
cfg.ptrLength = 0;
cfg.unitType = TAOS_CFG_UTYPE_NONE;
taosInitConfigOption(cfg);
cfg.option = "ablocks";
cfg.ptr = &tsAverageCacheBlocks;
cfg.valType = TAOS_CFG_VTYPE_INT32;
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
cfg.minValue = TSDB_MIN_AVG_BLOCKS;
cfg.maxValue = TSDB_MAX_AVG_BLOCKS;
cfg.ptrLength = 0;
cfg.unitType = TAOS_CFG_UTYPE_NONE;
taosInitConfigOption(cfg);
cfg.option = "tblocks";
cfg.ptr = &tsNumOfBlocksPerMeter;
cfg.valType = TAOS_CFG_VTYPE_INT16;
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
cfg.minValue = 32;
cfg.maxValue = 4096;
cfg.ptrLength = 0;
cfg.unitType = TAOS_CFG_UTYPE_NONE;
taosInitConfigOption(cfg);
// login configs // login configs
cfg.option = "defaultDB"; cfg.option = "defaultDB";
cfg.ptr = tsDefaultDB; cfg.ptr = tsDefaultDB;
......
...@@ -218,9 +218,6 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size); ...@@ -218,9 +218,6 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size);
#define TSDB_MAX_MGMT_IPS (TSDB_MAX_MPEERS+1) #define TSDB_MAX_MGMT_IPS (TSDB_MAX_MPEERS+1)
#define TSDB_REPLICA_MIN_NUM 1 #define TSDB_REPLICA_MIN_NUM 1
/*
* this is defined in CMakeList.txt
*/
#define TSDB_REPLICA_MAX_NUM 3 #define TSDB_REPLICA_MAX_NUM 3
#define TSDB_TBNAME_COLUMN_INDEX (-1) #define TSDB_TBNAME_COLUMN_INDEX (-1)
...@@ -242,8 +239,8 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size); ...@@ -242,8 +239,8 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size);
#define TSDB_MIN_ROWS_IN_FILEBLOCK 200 #define TSDB_MIN_ROWS_IN_FILEBLOCK 200
#define TSDB_MAX_ROWS_IN_FILEBLOCK 500000 #define TSDB_MAX_ROWS_IN_FILEBLOCK 500000
#define TSDB_MIN_CACHE_BLOCK_SIZE 100 #define TSDB_MIN_CACHE_BLOCK_SIZE 1
#define TSDB_MAX_CACHE_BLOCK_SIZE 104857600 #define TSDB_MAX_CACHE_BLOCK_SIZE 1000000
#define TSDB_MIN_CACHE_BLOCKS 100 #define TSDB_MIN_CACHE_BLOCKS 100
#define TSDB_MAX_CACHE_BLOCKS 409600 #define TSDB_MAX_CACHE_BLOCKS 409600
......
...@@ -29,32 +29,6 @@ struct SAcctObj; ...@@ -29,32 +29,6 @@ struct SAcctObj;
struct SUserObj; struct SUserObj;
struct SMnodeObj; struct SMnodeObj;
typedef struct {
char acct[TSDB_USER_LEN];
char db[TSDB_DB_NAME_LEN];
uint32_t vgId;
int32_t maxSessions;
int32_t cacheBlockSize;
union {
int32_t totalBlocks;
float fraction;
} cacheNumOfBlocks;
int32_t daysPerFile;
int32_t daysToKeep1;
int32_t daysToKeep2;
int32_t daysToKeep;
int32_t commitTime;
int32_t rowsInFileBlock;
int16_t blocksPerTable;
int8_t compression;
int8_t commitLog;
int8_t replications;
int8_t repStrategy;
int8_t loadLatest; // load into mem or not
uint8_t precision; // time resolution
int8_t reserved[16];
} SDbCfg;
typedef struct SDnodeObj { typedef struct SDnodeObj {
int32_t dnodeId; int32_t dnodeId;
uint32_t privateIp; uint32_t privateIp;
...@@ -168,12 +142,30 @@ typedef struct SVgObj { ...@@ -168,12 +142,30 @@ typedef struct SVgObj {
SChildTableObj **tableList; SChildTableObj **tableList;
} SVgObj; } SVgObj;
typedef struct {
int64_t maxCacheSize;
int32_t maxTables;
int32_t daysPerFile;
int32_t daysToKeep;
int32_t daysToKeep1;
int32_t daysToKeep2;
int32_t minRowsPerFileBlock; // minimum rows per file block
int32_t maxRowsPerFileBlock; // maximum rows per file block
int32_t commitTime;
int8_t precision;
int8_t compression;
int8_t commitLog;
int8_t replications;
int8_t reserved[16];
} SDbCfg;
typedef struct SDbObj { typedef struct SDbObj {
char name[TSDB_DB_NAME_LEN + 1]; char name[TSDB_DB_NAME_LEN + 1];
int8_t status; char acct[TSDB_USER_LEN + 1];
int64_t createdTime; int64_t createdTime;
SDbCfg cfg; SDbCfg cfg;
int8_t reserved[15]; int8_t status;
int8_t reserved[14];
int8_t updateEnd[1]; int8_t updateEnd[1];
int32_t refCount; int32_t refCount;
int32_t numOfVgroups; int32_t numOfVgroups;
......
...@@ -54,7 +54,7 @@ static int32_t mgmtDbActionDestroy(SSdbOper *pOper) { ...@@ -54,7 +54,7 @@ static int32_t mgmtDbActionDestroy(SSdbOper *pOper) {
static int32_t mgmtDbActionInsert(SSdbOper *pOper) { static int32_t mgmtDbActionInsert(SSdbOper *pOper) {
SDbObj *pDb = pOper->pObj; SDbObj *pDb = pOper->pObj;
SAcctObj *pAcct = mgmtGetAcct(pDb->cfg.acct); SAcctObj *pAcct = mgmtGetAcct(pDb->acct);
pDb->pHead = NULL; pDb->pHead = NULL;
pDb->pTail = NULL; pDb->pTail = NULL;
...@@ -67,7 +67,7 @@ static int32_t mgmtDbActionInsert(SSdbOper *pOper) { ...@@ -67,7 +67,7 @@ static int32_t mgmtDbActionInsert(SSdbOper *pOper) {
mgmtDecAcctRef(pAcct); mgmtDecAcctRef(pAcct);
} }
else { else {
mError("db:%s, acct:%s info not exist in sdb", pDb->name, pDb->cfg.acct); mError("db:%s, acct:%s info not exist in sdb", pDb->name, pDb->acct);
return TSDB_CODE_INVALID_ACCT; return TSDB_CODE_INVALID_ACCT;
} }
...@@ -76,7 +76,7 @@ static int32_t mgmtDbActionInsert(SSdbOper *pOper) { ...@@ -76,7 +76,7 @@ static int32_t mgmtDbActionInsert(SSdbOper *pOper) {
static int32_t mgmtDbActionDelete(SSdbOper *pOper) { static int32_t mgmtDbActionDelete(SSdbOper *pOper) {
SDbObj *pDb = pOper->pObj; SDbObj *pDb = pOper->pObj;
SAcctObj *pAcct = mgmtGetAcct(pDb->cfg.acct); SAcctObj *pAcct = mgmtGetAcct(pDb->acct);
mgmtDropDbFromAcct(pAcct, pDb); mgmtDropDbFromAcct(pAcct, pDb);
mgmtDropAllChildTables(pDb); mgmtDropAllChildTables(pDb);
...@@ -176,132 +176,108 @@ SDbObj *mgmtGetDbByTableId(char *tableId) { ...@@ -176,132 +176,108 @@ SDbObj *mgmtGetDbByTableId(char *tableId) {
return (SDbObj *)sdbGetRow(tsDbSdb, db); return (SDbObj *)sdbGetRow(tsDbSdb, db);
} }
static int32_t mgmtCheckDBParams(SCMCreateDbMsg *pCreate) { static int32_t mgmtCheckDbCfg(SDbCfg *pCfg) {
if (pCreate->commitLog < 0 || pCreate->commitLog > 2) { if (pCfg->maxCacheSize < TSDB_MIN_CACHE_BLOCK_SIZE || pCfg->maxCacheSize > TSDB_MAX_CACHE_BLOCK_SIZE) {
mError("invalid db option commitLog: %d, only 0-2 allowed", pCreate->commitLog); mError("invalid db option maxCacheSize:%d valid range: [%d, %d]", pCfg->maxCacheSize, TSDB_MIN_CACHE_BLOCK_SIZE,
return TSDB_CODE_INVALID_OPTION; TSDB_MAX_CACHE_BLOCK_SIZE);
} }
if (pCreate->replications < TSDB_REPLICA_MIN_NUM || pCreate->replications > TSDB_REPLICA_MAX_NUM) { if (pCfg->maxTables < TSDB_MIN_TABLES_PER_VNODE || pCfg->maxTables > TSDB_MAX_TABLES_PER_VNODE) {
mError("invalid db option replications: %d valid range: [%d, %d]", pCreate->replications, TSDB_REPLICA_MIN_NUM, mError("invalid db option maxTables:%d valid range: [%d, %d]", pCfg->maxTables, TSDB_MIN_TABLES_PER_VNODE,
TSDB_REPLICA_MAX_NUM); TSDB_MAX_TABLES_PER_VNODE);
return TSDB_CODE_INVALID_OPTION; return TSDB_CODE_INVALID_OPTION;
} }
if (pCreate->daysPerFile < TSDB_FILE_MIN_PARTITION_RANGE || pCreate->daysPerFile > TSDB_FILE_MAX_PARTITION_RANGE) { if (pCfg->daysPerFile < TSDB_FILE_MIN_PARTITION_RANGE || pCfg->daysPerFile > TSDB_FILE_MAX_PARTITION_RANGE) {
mError("invalid db option daysPerFile: %d valid range: [%d, %d]", pCreate->daysPerFile, TSDB_FILE_MIN_PARTITION_RANGE, mError("invalid db option daysPerFile:%d valid range: [%d, %d]", pCfg->daysPerFile, TSDB_FILE_MIN_PARTITION_RANGE,
TSDB_FILE_MAX_PARTITION_RANGE); TSDB_FILE_MAX_PARTITION_RANGE);
return TSDB_CODE_INVALID_OPTION; return TSDB_CODE_INVALID_OPTION;
} }
if (pCreate->daysToKeep1 > pCreate->daysToKeep2 || pCreate->daysToKeep2 > pCreate->daysToKeep) { if (pCfg->daysToKeep1 < TSDB_FILE_MIN_PARTITION_RANGE || pCfg->daysToKeep1 < pCfg->daysPerFile) {
mError("invalid db option daystokeep1: %d, daystokeep2: %d, daystokeep: %d", pCreate->daysToKeep1, mError("invalid db option daystokeep:%d", pCfg->daysToKeep);
pCreate->daysToKeep2, pCreate->daysToKeep);
return TSDB_CODE_INVALID_OPTION; return TSDB_CODE_INVALID_OPTION;
} }
if (pCreate->daysToKeep1 < TSDB_FILE_MIN_PARTITION_RANGE || pCreate->daysToKeep1 < pCreate->daysPerFile) { if (pCfg->daysToKeep2 > pCfg->daysToKeep || pCfg->daysToKeep2 < pCfg->daysToKeep1) {
mError("invalid db option daystokeep: %d", pCreate->daysToKeep); mError("invalid db option daystokeep1:%d, daystokeep2:%d, daystokeep:%d", pCfg->daysToKeep1,
pCfg->daysToKeep2, pCfg->daysToKeep);
return TSDB_CODE_INVALID_OPTION;
}
if (pCfg->minRowsPerFileBlock < TSDB_MIN_ROWS_IN_FILEBLOCK || pCfg->minRowsPerFileBlock > TSDB_MAX_ROWS_IN_FILEBLOCK) {
mError("invalid db option minRowsPerFileBlock:%d valid range: [%d, %d]", pCfg->minRowsPerFileBlock,
TSDB_MIN_ROWS_IN_FILEBLOCK, TSDB_MAX_ROWS_IN_FILEBLOCK);
return TSDB_CODE_INVALID_OPTION; return TSDB_CODE_INVALID_OPTION;
} }
if (pCreate->rowsInFileBlock < TSDB_MIN_ROWS_IN_FILEBLOCK || pCreate->rowsInFileBlock > TSDB_MAX_ROWS_IN_FILEBLOCK) { if (pCfg->maxRowsPerFileBlock < TSDB_MIN_ROWS_IN_FILEBLOCK || pCfg->maxRowsPerFileBlock > TSDB_MAX_ROWS_IN_FILEBLOCK) {
mError("invalid db option rowsInFileBlock: %d valid range: [%d, %d]", pCreate->rowsInFileBlock, mError("invalid db option maxRowsPerFileBlock:%d valid range: [%d, %d]", pCfg->maxRowsPerFileBlock,
TSDB_MIN_ROWS_IN_FILEBLOCK, TSDB_MAX_ROWS_IN_FILEBLOCK); TSDB_MIN_ROWS_IN_FILEBLOCK, TSDB_MAX_ROWS_IN_FILEBLOCK);
return TSDB_CODE_INVALID_OPTION; return TSDB_CODE_INVALID_OPTION;
} }
if (pCreate->cacheBlockSize < TSDB_MIN_CACHE_BLOCK_SIZE || pCreate->cacheBlockSize > TSDB_MAX_CACHE_BLOCK_SIZE) { if (pCfg->maxRowsPerFileBlock < pCfg->minRowsPerFileBlock) {
mError("invalid db option cacheBlockSize: %d valid range: [%d, %d]", pCreate->cacheBlockSize, mError("invalid db option minRowsPerFileBlock:%d maxRowsPerFileBlock:%d", pCfg->minRowsPerFileBlock,
TSDB_MIN_CACHE_BLOCK_SIZE, TSDB_MAX_CACHE_BLOCK_SIZE); pCfg->maxRowsPerFileBlock);
return TSDB_CODE_INVALID_OPTION; return TSDB_CODE_INVALID_OPTION;
} }
if (pCreate->maxSessions < TSDB_MIN_TABLES_PER_VNODE || pCreate->maxSessions > TSDB_MAX_TABLES_PER_VNODE) { if (pCfg->commitTime < TSDB_MIN_COMMIT_TIME_INTERVAL || pCfg->commitTime > TSDB_MAX_COMMIT_TIME_INTERVAL) {
mError("invalid db option maxSessions: %d valid range: [%d, %d]", pCreate->maxSessions, TSDB_MIN_TABLES_PER_VNODE, mError("invalid db option commitTime:%d valid range: [%d, %d]", pCfg->commitTime, TSDB_MIN_COMMIT_TIME_INTERVAL,
TSDB_MAX_TABLES_PER_VNODE); TSDB_MAX_COMMIT_TIME_INTERVAL);
return TSDB_CODE_INVALID_OPTION; return TSDB_CODE_INVALID_OPTION;
} }
if (pCreate->precision != TSDB_TIME_PRECISION_MILLI && pCreate->precision != TSDB_TIME_PRECISION_MICRO) { if (pCfg->precision != TSDB_TIME_PRECISION_MILLI && pCfg->precision != TSDB_TIME_PRECISION_MICRO) {
mError("invalid db option timePrecision: %d valid value: [%d, %d]", pCreate->precision, TSDB_TIME_PRECISION_MILLI, mError("invalid db option timePrecision:%d valid value: [%d, %d]", pCfg->precision, TSDB_TIME_PRECISION_MILLI,
TSDB_TIME_PRECISION_MICRO); TSDB_TIME_PRECISION_MICRO);
return TSDB_CODE_INVALID_OPTION; return TSDB_CODE_INVALID_OPTION;
} }
if (pCreate->cacheNumOfBlocks.fraction < TSDB_MIN_AVG_BLOCKS || pCreate->cacheNumOfBlocks.fraction > TSDB_MAX_AVG_BLOCKS) { if (pCfg->compression < TSDB_MIN_COMPRESSION_LEVEL || pCfg->compression > TSDB_MAX_COMPRESSION_LEVEL) {
mError("invalid db option ablocks: %f valid value: [%d, %d]", pCreate->cacheNumOfBlocks.fraction, 0, TSDB_MAX_AVG_BLOCKS); mError("invalid db option compression:%d valid range: [%d, %d]", pCfg->compression, TSDB_MIN_COMPRESSION_LEVEL,
TSDB_MAX_COMPRESSION_LEVEL);
return TSDB_CODE_INVALID_OPTION; return TSDB_CODE_INVALID_OPTION;
} }
if (pCreate->commitTime < TSDB_MIN_COMMIT_TIME_INTERVAL || pCreate->commitTime > TSDB_MAX_COMMIT_TIME_INTERVAL) { if (pCfg->commitLog < 0 || pCfg->commitLog > 2) {
mError("invalid db option commitTime: %d valid range: [%d, %d]", pCreate->commitTime, TSDB_MIN_COMMIT_TIME_INTERVAL, mError("invalid db option commitLog:%d, only 0-2 allowed", pCfg->commitLog);
TSDB_MAX_COMMIT_TIME_INTERVAL);
return TSDB_CODE_INVALID_OPTION; return TSDB_CODE_INVALID_OPTION;
} }
if (pCreate->compression < TSDB_MIN_COMPRESSION_LEVEL || pCreate->compression > TSDB_MAX_COMPRESSION_LEVEL) { if (pCfg->replications < TSDB_REPLICA_MIN_NUM || pCfg->replications > TSDB_REPLICA_MAX_NUM) {
mError("invalid db option compression: %d valid range: [%d, %d]", pCreate->compression, TSDB_MIN_COMPRESSION_LEVEL, mError("invalid db option replications:%d valid range: [%d, %d]", pCfg->replications, TSDB_REPLICA_MIN_NUM,
TSDB_MAX_COMPRESSION_LEVEL); TSDB_REPLICA_MAX_NUM);
return TSDB_CODE_INVALID_OPTION; return TSDB_CODE_INVALID_OPTION;
} }
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
static int32_t mgmtCheckDbParams(SCMCreateDbMsg *pCreate) { static void mgmtSetDefaultDbCfg(SDbCfg *pCfg) {
// assign default parameters if (pCfg->maxCacheSize < 0) pCfg->maxCacheSize = tsMaxCacheSize;
if (pCreate->maxSessions < 0) pCreate->maxSessions = tsSessionsPerVnode; if (pCfg->maxTables < 0) pCfg->maxTables = tsSessionsPerVnode;
if (pCreate->cacheBlockSize < 0) pCreate->cacheBlockSize = tsCacheBlockSize; if (pCfg->daysPerFile < 0) pCfg->daysPerFile = tsDaysPerFile;
if (pCreate->daysPerFile < 0) pCreate->daysPerFile = tsDaysPerFile; if (pCfg->daysToKeep < 0) pCfg->daysToKeep = tsDaysToKeep;
if (pCreate->daysToKeep < 0) pCreate->daysToKeep = tsDaysToKeep; if (pCfg->daysToKeep1 < 0) pCfg->daysToKeep1 = pCfg->daysToKeep;
if (pCreate->daysToKeep1 < 0) pCreate->daysToKeep1 = pCreate->daysToKeep; if (pCfg->daysToKeep2 < 0) pCfg->daysToKeep2 = pCfg->daysToKeep;
if (pCreate->daysToKeep2 < 0) pCreate->daysToKeep2 = pCreate->daysToKeep; if (pCfg->minRowsPerFileBlock < 0) pCfg->minRowsPerFileBlock = tsRowsInFileBlock;
if (pCreate->commitTime < 0) pCreate->commitTime = tsCommitTime; if (pCfg->maxRowsPerFileBlock < 0) pCfg->maxRowsPerFileBlock = pCfg->minRowsPerFileBlock * 2;
if (pCreate->compression < 0) pCreate->compression = tsCompression; if (pCfg->commitTime < 0) pCfg->commitTime = tsCommitTime;
if (pCreate->commitLog < 0) pCreate->commitLog = tsCommitLog; if (pCfg->precision < 0) pCfg->precision = tsTimePrecision;
if (pCreate->replications < 0) pCreate->replications = tsReplications; // if (pCfg->compression < 0) pCfg->compression = tsCompression;
if (pCreate->rowsInFileBlock < 0) pCreate->rowsInFileBlock = tsRowsInFileBlock; // if (pCfg->commitLog < 0) pCfg->commitLog = tsCommitLog;
if (pCreate->cacheNumOfBlocks.fraction < 0) pCreate->cacheNumOfBlocks.fraction = tsAverageCacheBlocks; // if (pCfg->replications < 0) pCfg->replications = tsReplications;
if (mgmtCheckDBParams(pCreate) != TSDB_CODE_SUCCESS) {
return TSDB_CODE_INVALID_OPTION;
}
pCreate->cacheNumOfBlocks.totalBlocks = (int32_t)(pCreate->cacheNumOfBlocks.fraction * pCreate->maxSessions);
if (pCreate->cacheNumOfBlocks.totalBlocks > TSDB_MAX_CACHE_BLOCKS) {
mTrace("invalid db option cacheNumOfBlocks: %d valid range: [%d, %d]", pCreate->cacheNumOfBlocks.totalBlocks,
TSDB_MIN_CACHE_BLOCKS, TSDB_MAX_CACHE_BLOCKS);
return TSDB_CODE_INVALID_OPTION;
}
// calculate the blocks per table
if (pCreate->blocksPerTable < 0) {
pCreate->blocksPerTable = pCreate->cacheNumOfBlocks.totalBlocks / 4;
}
if (pCreate->blocksPerTable > pCreate->cacheNumOfBlocks.totalBlocks * 3 / 4) {
pCreate->blocksPerTable = pCreate->cacheNumOfBlocks.totalBlocks * 3 / 4;
}
if (pCreate->blocksPerTable < TSDB_MIN_AVG_BLOCKS) {
pCreate->blocksPerTable = TSDB_MIN_AVG_BLOCKS;
}
return TSDB_CODE_SUCCESS;
} }
static int32_t mgmtCreateDb(SAcctObj *pAcct, SCMCreateDbMsg *pCreate) { static int32_t mgmtCreateDb(SAcctObj *pAcct, SCMCreateDbMsg *pCreate) {
int32_t code = acctCheck(pAcct, ACCT_GRANT_DB); int32_t code = acctCheck(pAcct, ACCT_GRANT_DB);
if (code != 0) { if (code != 0) return code;
return code;
}
SDbObj *pDb = mgmtGetDb(pCreate->db); SDbObj *pDb = mgmtGetDb(pCreate->db);
if (pDb != NULL) { if (pDb != NULL) {
mgmtDecDbRef(pDb); mgmtDecDbRef(pDb);
if (pCreate->ignoreExist) { if (pCreate->ignoreExist) {
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} else { } else {
...@@ -309,50 +285,41 @@ static int32_t mgmtCreateDb(SAcctObj *pAcct, SCMCreateDbMsg *pCreate) { ...@@ -309,50 +285,41 @@ static int32_t mgmtCreateDb(SAcctObj *pAcct, SCMCreateDbMsg *pCreate) {
} }
} }
code = mgmtCheckDbParams(pCreate);
if (code != TSDB_CODE_SUCCESS) return code;
assert(pCreate->daysToKeep1 <= pCreate->daysToKeep2 && pCreate->daysToKeep2 <= pCreate->daysToKeep);
code = grantCheck(TSDB_GRANT_DB); code = grantCheck(TSDB_GRANT_DB);
if (code != 0) { if (code != 0) return code;
return code;
}
pDb = calloc(1, sizeof(SDbObj)); pDb = calloc(1, sizeof(SDbObj));
strncpy(pDb->name, pCreate->db, TSDB_DB_NAME_LEN); strncpy(pDb->name, pCreate->db, TSDB_DB_NAME_LEN);
strncpy(pCreate->acct, pAcct->user, TSDB_USER_LEN); strncpy(pDb->acct, pAcct->user, TSDB_USER_LEN);
pDb->createdTime = taosGetTimestampMs();
pDb->createdTime = taosGetTimestampMs();
pDb->cfg = (SDbCfg) { pDb->cfg = (SDbCfg) {
.vgId = pCreate->vgId, .maxCacheSize = 64,//(int64_t)pCreate->cacheBlockSize * pCreate->cacheNumOfBlocks.totalBlocks,
.precision = pCreate->precision, .maxTables = pCreate->maxSessions,
.maxSessions = pCreate->maxSessions, .daysPerFile = pCreate->daysPerFile,
.cacheNumOfBlocks.totalBlocks = pCreate->cacheNumOfBlocks.totalBlocks, .daysToKeep = pCreate->daysToKeep,
.rowsInFileBlock = pCreate->rowsInFileBlock, .daysToKeep1 = pCreate->daysToKeep1,
.commitLog = pCreate->commitLog, .daysToKeep2 = pCreate->daysToKeep2,
.replications = pCreate->replications, .minRowsPerFileBlock = pCreate->rowsInFileBlock * 1,
.daysPerFile = pCreate->daysPerFile, .maxRowsPerFileBlock = pCreate->rowsInFileBlock * 2,
.cacheBlockSize = pCreate->cacheBlockSize, .commitTime = pCreate->commitTime,
.commitTime = pCreate->commitTime, .precision = pCreate->precision,
.blocksPerTable = pCreate->blocksPerTable, .compression = pCreate->compression,
.compression = pCreate->compression, .commitLog = pCreate->commitLog,
.daysToKeep = pCreate->daysToKeep, .replications = pCreate->replications
.daysToKeep1 = pCreate->daysToKeep1,
.daysToKeep2 = pCreate->daysToKeep2,
.loadLatest = pCreate->loadLatest,
.repStrategy = pCreate->repStrategy,
}; };
strncpy(pDb->cfg.db, pCreate->db, TSDB_DB_NAME_LEN); mgmtSetDefaultDbCfg(&pDb->cfg);
strncpy(pDb->cfg.acct, pCreate->acct, TSDB_USER_LEN);
code = mgmtCheckDbCfg(&pDb->cfg);
if (code != TSDB_CODE_SUCCESS) {
tfree(pDb);
return code;
}
SSdbOper oper = { SSdbOper oper = {
.type = SDB_OPER_GLOBAL, .type = SDB_OPER_GLOBAL,
.table = tsDbSdb, .table = tsDbSdb,
.pObj = pDb, .pObj = pDb,
.rowSize = sizeof(SDbObj), .rowSize = sizeof(SDbObj),
}; };
...@@ -498,19 +465,7 @@ static int32_t mgmtGetDbMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn) ...@@ -498,19 +465,7 @@ static int32_t mgmtGetDbMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn)
pShow->bytes[cols] = 4; pShow->bytes[cols] = 4;
pSchema[cols].type = TSDB_DATA_TYPE_INT; pSchema[cols].type = TSDB_DATA_TYPE_INT;
strcpy(pSchema[cols].name, "cache(b)"); strcpy(pSchema[cols].name, "cache(Mb)");
pSchema[cols].bytes = htons(pShow->bytes[cols]);
cols++;
pShow->bytes[cols] = 4;
pSchema[cols].type = TSDB_DATA_TYPE_FLOAT;
strcpy(pSchema[cols].name, "ablocks");
pSchema[cols].bytes = htons(pShow->bytes[cols]);
cols++;
pShow->bytes[cols] = 2;
pSchema[cols].type = TSDB_DATA_TYPE_SMALLINT;
strcpy(pSchema[cols].name, "tblocks");
pSchema[cols].bytes = htons(pShow->bytes[cols]); pSchema[cols].bytes = htons(pShow->bytes[cols]);
cols++; cols++;
...@@ -625,27 +580,15 @@ static int32_t mgmtRetrieveDbs(SShowObj *pShow, char *data, int32_t rows, void * ...@@ -625,27 +580,15 @@ static int32_t mgmtRetrieveDbs(SShowObj *pShow, char *data, int32_t rows, void *
if (strcmp(pUser->user, "root") == 0) { if (strcmp(pUser->user, "root") == 0) {
#endif #endif
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
*(int32_t *)pWrite = pDb->cfg.maxSessions; // table num can be created should minus 1 *(int32_t *)pWrite = pDb->cfg.maxTables; // table num can be created should minus 1
cols++;
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
*(int32_t *)pWrite = pDb->cfg.rowsInFileBlock;
cols++;
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
*(int32_t *)pWrite = pDb->cfg.cacheBlockSize;
cols++; cols++;
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
#ifdef _TD_ARM_32_ *(int32_t *)pWrite = pDb->cfg.minRowsPerFileBlock;
*(int32_t *)pWrite = (pDb->cfg.cacheNumOfBlocks.totalBlocks * 1.0 / (pDb->cfg.maxSessions));
#else
*(float *)pWrite = (pDb->cfg.cacheNumOfBlocks.totalBlocks * 1.0 / (pDb->cfg.maxSessions));
#endif
cols++; cols++;
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
*(int16_t *)pWrite = pDb->cfg.blocksPerTable; *(int32_t *)pWrite = pDb->cfg.maxCacheSize;
cols++; cols++;
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
...@@ -747,7 +690,7 @@ static void mgmtProcessCreateDbMsg(SQueuedMsg *pMsg) { ...@@ -747,7 +690,7 @@ static void mgmtProcessCreateDbMsg(SQueuedMsg *pMsg) {
static SDbCfg mgmtGetAlterDbOption(SDbObj *pDb, SCMAlterDbMsg *pAlter) { static SDbCfg mgmtGetAlterDbOption(SDbObj *pDb, SCMAlterDbMsg *pAlter) {
SDbCfg newCfg = pDb->cfg; SDbCfg newCfg = pDb->cfg;
int32_t daysToKeep = htonl(pAlter->daysToKeep); int32_t daysToKeep = htonl(pAlter->daysToKeep);
int32_t maxSessions = htonl(pAlter->maxSessions); int32_t maxTables = htonl(pAlter->maxSessions);
int8_t replications = pAlter->replications; int8_t replications = pAlter->replications;
terrno = TSDB_CODE_SUCCESS; terrno = TSDB_CODE_SUCCESS;
...@@ -755,25 +698,28 @@ static SDbCfg mgmtGetAlterDbOption(SDbObj *pDb, SCMAlterDbMsg *pAlter) { ...@@ -755,25 +698,28 @@ static SDbCfg mgmtGetAlterDbOption(SDbObj *pDb, SCMAlterDbMsg *pAlter) {
if (daysToKeep > 0 && daysToKeep != pDb->cfg.daysToKeep) { if (daysToKeep > 0 && daysToKeep != pDb->cfg.daysToKeep) {
mTrace("db:%s, daysToKeep:%d change to %d", pDb->name, pDb->cfg.daysToKeep, daysToKeep); mTrace("db:%s, daysToKeep:%d change to %d", pDb->name, pDb->cfg.daysToKeep, daysToKeep);
newCfg.daysToKeep = daysToKeep; newCfg.daysToKeep = daysToKeep;
} else if (replications > 0 && replications != pDb->cfg.replications) { }
if (replications > 0 && replications != pDb->cfg.replications) {
mTrace("db:%s, replica:%d change to %d", pDb->name, pDb->cfg.replications, replications); mTrace("db:%s, replica:%d change to %d", pDb->name, pDb->cfg.replications, replications);
if (replications < TSDB_REPLICA_MIN_NUM || replications > TSDB_REPLICA_MAX_NUM) { if (replications < TSDB_REPLICA_MIN_NUM || replications > TSDB_REPLICA_MAX_NUM) {
mError("invalid db option replica: %d valid range: %d--%d", replications, TSDB_REPLICA_MIN_NUM, TSDB_REPLICA_MAX_NUM); mError("invalid db option replica: %d valid range: %d--%d", replications, TSDB_REPLICA_MIN_NUM, TSDB_REPLICA_MAX_NUM);
terrno = TSDB_CODE_INVALID_OPTION; terrno = TSDB_CODE_INVALID_OPTION;
} }
newCfg.replications = replications; newCfg.replications = replications;
} else if (maxSessions > 0 && maxSessions != pDb->cfg.maxSessions) { }
mTrace("db:%s, tables:%d change to %d", pDb->name, pDb->cfg.maxSessions, maxSessions);
if (maxSessions < TSDB_MIN_TABLES_PER_VNODE || maxSessions > TSDB_MAX_TABLES_PER_VNODE) { if (maxTables > 0 && maxTables != pDb->cfg.maxTables) {
mError("invalid db option tables: %d valid range: %d--%d", maxSessions, TSDB_MIN_TABLES_PER_VNODE, TSDB_MAX_TABLES_PER_VNODE); mTrace("db:%s, tables:%d change to %d", pDb->name, pDb->cfg.maxTables, maxTables);
if (maxTables < TSDB_MIN_TABLES_PER_VNODE || maxTables > TSDB_MAX_TABLES_PER_VNODE) {
mError("invalid db option tables: %d valid range: %d--%d", maxTables, TSDB_MIN_TABLES_PER_VNODE, TSDB_MAX_TABLES_PER_VNODE);
terrno = TSDB_CODE_INVALID_OPTION; terrno = TSDB_CODE_INVALID_OPTION;
} }
if (maxSessions < pDb->cfg.maxSessions) { if (maxTables < pDb->cfg.maxTables) {
mError("invalid db option tables: %d should larger than original:%d", maxSessions, pDb->cfg.maxSessions); mError("invalid db option tables: %d should larger than original:%d", maxTables, pDb->cfg.maxTables);
terrno = TSDB_CODE_INVALID_OPTION; terrno = TSDB_CODE_INVALID_OPTION;
} }
newCfg.maxSessions = maxSessions; newCfg.maxTables = maxTables;
} else {
} }
return newCfg; return newCfg;
......
...@@ -106,9 +106,9 @@ static int32_t mgmtChildTableActionInsert(SSdbOper *pOper) { ...@@ -106,9 +106,9 @@ static int32_t mgmtChildTableActionInsert(SSdbOper *pOper) {
} }
mgmtDecDbRef(pDb); mgmtDecDbRef(pDb);
SAcctObj *pAcct = mgmtGetAcct(pDb->cfg.acct); SAcctObj *pAcct = mgmtGetAcct(pDb->acct);
if (pAcct == NULL) { if (pAcct == NULL) {
mError("ctable:%s, acct:%s not exists", pTable->info.tableId, pDb->cfg.acct); mError("ctable:%s, acct:%s not exists", pTable->info.tableId, pDb->acct);
return TSDB_CODE_INVALID_ACCT; return TSDB_CODE_INVALID_ACCT;
} }
mgmtDecAcctRef(pAcct); mgmtDecAcctRef(pAcct);
...@@ -148,9 +148,9 @@ static int32_t mgmtChildTableActionDelete(SSdbOper *pOper) { ...@@ -148,9 +148,9 @@ static int32_t mgmtChildTableActionDelete(SSdbOper *pOper) {
} }
mgmtDecDbRef(pDb); mgmtDecDbRef(pDb);
SAcctObj *pAcct = mgmtGetAcct(pDb->cfg.acct); SAcctObj *pAcct = mgmtGetAcct(pDb->acct);
if (pAcct == NULL) { if (pAcct == NULL) {
mError("ctable:%s, acct:%s not exists", pTable->info.tableId, pDb->cfg.acct); mError("ctable:%s, acct:%s not exists", pTable->info.tableId, pDb->acct);
return TSDB_CODE_INVALID_ACCT; return TSDB_CODE_INVALID_ACCT;
} }
mgmtDecAcctRef(pAcct); mgmtDecAcctRef(pAcct);
...@@ -929,7 +929,7 @@ static int32_t mgmtAddSuperTableColumn(SDbObj *pDb, SSuperTableObj *pStable, SSc ...@@ -929,7 +929,7 @@ static int32_t mgmtAddSuperTableColumn(SDbObj *pDb, SSuperTableObj *pStable, SSc
pStable->numOfColumns += ncols; pStable->numOfColumns += ncols;
pStable->sversion++; pStable->sversion++;
SAcctObj *pAcct = mgmtGetAcct(pDb->cfg.acct); SAcctObj *pAcct = mgmtGetAcct(pDb->acct);
if (pAcct != NULL) { if (pAcct != NULL) {
pAcct->acctInfo.numOfTimeSeries += (ncols * pStable->numOfTables); pAcct->acctInfo.numOfTimeSeries += (ncols * pStable->numOfTables);
mgmtDecAcctRef(pAcct); mgmtDecAcctRef(pAcct);
...@@ -966,7 +966,7 @@ static int32_t mgmtDropSuperTableColumn(SDbObj *pDb, SSuperTableObj *pStable, ch ...@@ -966,7 +966,7 @@ static int32_t mgmtDropSuperTableColumn(SDbObj *pDb, SSuperTableObj *pStable, ch
int32_t schemaSize = sizeof(SSchema) * (pStable->numOfTags + pStable->numOfColumns); int32_t schemaSize = sizeof(SSchema) * (pStable->numOfTags + pStable->numOfColumns);
pStable->schema = realloc(pStable->schema, schemaSize); pStable->schema = realloc(pStable->schema, schemaSize);
SAcctObj *pAcct = mgmtGetAcct(pDb->cfg.acct); SAcctObj *pAcct = mgmtGetAcct(pDb->acct);
if (pAcct != NULL) { if (pAcct != NULL) {
pAcct->acctInfo.numOfTimeSeries -= pStable->numOfTables; pAcct->acctInfo.numOfTimeSeries -= pStable->numOfTables;
mgmtDecAcctRef(pAcct); mgmtDecAcctRef(pAcct);
...@@ -1505,7 +1505,7 @@ static int32_t mgmtAddNormalTableColumn(SDbObj *pDb, SChildTableObj *pTable, SSc ...@@ -1505,7 +1505,7 @@ static int32_t mgmtAddNormalTableColumn(SDbObj *pDb, SChildTableObj *pTable, SSc
pTable->numOfColumns += ncols; pTable->numOfColumns += ncols;
pTable->sversion++; pTable->sversion++;
SAcctObj *pAcct = mgmtGetAcct(pDb->cfg.acct); SAcctObj *pAcct = mgmtGetAcct(pDb->acct);
if (pAcct != NULL) { if (pAcct != NULL) {
pAcct->acctInfo.numOfTimeSeries += ncols; pAcct->acctInfo.numOfTimeSeries += ncols;
mgmtDecAcctRef(pAcct); mgmtDecAcctRef(pAcct);
...@@ -1539,7 +1539,7 @@ static int32_t mgmtDropNormalTableColumn(SDbObj *pDb, SChildTableObj *pTable, ch ...@@ -1539,7 +1539,7 @@ static int32_t mgmtDropNormalTableColumn(SDbObj *pDb, SChildTableObj *pTable, ch
pTable->numOfColumns--; pTable->numOfColumns--;
pTable->sversion++; pTable->sversion++;
SAcctObj *pAcct = mgmtGetAcct(pDb->cfg.acct); SAcctObj *pAcct = mgmtGetAcct(pDb->acct);
if (pAcct != NULL) { if (pAcct != NULL) {
pAcct->acctInfo.numOfTimeSeries--; pAcct->acctInfo.numOfTimeSeries--;
mgmtDecAcctRef(pAcct); mgmtDecAcctRef(pAcct);
......
...@@ -71,14 +71,14 @@ static int32_t mgmtVgroupActionInsert(SSdbOper *pOper) { ...@@ -71,14 +71,14 @@ static int32_t mgmtVgroupActionInsert(SSdbOper *pOper) {
pVgroup->prev = NULL; pVgroup->prev = NULL;
pVgroup->next = NULL; pVgroup->next = NULL;
int32_t size = sizeof(SChildTableObj *) * pDb->cfg.maxSessions; int32_t size = sizeof(SChildTableObj *) * pDb->cfg.maxTables;
pVgroup->tableList = calloc(pDb->cfg.maxSessions, sizeof(SChildTableObj *)); pVgroup->tableList = calloc(pDb->cfg.maxTables, sizeof(SChildTableObj *));
if (pVgroup->tableList == NULL) { if (pVgroup->tableList == NULL) {
mError("vgroup:%d, failed to malloc(size:%d) for the tableList of vgroups", pVgroup->vgId, size); mError("vgroup:%d, failed to malloc(size:%d) for the tableList of vgroups", pVgroup->vgId, size);
return -1; return -1;
} }
pVgroup->idPool = taosInitIdPool(pDb->cfg.maxSessions); pVgroup->idPool = taosInitIdPool(pDb->cfg.maxTables);
if (pVgroup->idPool == NULL) { if (pVgroup->idPool == NULL) {
mError("vgroup:%d, failed to taosInitIdPool for vgroups", pVgroup->vgId); mError("vgroup:%d, failed to taosInitIdPool for vgroups", pVgroup->vgId);
tfree(pVgroup->tableList); tfree(pVgroup->tableList);
...@@ -146,15 +146,15 @@ static int32_t mgmtVgroupActionUpdate(SSdbOper *pOper) { ...@@ -146,15 +146,15 @@ static int32_t mgmtVgroupActionUpdate(SSdbOper *pOper) {
int32_t oldTables = taosIdPoolMaxSize(pVgroup->idPool); int32_t oldTables = taosIdPoolMaxSize(pVgroup->idPool);
SDbObj *pDb = pVgroup->pDb; SDbObj *pDb = pVgroup->pDb;
if (pDb != NULL) { if (pDb != NULL) {
if (pDb->cfg.maxSessions != oldTables) { if (pDb->cfg.maxTables != oldTables) {
mPrint("vgroup:%d tables change from %d to %d", pVgroup->vgId, oldTables, pDb->cfg.maxSessions); mPrint("vgroup:%d tables change from %d to %d", pVgroup->vgId, oldTables, pDb->cfg.maxTables);
taosUpdateIdPool(pVgroup->idPool, pDb->cfg.maxSessions); taosUpdateIdPool(pVgroup->idPool, pDb->cfg.maxTables);
int32_t size = sizeof(SChildTableObj *) * pDb->cfg.maxSessions; int32_t size = sizeof(SChildTableObj *) * pDb->cfg.maxTables;
pVgroup->tableList = (SChildTableObj **)realloc(pVgroup->tableList, size); pVgroup->tableList = (SChildTableObj **)realloc(pVgroup->tableList, size);
} }
} }
mTrace("vgroup:%d, is updated, tables:%d numOfVnode:%d", pVgroup->vgId, pDb->cfg.maxSessions, pVgroup->numOfVnodes); mTrace("vgroup:%d, is updated, tables:%d numOfVnode:%d", pVgroup->vgId, pDb->cfg.maxTables, pVgroup->numOfVnodes);
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
...@@ -511,7 +511,7 @@ void mgmtAddTableIntoVgroup(SVgObj *pVgroup, SChildTableObj *pTable) { ...@@ -511,7 +511,7 @@ void mgmtAddTableIntoVgroup(SVgObj *pVgroup, SChildTableObj *pTable) {
pVgroup->numOfTables++; pVgroup->numOfTables++;
} }
if (pVgroup->numOfTables >= pVgroup->pDb->cfg.maxSessions) if (pVgroup->numOfTables >= pVgroup->pDb->cfg.maxTables)
mgmtAddVgroupIntoDbTail(pVgroup); mgmtAddVgroupIntoDbTail(pVgroup);
} }
...@@ -522,7 +522,7 @@ void mgmtRemoveTableFromVgroup(SVgObj *pVgroup, SChildTableObj *pTable) { ...@@ -522,7 +522,7 @@ void mgmtRemoveTableFromVgroup(SVgObj *pVgroup, SChildTableObj *pTable) {
pVgroup->numOfTables--; pVgroup->numOfTables--;
} }
if (pVgroup->numOfTables >= pVgroup->pDb->cfg.maxSessions) if (pVgroup->numOfTables >= pVgroup->pDb->cfg.maxTables)
mgmtAddVgroupIntoDbTail(pVgroup); mgmtAddVgroupIntoDbTail(pVgroup);
} }
...@@ -535,16 +535,16 @@ SMDCreateVnodeMsg *mgmtBuildCreateVnodeMsg(SVgObj *pVgroup) { ...@@ -535,16 +535,16 @@ SMDCreateVnodeMsg *mgmtBuildCreateVnodeMsg(SVgObj *pVgroup) {
SMDVnodeCfg *pCfg = &pVnode->cfg; SMDVnodeCfg *pCfg = &pVnode->cfg;
pCfg->vgId = htonl(pVgroup->vgId); pCfg->vgId = htonl(pVgroup->vgId);
pCfg->maxTables = htonl(pDb->cfg.maxSessions); pCfg->maxTables = htonl(pDb->cfg.maxTables);
pCfg->maxCacheSize = htobe64((int64_t)pDb->cfg.cacheBlockSize * pDb->cfg.cacheNumOfBlocks.totalBlocks); pCfg->maxCacheSize = htobe64(pDb->cfg.maxCacheSize);
pCfg->maxCacheSize = htobe64(-1); pCfg->maxCacheSize = htobe64(-1); //TODO
pCfg->minRowsPerFileBlock = htonl(-1); pCfg->minRowsPerFileBlock = htonl(-1); //TODO
pCfg->maxRowsPerFileBlock = htonl(-1); pCfg->maxRowsPerFileBlock = htonl(-1); //TODO
pCfg->daysPerFile = htonl(pDb->cfg.daysPerFile); pCfg->daysPerFile = htonl(pDb->cfg.daysPerFile);
pCfg->daysToKeep1 = htonl(pDb->cfg.daysToKeep1); pCfg->daysToKeep1 = htonl(pDb->cfg.daysToKeep1);
pCfg->daysToKeep2 = htonl(pDb->cfg.daysToKeep2); pCfg->daysToKeep2 = htonl(pDb->cfg.daysToKeep2);
pCfg->daysToKeep = htonl(pDb->cfg.daysToKeep); pCfg->daysToKeep = htonl(pDb->cfg.daysToKeep);
pCfg->daysToKeep = htonl(-1); pCfg->daysToKeep = htonl(-1); //TODO
pCfg->commitTime = htonl(pDb->cfg.commitTime); pCfg->commitTime = htonl(pDb->cfg.commitTime);
pCfg->precision = pDb->cfg.precision; pCfg->precision = pDb->cfg.precision;
pCfg->compression = pDb->cfg.compression; pCfg->compression = pDb->cfg.compression;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册