refactor: check db options
This commit is contained in:
parent
4e64e8db62
commit
76883aa42f
|
@ -509,7 +509,7 @@ typedef struct {
|
|||
int8_t precision; // time resolution
|
||||
int8_t compression;
|
||||
int8_t replications;
|
||||
int8_t quorum;
|
||||
int8_t strict;
|
||||
int8_t update;
|
||||
int8_t cacheLastRow;
|
||||
int8_t ignoreExist;
|
||||
|
@ -531,7 +531,7 @@ typedef struct {
|
|||
int32_t daysToKeep2;
|
||||
int32_t fsyncPeriod;
|
||||
int8_t walLevel;
|
||||
int8_t quorum;
|
||||
int8_t strict;
|
||||
int8_t cacheLastRow;
|
||||
int8_t replications;
|
||||
} SAlterDbReq;
|
||||
|
@ -604,7 +604,7 @@ typedef struct {
|
|||
int8_t precision;
|
||||
int8_t compression;
|
||||
int8_t replications;
|
||||
int8_t quorum;
|
||||
int8_t strict;
|
||||
int8_t update;
|
||||
int8_t cacheLastRow;
|
||||
int8_t streamMode;
|
||||
|
@ -639,10 +639,10 @@ void tFreeSUseDbBatchRsp(SUseDbBatchRsp* pRsp);
|
|||
|
||||
typedef struct {
|
||||
char db[TSDB_DB_FNAME_LEN];
|
||||
} SSyncDbReq, SCompactDbReq;
|
||||
} SCompactDbReq;
|
||||
|
||||
int32_t tSerializeSSyncDbReq(void* buf, int32_t bufLen, SSyncDbReq* pReq);
|
||||
int32_t tDeserializeSSyncDbReq(void* buf, int32_t bufLen, SSyncDbReq* pReq);
|
||||
int32_t tSerializeSCompactDbReq(void* buf, int32_t bufLen, SCompactDbReq* pReq);
|
||||
int32_t tDeserializeSCompactDbReq(void* buf, int32_t bufLen, SCompactDbReq* pReq);
|
||||
|
||||
typedef struct {
|
||||
char name[TSDB_FUNC_NAME_LEN];
|
||||
|
@ -814,7 +814,7 @@ typedef struct {
|
|||
int8_t walLevel;
|
||||
int8_t precision;
|
||||
int8_t compression;
|
||||
int8_t quorum;
|
||||
int8_t strict;
|
||||
int8_t update;
|
||||
int8_t cacheLastRow;
|
||||
int8_t replica;
|
||||
|
|
|
@ -297,16 +297,6 @@ typedef enum ELogicConditionType {
|
|||
#define TSDB_DNODE_CONFIG_LEN 128
|
||||
#define TSDB_DNODE_VALUE_LEN 256
|
||||
|
||||
#define TSDB_MQTT_HOSTNAME_LEN 64
|
||||
#define TSDB_MQTT_PORT_LEN 8
|
||||
#define TSDB_MQTT_USER_LEN 24
|
||||
#define TSDB_MQTT_PASS_LEN 24
|
||||
#define TSDB_MQTT_TOPIC_LEN 64
|
||||
#define TSDB_MQTT_CLIENT_ID_LEN 32
|
||||
|
||||
#define TSDB_DB_TYPE_DEFAULT 0
|
||||
#define TSDB_DB_TYPE_TOPIC 1
|
||||
|
||||
#define TSDB_DEFAULT_PKT_SIZE 65480 // same as RPC_MAX_UDP_SIZE
|
||||
|
||||
#define TSDB_PAYLOAD_SIZE TSDB_DEFAULT_PKT_SIZE
|
||||
|
@ -315,9 +305,6 @@ typedef enum ELogicConditionType {
|
|||
#define TSDB_CQ_SQL_SIZE 1024
|
||||
#define TSDB_MIN_VNODES 16
|
||||
#define TSDB_MAX_VNODES 512
|
||||
#define TSDB_MIN_VNODES_PER_DB 1
|
||||
#define TSDB_MAX_VNODES_PER_DB 4096
|
||||
#define TSDB_DEFAULT_VN_PER_DB 2
|
||||
|
||||
#define TSDB_DNODE_ROLE_ANY 0
|
||||
#define TSDB_DNODE_ROLE_MGMT 1
|
||||
|
@ -331,104 +318,81 @@ typedef enum ELogicConditionType {
|
|||
|
||||
#define TSDB_MULTI_TABLEMETA_MAX_NUM 100000 // maximum batch size allowed to load table meta
|
||||
|
||||
#define TSDB_MIN_VNODES_PER_DB 1
|
||||
#define TSDB_MAX_VNODES_PER_DB 4096
|
||||
#define TSDB_DEFAULT_VN_PER_DB 2
|
||||
#define TSDB_MIN_CACHE_BLOCK_SIZE 1
|
||||
#define TSDB_MAX_CACHE_BLOCK_SIZE 128 // 128MB for each vnode
|
||||
#define TSDB_DEFAULT_CACHE_BLOCK_SIZE 16
|
||||
|
||||
#define TSDB_MIN_TOTAL_BLOCKS 3
|
||||
#define TSDB_MAX_TOTAL_BLOCKS 10000
|
||||
#define TSDB_DEFAULT_TOTAL_BLOCKS 6
|
||||
|
||||
#define TSDB_MIN_DAYS_PER_FILE 60 // unit minute
|
||||
#define TSDB_MAX_DAYS_PER_FILE (3650 * 1440)
|
||||
#define TSDB_DEFAULT_DAYS_PER_FILE (10 * 1440)
|
||||
|
||||
#define TSDB_MIN_KEEP (1 * 1440) // data in db to be reserved. unit minute
|
||||
#define TSDB_MAX_KEEP (365000 * 1440) // data in db to be reserved.
|
||||
#define TSDB_DEFAULT_KEEP (3650 * 1440) // ten years
|
||||
|
||||
#define TSDB_MIN_MIN_ROW_FBLOCK 10
|
||||
#define TSDB_MAX_MIN_ROW_FBLOCK 1000
|
||||
#define TSDB_DEFAULT_MIN_ROW_FBLOCK 100
|
||||
|
||||
#define TSDB_MIN_MAX_ROW_FBLOCK 200
|
||||
#define TSDB_MAX_MAX_ROW_FBLOCK 10000
|
||||
#define TSDB_DEFAULT_MAX_ROW_FBLOCK 4096
|
||||
|
||||
#define TSDB_MIN_COMMIT_TIME 30
|
||||
#define TSDB_MAX_COMMIT_TIME 40960
|
||||
#define TSDB_DEFAULT_COMMIT_TIME 3600
|
||||
|
||||
#define TSDB_MIN_FSYNC_PERIOD 0
|
||||
#define TSDB_MAX_FSYNC_PERIOD 180000 // millisecond
|
||||
#define TSDB_DEFAULT_FSYNC_PERIOD 3000 // three second
|
||||
|
||||
#define TSDB_MIN_WAL_LEVEL 1
|
||||
#define TSDB_MAX_WAL_LEVEL 2
|
||||
#define TSDB_DEFAULT_WAL_LEVEL 1
|
||||
|
||||
#define TSDB_MIN_PRECISION TSDB_TIME_PRECISION_MILLI
|
||||
#define TSDB_MAX_PRECISION TSDB_TIME_PRECISION_NANO
|
||||
#define TSDB_DEFAULT_PRECISION TSDB_TIME_PRECISION_MILLI
|
||||
|
||||
#define TSDB_MIN_COMP_LEVEL 0
|
||||
#define TSDB_MAX_COMP_LEVEL 2
|
||||
#define TSDB_DEFAULT_COMP_LEVEL 2
|
||||
|
||||
#define TSDB_MIN_DB_REPLICA_OPTION 1
|
||||
#define TSDB_MAX_DB_REPLICA_OPTION 3
|
||||
#define TSDB_DEFAULT_DB_REPLICA_OPTION 1
|
||||
|
||||
#define TSDB_MIN_DB_QUORUM_OPTION 1
|
||||
#define TSDB_MAX_DB_QUORUM_OPTION 2
|
||||
#define TSDB_DEFAULT_DB_QUORUM_OPTION 1
|
||||
|
||||
#define TSDB_MIN_DB_TTL_OPTION 1
|
||||
#define TSDB_DEFAULT_DB_TTL_OPTION 0
|
||||
|
||||
#define TSDB_MIN_DB_SINGLE_STABLE_OPTION 0
|
||||
#define TSDB_MAX_DB_SINGLE_STABLE_OPTION 1
|
||||
#define TSDB_DEFAULT_DB_SINGLE_STABLE_OPTION 0
|
||||
|
||||
#define TSDB_MIN_DB_STREAM_MODE_OPTION 0
|
||||
#define TSDB_MAX_DB_STREAM_MODE_OPTION 1
|
||||
#define TSDB_DEFAULT_DB_STREAM_MODE_OPTION 0
|
||||
|
||||
#define TSDB_MAX_JOIN_TABLE_NUM 10
|
||||
#define TSDB_MAX_UNION_CLAUSE 5
|
||||
|
||||
#define TSDB_MIN_TOTAL_BLOCKS 3
|
||||
#define TSDB_MAX_TOTAL_BLOCKS 10000
|
||||
#define TSDB_DEFAULT_TOTAL_BLOCKS 6
|
||||
#define TSDB_MIN_DAYS_PER_FILE 60 // unit minute
|
||||
#define TSDB_MAX_DAYS_PER_FILE (3650 * 1440)
|
||||
#define TSDB_DEFAULT_DAYS_PER_FILE (10 * 1440)
|
||||
#define TSDB_MIN_KEEP (1 * 1440) // data in db to be reserved. unit minute
|
||||
#define TSDB_MAX_KEEP (365000 * 1440) // data in db to be reserved.
|
||||
#define TSDB_DEFAULT_KEEP (3650 * 1440) // ten years
|
||||
#define TSDB_MIN_MINROWS_FBLOCK 10
|
||||
#define TSDB_MAX_MINROWS_FBLOCK 1000
|
||||
#define TSDB_DEFAULT_MINROWS_FBLOCK 100
|
||||
#define TSDB_MIN_MAXROWS_FBLOCK 200
|
||||
#define TSDB_MAX_MAXROWS_FBLOCK 10000
|
||||
#define TSDB_DEFAULT_MAXROWS_FBLOCK 4096
|
||||
#define TSDB_MIN_COMMIT_TIME 30
|
||||
#define TSDB_MAX_COMMIT_TIME 40960
|
||||
#define TSDB_DEFAULT_COMMIT_TIME 3600
|
||||
#define TSDB_MIN_FSYNC_PERIOD 0
|
||||
#define TSDB_MAX_FSYNC_PERIOD 180000 // millisecond
|
||||
#define TSDB_DEFAULT_FSYNC_PERIOD 3000 // three second
|
||||
#define TSDB_MIN_DB_TTL 1
|
||||
#define TSDB_DEFAULT_DB_TTL 1
|
||||
#define TSDB_MIN_WAL_LEVEL 1
|
||||
#define TSDB_MAX_WAL_LEVEL 2
|
||||
#define TSDB_DEFAULT_WAL_LEVEL 1
|
||||
#define TSDB_MIN_PRECISION TSDB_TIME_PRECISION_MILLI
|
||||
#define TSDB_MAX_PRECISION TSDB_TIME_PRECISION_NANO
|
||||
#define TSDB_DEFAULT_PRECISION TSDB_TIME_PRECISION_MILLI
|
||||
#define TSDB_MIN_COMP_LEVEL 0
|
||||
#define TSDB_MAX_COMP_LEVEL 2
|
||||
#define TSDB_DEFAULT_COMP_LEVEL 2
|
||||
#define TSDB_MIN_DB_REPLICA 1
|
||||
#define TSDB_MAX_DB_REPLICA 3
|
||||
#define TSDB_DEFAULT_DB_REPLICA 1
|
||||
#define TSDB_MIN_DB_STRICT 0
|
||||
#define TSDB_MAX_DB_STRICT 1
|
||||
#define TSDB_DEFAULT_DB_STRICT 0
|
||||
#define TSDB_MIN_DB_UPDATE 0
|
||||
#define TSDB_MAX_DB_UPDATE 2
|
||||
#define TSDB_DEFAULT_DB_UPDATE_OPTION 0
|
||||
|
||||
#define TSDB_MIN_DB_CACHE_LAST_ROW 0
|
||||
#define TSDB_MAX_DB_CACHE_LAST_ROW 3
|
||||
#define TSDB_DEFAULT_CACHE_LAST_ROW 0
|
||||
|
||||
#define TSDB_MIN_DB_STREAM_MODE 0
|
||||
#define TSDB_MAX_DB_STREAM_MODE 1
|
||||
#define TSDB_DEFAULT_DB_STREAM_MODE 0
|
||||
#define TSDB_DEFAULT_DB_UPDATE 0
|
||||
#define TSDB_MIN_DB_CACHE_LAST_ROW 0
|
||||
#define TSDB_MAX_DB_CACHE_LAST_ROW 3
|
||||
#define TSDB_DEFAULT_CACHE_LAST_ROW 0
|
||||
#define TSDB_MIN_DB_STREAM_MODE 0
|
||||
#define TSDB_MAX_DB_STREAM_MODE 1
|
||||
#define TSDB_DEFAULT_DB_STREAM_MODE 0
|
||||
#define TSDB_MIN_DB_SINGLE_STABLE 0
|
||||
#define TSDB_MAX_DB_SINGLE_STABLE 1
|
||||
#define TSDB_DEFAULT_DB_SINGLE_STABLE 0
|
||||
|
||||
#define TSDB_MIN_DB_FILE_FACTOR 0
|
||||
#define TSDB_MAX_DB_FILE_FACTOR 1
|
||||
#define TSDB_DEFAULT_DB_FILE_FACTOR 0.1
|
||||
|
||||
#define TSDB_MIN_DB_DELAY 1
|
||||
#define TSDB_MAX_DB_DELAY 10
|
||||
#define TSDB_DEFAULT_DB_DELAY 2
|
||||
|
||||
#define TSDB_DEFAULT_EXPLAIN_VERBOSE false
|
||||
|
||||
#define TSDB_MIN_EXPLAIN_RATIO 0
|
||||
#define TSDB_MAX_EXPLAIN_RATIO 1
|
||||
#define TSDB_DEFAULT_EXPLAIN_RATIO 0.001
|
||||
|
||||
#define TSDB_EXPLAIN_RESULT_ROW_SIZE 1024
|
||||
#define TSDB_EXPLAIN_RESULT_COLUMN_NAME "QUERY PLAN"
|
||||
#define TSDB_MIN_DB_DELAY 1
|
||||
#define TSDB_MAX_DB_DELAY 10
|
||||
#define TSDB_DEFAULT_DB_DELAY 2
|
||||
#define TSDB_MIN_EXPLAIN_RATIO 0
|
||||
#define TSDB_MAX_EXPLAIN_RATIO 1
|
||||
#define TSDB_DEFAULT_EXPLAIN_RATIO 0.001
|
||||
|
||||
#define TSDB_MAX_JOIN_TABLE_NUM 10
|
||||
#define TSDB_MAX_UNION_CLAUSE 5
|
||||
|
||||
#define TSDB_DEFAULT_EXPLAIN_VERBOSE false
|
||||
|
||||
#define TSDB_EXPLAIN_RESULT_ROW_SIZE 1024
|
||||
#define TSDB_EXPLAIN_RESULT_COLUMN_NAME "QUERY PLAN"
|
||||
|
||||
#define TSDB_MAX_FIELD_LEN 16384
|
||||
#define TSDB_MAX_BINARY_LEN (TSDB_MAX_FIELD_LEN - TSDB_KEYSIZE) // keep 16384
|
||||
#define TSDB_MAX_NCHAR_LEN (TSDB_MAX_FIELD_LEN - TSDB_KEYSIZE) // keep 16384
|
||||
|
|
|
@ -1736,7 +1736,7 @@ int32_t tSerializeSCreateDbReq(void *buf, int32_t bufLen, SCreateDbReq *pReq) {
|
|||
if (tEncodeI8(&encoder, pReq->precision) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pReq->compression) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pReq->replications) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pReq->quorum) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pReq->strict) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pReq->update) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pReq->cacheLastRow) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pReq->ignoreExist) < 0) return -1;
|
||||
|
@ -1779,7 +1779,7 @@ int32_t tDeserializeSCreateDbReq(void *buf, int32_t bufLen, SCreateDbReq *pReq)
|
|||
if (tDecodeI8(&decoder, &pReq->precision) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pReq->compression) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pReq->replications) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pReq->quorum) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pReq->strict) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pReq->update) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pReq->cacheLastRow) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pReq->ignoreExist) < 0) return -1;
|
||||
|
@ -1827,7 +1827,7 @@ int32_t tSerializeSAlterDbReq(void *buf, int32_t bufLen, SAlterDbReq *pReq) {
|
|||
if (tEncodeI32(&encoder, pReq->daysToKeep2) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->fsyncPeriod) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pReq->walLevel) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pReq->quorum) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pReq->strict) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pReq->cacheLastRow) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pReq->replications) < 0) return -1;
|
||||
tEndEncode(&encoder);
|
||||
|
@ -1849,7 +1849,7 @@ int32_t tDeserializeSAlterDbReq(void *buf, int32_t bufLen, SAlterDbReq *pReq) {
|
|||
if (tDecodeI32(&decoder, &pReq->daysToKeep2) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->fsyncPeriod) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pReq->walLevel) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pReq->quorum) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pReq->strict) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pReq->cacheLastRow) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pReq->replications) < 0) return -1;
|
||||
tEndDecode(&decoder);
|
||||
|
@ -2006,7 +2006,7 @@ int32_t tDeserializeSQnodeListRsp(void *buf, int32_t bufLen, SQnodeListRsp *pRsp
|
|||
|
||||
void tFreeSQnodeListRsp(SQnodeListRsp *pRsp) { taosArrayDestroy(pRsp->epSetList); }
|
||||
|
||||
int32_t tSerializeSSyncDbReq(void *buf, int32_t bufLen, SSyncDbReq *pReq) {
|
||||
int32_t tSerializeSCompactDbReq(void *buf, int32_t bufLen, SCompactDbReq *pReq) {
|
||||
SCoder encoder = {0};
|
||||
tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER);
|
||||
|
||||
|
@ -2019,7 +2019,7 @@ int32_t tSerializeSSyncDbReq(void *buf, int32_t bufLen, SSyncDbReq *pReq) {
|
|||
return tlen;
|
||||
}
|
||||
|
||||
int32_t tDeserializeSSyncDbReq(void *buf, int32_t bufLen, SSyncDbReq *pReq) {
|
||||
int32_t tDeserializeSCompactDbReq(void *buf, int32_t bufLen, SCompactDbReq *pReq) {
|
||||
SCoder decoder = {0};
|
||||
tCoderInit(&decoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_DECODER);
|
||||
|
||||
|
@ -2207,7 +2207,7 @@ int32_t tSerializeSDbCfgRsp(void *buf, int32_t bufLen, const SDbCfgRsp *pRsp) {
|
|||
if (tEncodeI8(&encoder, pRsp->precision) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pRsp->compression) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pRsp->replications) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pRsp->quorum) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pRsp->strict) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pRsp->update) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pRsp->cacheLastRow) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pRsp->streamMode) < 0) return -1;
|
||||
|
@ -2238,7 +2238,7 @@ int32_t tDeserializeSDbCfgRsp(void *buf, int32_t bufLen, SDbCfgRsp *pRsp) {
|
|||
if (tDecodeI8(&decoder, &pRsp->precision) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pRsp->compression) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pRsp->replications) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pRsp->quorum) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pRsp->strict) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pRsp->update) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pRsp->cacheLastRow) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pRsp->streamMode) < 0) return -1;
|
||||
|
@ -2831,7 +2831,7 @@ int32_t tSerializeSCreateVnodeReq(void *buf, int32_t bufLen, SCreateVnodeReq *pR
|
|||
if (tEncodeI8(&encoder, pReq->walLevel) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pReq->precision) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pReq->compression) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pReq->quorum) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pReq->strict) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pReq->update) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pReq->cacheLastRow) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pReq->replica) < 0) return -1;
|
||||
|
@ -2882,7 +2882,7 @@ int32_t tDeserializeSCreateVnodeReq(void *buf, int32_t bufLen, SCreateVnodeReq *
|
|||
if (tDecodeI8(&decoder, &pReq->walLevel) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pReq->precision) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pReq->compression) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pReq->quorum) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pReq->strict) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pReq->update) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pReq->cacheLastRow) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pReq->replica) < 0) return -1;
|
||||
|
|
|
@ -188,7 +188,6 @@ void mmInitMsgHandle(SMgmtWrapper *pWrapper) {
|
|||
dmSetMsgHandle(pWrapper, TDMT_MND_DROP_DB, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||
dmSetMsgHandle(pWrapper, TDMT_MND_USE_DB, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||
dmSetMsgHandle(pWrapper, TDMT_MND_ALTER_DB, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||
dmSetMsgHandle(pWrapper, TDMT_MND_SYNC_DB, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||
dmSetMsgHandle(pWrapper, TDMT_MND_COMPACT_DB, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||
dmSetMsgHandle(pWrapper, TDMT_MND_CREATE_FUNC, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||
dmSetMsgHandle(pWrapper, TDMT_MND_RETRIEVE_FUNC, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||
|
|
|
@ -47,7 +47,7 @@ TEST_F(DndTestVnode, 01_Create_Vnode) {
|
|||
createReq.precision = 0;
|
||||
createReq.compression = 2;
|
||||
createReq.replica = 1;
|
||||
createReq.quorum = 1;
|
||||
createReq.strict = 1;
|
||||
createReq.update = 0;
|
||||
createReq.cacheLastRow = 0;
|
||||
createReq.selfIndex = 0;
|
||||
|
@ -94,7 +94,7 @@ TEST_F(DndTestVnode, 02_Alter_Vnode) {
|
|||
alterReq.precision = 0;
|
||||
alterReq.compression = 2;
|
||||
alterReq.replica = 1;
|
||||
alterReq.quorum = 1;
|
||||
alterReq.strict = 1;
|
||||
alterReq.update = 0;
|
||||
alterReq.cacheLastRow = 0;
|
||||
alterReq.selfIndex = 0;
|
||||
|
|
|
@ -33,7 +33,7 @@ int32_t mndCheckNodeAuth(SUserObj *pOperUser);
|
|||
int32_t mndCheckFuncAuth(SUserObj *pOperUser);
|
||||
|
||||
int32_t mndCheckCreateDbAuth(SUserObj *pOperUser);
|
||||
int32_t mndCheckAlterDropCompactSyncDbAuth(SUserObj *pOperUser, SDbObj *pDb);
|
||||
int32_t mndCheckAlterDropCompactDbAuth(SUserObj *pOperUser, SDbObj *pDb);
|
||||
int32_t mndCheckUseDbAuth(SUserObj *pOperUser, SDbObj *pDb);
|
||||
|
||||
int32_t mndCheckWriteAuth(SUserObj *pOperUser, SDbObj *pDb);
|
||||
|
|
|
@ -27,9 +27,10 @@ void mndCleanupDb(SMnode *pMnode);
|
|||
SDbObj *mndAcquireDb(SMnode *pMnode, const char *db);
|
||||
void mndReleaseDb(SMnode *pMnode, SDbObj *pDb);
|
||||
int32_t mndValidateDbInfo(SMnode *pMnode, SDbVgVersion *pDbs, int32_t numOfDbs, void **ppRsp, int32_t *pRspLen);
|
||||
char *mndGetDbStr(char *src);
|
||||
int32_t mndExtractDbInfo(SMnode *pMnode, SDbObj *pDb, SUseDbRsp *pRsp, const SUseDbReq *pReq);
|
||||
|
||||
const char *mndGetDbStr(const char *src);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -265,11 +265,12 @@ typedef struct {
|
|||
int8_t precision;
|
||||
int8_t compression;
|
||||
int8_t replications;
|
||||
int8_t quorum;
|
||||
int8_t strict;
|
||||
int8_t update;
|
||||
int8_t cacheLastRow;
|
||||
int8_t streamMode;
|
||||
int8_t singleSTable;
|
||||
int8_t hashMethod; // default is 1
|
||||
int32_t numOfRetensions;
|
||||
SArray* pRetensions;
|
||||
} SDbCfg;
|
||||
|
@ -283,7 +284,6 @@ typedef struct {
|
|||
int64_t uid;
|
||||
int32_t cfgVersion;
|
||||
int32_t vgVersion;
|
||||
int8_t hashMethod; // default is 1
|
||||
SDbCfg cfg;
|
||||
SRWLatch lock;
|
||||
} SDbObj;
|
||||
|
|
|
@ -146,7 +146,7 @@ int32_t mndCheckFuncAuth(SUserObj *pOperUser) {
|
|||
|
||||
int32_t mndCheckCreateDbAuth(SUserObj *pOperUser) { return 0; }
|
||||
|
||||
int32_t mndCheckAlterDropCompactSyncDbAuth(SUserObj *pOperUser, SDbObj *pDb) {
|
||||
int32_t mndCheckAlterDropCompactDbAuth(SUserObj *pOperUser, SDbObj *pDb) {
|
||||
if (pOperUser->superUser || strcmp(pOperUser->user, pDb->createUser) == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -18,14 +18,14 @@
|
|||
#include "mndAuth.h"
|
||||
#include "mndDnode.h"
|
||||
#include "mndShow.h"
|
||||
#include "mndSma.h"
|
||||
#include "mndStb.h"
|
||||
#include "mndTrans.h"
|
||||
#include "mndUser.h"
|
||||
#include "mndVgroup.h"
|
||||
#include "mndSma.h"
|
||||
|
||||
#define TSDB_DB_VER_NUMBER 1
|
||||
#define TSDB_DB_RESERVE_SIZE 64
|
||||
#define DB_VER_NUMBER 1
|
||||
#define DB_RESERVE_SIZE 64
|
||||
|
||||
static SSdbRaw *mndDbActionEncode(SDbObj *pDb);
|
||||
static SSdbRow *mndDbActionDecode(SSdbRaw *pRaw);
|
||||
|
@ -36,9 +36,8 @@ static int32_t mndProcessCreateDbReq(SNodeMsg *pReq);
|
|||
static int32_t mndProcessAlterDbReq(SNodeMsg *pReq);
|
||||
static int32_t mndProcessDropDbReq(SNodeMsg *pReq);
|
||||
static int32_t mndProcessUseDbReq(SNodeMsg *pReq);
|
||||
static int32_t mndProcessSyncDbReq(SNodeMsg *pReq);
|
||||
static int32_t mndProcessCompactDbReq(SNodeMsg *pReq);
|
||||
static int32_t mndRetrieveDbs(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock* pBlock, int32_t rowsCapacity);
|
||||
static int32_t mndRetrieveDbs(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rowsCapacity);
|
||||
static void mndCancelGetNextDb(SMnode *pMnode, void *pIter);
|
||||
static int32_t mndProcessGetDbCfgReq(SNodeMsg *pReq);
|
||||
static int32_t mndProcessGetIndexReq(SNodeMsg *pReq);
|
||||
|
@ -56,7 +55,6 @@ int32_t mndInitDb(SMnode *pMnode) {
|
|||
mndSetMsgHandle(pMnode, TDMT_MND_ALTER_DB, mndProcessAlterDbReq);
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_DROP_DB, mndProcessDropDbReq);
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_USE_DB, mndProcessUseDbReq);
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_SYNC_DB, mndProcessSyncDbReq);
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_COMPACT_DB, mndProcessCompactDbReq);
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_GET_DB_CFG, mndProcessGetDbCfgReq);
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_GET_INDEX, mndProcessGetIndexReq);
|
||||
|
@ -72,54 +70,57 @@ void mndCleanupDb(SMnode *pMnode) {}
|
|||
static SSdbRaw *mndDbActionEncode(SDbObj *pDb) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
||||
SSdbRaw *pRaw = sdbAllocRaw(SDB_DB, TSDB_DB_VER_NUMBER,
|
||||
sizeof(SDbObj) + pDb->cfg.numOfRetensions * sizeof(SRetention) + TSDB_DB_RESERVE_SIZE);
|
||||
if (pRaw == NULL) goto DB_ENCODE_OVER;
|
||||
int32_t size = sizeof(SDbObj) + pDb->cfg.numOfRetensions * sizeof(SRetention) + DB_RESERVE_SIZE;
|
||||
SSdbRaw *pRaw = sdbAllocRaw(SDB_DB, DB_VER_NUMBER, size);
|
||||
if (pRaw == NULL) goto _OVER;
|
||||
|
||||
int32_t dataPos = 0;
|
||||
SDB_SET_BINARY(pRaw, dataPos, pDb->name, TSDB_DB_FNAME_LEN, DB_ENCODE_OVER)
|
||||
SDB_SET_BINARY(pRaw, dataPos, pDb->acct, TSDB_USER_LEN, DB_ENCODE_OVER)
|
||||
SDB_SET_BINARY(pRaw, dataPos, pDb->createUser, TSDB_USER_LEN, DB_ENCODE_OVER)
|
||||
SDB_SET_INT64(pRaw, dataPos, pDb->createdTime, DB_ENCODE_OVER)
|
||||
SDB_SET_INT64(pRaw, dataPos, pDb->updateTime, DB_ENCODE_OVER)
|
||||
SDB_SET_INT64(pRaw, dataPos, pDb->uid, DB_ENCODE_OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pDb->cfgVersion, DB_ENCODE_OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pDb->vgVersion, DB_ENCODE_OVER)
|
||||
SDB_SET_INT8(pRaw, dataPos, pDb->hashMethod, DB_ENCODE_OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.numOfVgroups, DB_ENCODE_OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.cacheBlockSize, DB_ENCODE_OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.totalBlocks, DB_ENCODE_OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.daysPerFile, DB_ENCODE_OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.daysToKeep0, DB_ENCODE_OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.daysToKeep1, DB_ENCODE_OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.daysToKeep2, DB_ENCODE_OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.minRows, DB_ENCODE_OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.maxRows, DB_ENCODE_OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.commitTime, DB_ENCODE_OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.fsyncPeriod, DB_ENCODE_OVER)
|
||||
SDB_SET_INT8(pRaw, dataPos, pDb->cfg.walLevel, DB_ENCODE_OVER)
|
||||
SDB_SET_INT8(pRaw, dataPos, pDb->cfg.precision, DB_ENCODE_OVER)
|
||||
SDB_SET_INT8(pRaw, dataPos, pDb->cfg.compression, DB_ENCODE_OVER)
|
||||
SDB_SET_INT8(pRaw, dataPos, pDb->cfg.replications, DB_ENCODE_OVER)
|
||||
SDB_SET_INT8(pRaw, dataPos, pDb->cfg.quorum, DB_ENCODE_OVER)
|
||||
SDB_SET_INT8(pRaw, dataPos, pDb->cfg.update, DB_ENCODE_OVER)
|
||||
SDB_SET_INT8(pRaw, dataPos, pDb->cfg.cacheLastRow, DB_ENCODE_OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.numOfRetensions, DB_ENCODE_OVER)
|
||||
SDB_SET_BINARY(pRaw, dataPos, pDb->name, TSDB_DB_FNAME_LEN, _OVER)
|
||||
SDB_SET_BINARY(pRaw, dataPos, pDb->acct, TSDB_USER_LEN, _OVER)
|
||||
SDB_SET_BINARY(pRaw, dataPos, pDb->createUser, TSDB_USER_LEN, _OVER)
|
||||
SDB_SET_INT64(pRaw, dataPos, pDb->createdTime, _OVER)
|
||||
SDB_SET_INT64(pRaw, dataPos, pDb->updateTime, _OVER)
|
||||
SDB_SET_INT64(pRaw, dataPos, pDb->uid, _OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pDb->cfgVersion, _OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pDb->vgVersion, _OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.numOfVgroups, _OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.cacheBlockSize, _OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.totalBlocks, _OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.daysPerFile, _OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.daysToKeep0, _OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.daysToKeep1, _OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.daysToKeep2, _OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.minRows, _OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.maxRows, _OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.commitTime, _OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.fsyncPeriod, _OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.ttl, _OVER)
|
||||
SDB_SET_INT8(pRaw, dataPos, pDb->cfg.walLevel, _OVER)
|
||||
SDB_SET_INT8(pRaw, dataPos, pDb->cfg.precision, _OVER)
|
||||
SDB_SET_INT8(pRaw, dataPos, pDb->cfg.compression, _OVER)
|
||||
SDB_SET_INT8(pRaw, dataPos, pDb->cfg.replications, _OVER)
|
||||
SDB_SET_INT8(pRaw, dataPos, pDb->cfg.strict, _OVER)
|
||||
SDB_SET_INT8(pRaw, dataPos, pDb->cfg.update, _OVER)
|
||||
SDB_SET_INT8(pRaw, dataPos, pDb->cfg.cacheLastRow, _OVER)
|
||||
SDB_SET_INT8(pRaw, dataPos, pDb->cfg.streamMode, _OVER)
|
||||
SDB_SET_INT8(pRaw, dataPos, pDb->cfg.singleSTable, _OVER)
|
||||
SDB_SET_INT8(pRaw, dataPos, pDb->cfg.hashMethod, _OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.numOfRetensions, _OVER)
|
||||
for (int32_t i = 0; i < pDb->cfg.numOfRetensions; ++i) {
|
||||
TASSERT(taosArrayGetSize(pDb->cfg.pRetensions) == pDb->cfg.numOfRetensions);
|
||||
SRetention *pRetension = taosArrayGet(pDb->cfg.pRetensions, i);
|
||||
SDB_SET_INT32(pRaw, dataPos, pRetension->freq, DB_ENCODE_OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pRetension->keep, DB_ENCODE_OVER)
|
||||
SDB_SET_INT8(pRaw, dataPos, pRetension->freqUnit, DB_ENCODE_OVER)
|
||||
SDB_SET_INT8(pRaw, dataPos, pRetension->keepUnit, DB_ENCODE_OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pRetension->freq, _OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pRetension->keep, _OVER)
|
||||
SDB_SET_INT8(pRaw, dataPos, pRetension->freqUnit, _OVER)
|
||||
SDB_SET_INT8(pRaw, dataPos, pRetension->keepUnit, _OVER)
|
||||
}
|
||||
|
||||
SDB_SET_RESERVE(pRaw, dataPos, TSDB_DB_RESERVE_SIZE, DB_ENCODE_OVER)
|
||||
SDB_SET_DATALEN(pRaw, dataPos, DB_ENCODE_OVER)
|
||||
SDB_SET_RESERVE(pRaw, dataPos, DB_RESERVE_SIZE, _OVER)
|
||||
SDB_SET_DATALEN(pRaw, dataPos, _OVER)
|
||||
|
||||
terrno = 0;
|
||||
|
||||
DB_ENCODE_OVER:
|
||||
_OVER:
|
||||
if (terrno != 0) {
|
||||
mError("db:%s, failed to encode to raw:%p since %s", pDb->name, pRaw, terrstr());
|
||||
sdbFreeRaw(pRaw);
|
||||
|
@ -134,68 +135,71 @@ static SSdbRow *mndDbActionDecode(SSdbRaw *pRaw) {
|
|||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
||||
int8_t sver = 0;
|
||||
if (sdbGetRawSoftVer(pRaw, &sver) != 0) goto DB_DECODE_OVER;
|
||||
if (sdbGetRawSoftVer(pRaw, &sver) != 0) goto _OVER;
|
||||
|
||||
if (sver != TSDB_DB_VER_NUMBER) {
|
||||
if (sver != DB_VER_NUMBER) {
|
||||
terrno = TSDB_CODE_SDB_INVALID_DATA_VER;
|
||||
goto DB_DECODE_OVER;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
SSdbRow *pRow = sdbAllocRow(sizeof(SDbObj));
|
||||
if (pRow == NULL) goto DB_DECODE_OVER;
|
||||
if (pRow == NULL) goto _OVER;
|
||||
|
||||
SDbObj *pDb = sdbGetRowObj(pRow);
|
||||
if (pDb == NULL) goto DB_DECODE_OVER;
|
||||
if (pDb == NULL) goto _OVER;
|
||||
|
||||
int32_t dataPos = 0;
|
||||
SDB_GET_BINARY(pRaw, dataPos, pDb->name, TSDB_DB_FNAME_LEN, DB_DECODE_OVER)
|
||||
SDB_GET_BINARY(pRaw, dataPos, pDb->acct, TSDB_USER_LEN, DB_DECODE_OVER)
|
||||
SDB_GET_BINARY(pRaw, dataPos, pDb->createUser, TSDB_USER_LEN, DB_DECODE_OVER)
|
||||
SDB_GET_INT64(pRaw, dataPos, &pDb->createdTime, DB_DECODE_OVER)
|
||||
SDB_GET_INT64(pRaw, dataPos, &pDb->updateTime, DB_DECODE_OVER)
|
||||
SDB_GET_INT64(pRaw, dataPos, &pDb->uid, DB_DECODE_OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pDb->cfgVersion, DB_DECODE_OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pDb->vgVersion, DB_DECODE_OVER)
|
||||
SDB_GET_INT8(pRaw, dataPos, &pDb->hashMethod, DB_DECODE_OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.numOfVgroups, DB_DECODE_OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.cacheBlockSize, DB_DECODE_OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.totalBlocks, DB_DECODE_OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.daysPerFile, DB_DECODE_OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.daysToKeep0, DB_DECODE_OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.daysToKeep1, DB_DECODE_OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.daysToKeep2, DB_DECODE_OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.minRows, DB_DECODE_OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.maxRows, DB_DECODE_OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.commitTime, DB_DECODE_OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.fsyncPeriod, DB_DECODE_OVER)
|
||||
SDB_GET_INT8(pRaw, dataPos, &pDb->cfg.walLevel, DB_DECODE_OVER)
|
||||
SDB_GET_INT8(pRaw, dataPos, &pDb->cfg.precision, DB_DECODE_OVER)
|
||||
SDB_GET_INT8(pRaw, dataPos, &pDb->cfg.compression, DB_DECODE_OVER)
|
||||
SDB_GET_INT8(pRaw, dataPos, &pDb->cfg.replications, DB_DECODE_OVER)
|
||||
SDB_GET_INT8(pRaw, dataPos, &pDb->cfg.quorum, DB_DECODE_OVER)
|
||||
SDB_GET_INT8(pRaw, dataPos, &pDb->cfg.update, DB_DECODE_OVER)
|
||||
SDB_GET_INT8(pRaw, dataPos, &pDb->cfg.cacheLastRow, DB_DECODE_OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.numOfRetensions, DB_DECODE_OVER)
|
||||
SDB_GET_BINARY(pRaw, dataPos, pDb->name, TSDB_DB_FNAME_LEN, _OVER)
|
||||
SDB_GET_BINARY(pRaw, dataPos, pDb->acct, TSDB_USER_LEN, _OVER)
|
||||
SDB_GET_BINARY(pRaw, dataPos, pDb->createUser, TSDB_USER_LEN, _OVER)
|
||||
SDB_GET_INT64(pRaw, dataPos, &pDb->createdTime, _OVER)
|
||||
SDB_GET_INT64(pRaw, dataPos, &pDb->updateTime, _OVER)
|
||||
SDB_GET_INT64(pRaw, dataPos, &pDb->uid, _OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pDb->cfgVersion, _OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pDb->vgVersion, _OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.numOfVgroups, _OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.cacheBlockSize, _OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.totalBlocks, _OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.daysPerFile, _OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.daysToKeep0, _OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.daysToKeep1, _OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.daysToKeep2, _OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.minRows, _OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.maxRows, _OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.commitTime, _OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.fsyncPeriod, _OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.ttl, _OVER)
|
||||
SDB_GET_INT8(pRaw, dataPos, &pDb->cfg.walLevel, _OVER)
|
||||
SDB_GET_INT8(pRaw, dataPos, &pDb->cfg.precision, _OVER)
|
||||
SDB_GET_INT8(pRaw, dataPos, &pDb->cfg.compression, _OVER)
|
||||
SDB_GET_INT8(pRaw, dataPos, &pDb->cfg.replications, _OVER)
|
||||
SDB_GET_INT8(pRaw, dataPos, &pDb->cfg.strict, _OVER)
|
||||
SDB_GET_INT8(pRaw, dataPos, &pDb->cfg.update, _OVER)
|
||||
SDB_GET_INT8(pRaw, dataPos, &pDb->cfg.cacheLastRow, _OVER)
|
||||
SDB_GET_INT8(pRaw, dataPos, &pDb->cfg.streamMode, _OVER)
|
||||
SDB_GET_INT8(pRaw, dataPos, &pDb->cfg.singleSTable, _OVER)
|
||||
SDB_GET_INT8(pRaw, dataPos, &pDb->cfg.hashMethod, _OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.numOfRetensions, _OVER)
|
||||
if (pDb->cfg.numOfRetensions > 0) {
|
||||
pDb->cfg.pRetensions = taosArrayInit(pDb->cfg.numOfRetensions, sizeof(SRetention));
|
||||
if (pDb->cfg.pRetensions == NULL) goto DB_DECODE_OVER;
|
||||
if (pDb->cfg.pRetensions == NULL) goto _OVER;
|
||||
for (int32_t i = 0; i < pDb->cfg.numOfRetensions; ++i) {
|
||||
SRetention retension = {0};
|
||||
SDB_GET_INT32(pRaw, dataPos, &retension.freq, DB_DECODE_OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &retension.keep, DB_DECODE_OVER)
|
||||
SDB_GET_INT8(pRaw, dataPos, &retension.freqUnit, DB_DECODE_OVER)
|
||||
SDB_GET_INT8(pRaw, dataPos, &retension.keepUnit, DB_DECODE_OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &retension.freq, _OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &retension.keep, _OVER)
|
||||
SDB_GET_INT8(pRaw, dataPos, &retension.freqUnit, _OVER)
|
||||
SDB_GET_INT8(pRaw, dataPos, &retension.keepUnit, _OVER)
|
||||
if (taosArrayPush(pDb->cfg.pRetensions, &retension) == NULL) {
|
||||
goto DB_DECODE_OVER;
|
||||
goto _OVER;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SDB_GET_RESERVE(pRaw, dataPos, TSDB_DB_RESERVE_SIZE, DB_DECODE_OVER)
|
||||
SDB_GET_RESERVE(pRaw, dataPos, DB_RESERVE_SIZE, _OVER)
|
||||
|
||||
terrno = 0;
|
||||
|
||||
DB_DECODE_OVER:
|
||||
_OVER:
|
||||
if (terrno != 0) {
|
||||
mError("db:%s, failed to decode from raw:%p since %s", pDb->name, pRaw, terrstr());
|
||||
taosMemoryFreeClear(pRow);
|
||||
|
@ -244,7 +248,7 @@ void mndReleaseDb(SMnode *pMnode, SDbObj *pDb) {
|
|||
sdbRelease(pSdb, pDb);
|
||||
}
|
||||
|
||||
static int32_t mndCheckDbName(char *dbName, SUserObj *pUser) {
|
||||
static int32_t mndCheckDbName(const char *dbName, SUserObj *pUser) {
|
||||
char *pos = strstr(dbName, TS_PATH_DELIMITER);
|
||||
if (pos == NULL) {
|
||||
terrno = TSDB_CODE_MND_INVALID_DB;
|
||||
|
@ -271,23 +275,24 @@ static int32_t mndCheckDbCfg(SMnode *pMnode, SDbCfg *pCfg) {
|
|||
if (pCfg->daysToKeep0 < pCfg->daysPerFile) return -1;
|
||||
if (pCfg->daysToKeep0 > pCfg->daysToKeep1) return -1;
|
||||
if (pCfg->daysToKeep1 > pCfg->daysToKeep2) return -1;
|
||||
if (pCfg->minRows < TSDB_MIN_MIN_ROW_FBLOCK || pCfg->minRows > TSDB_MAX_MIN_ROW_FBLOCK) return -1;
|
||||
if (pCfg->maxRows < TSDB_MIN_MAX_ROW_FBLOCK || pCfg->maxRows > TSDB_MAX_MAX_ROW_FBLOCK) return -1;
|
||||
if (pCfg->minRows < TSDB_MIN_MINROWS_FBLOCK || pCfg->minRows > TSDB_MAX_MINROWS_FBLOCK) return -1;
|
||||
if (pCfg->maxRows < TSDB_MIN_MAXROWS_FBLOCK || pCfg->maxRows > TSDB_MAX_MAXROWS_FBLOCK) return -1;
|
||||
if (pCfg->minRows > pCfg->maxRows) return -1;
|
||||
if (pCfg->commitTime < TSDB_MIN_COMMIT_TIME || pCfg->commitTime > TSDB_MAX_COMMIT_TIME) return -1;
|
||||
if (pCfg->fsyncPeriod < TSDB_MIN_FSYNC_PERIOD || pCfg->fsyncPeriod > TSDB_MAX_FSYNC_PERIOD) return -1;
|
||||
if (pCfg->ttl < TSDB_MIN_DB_TTL_OPTION && pCfg->ttl != TSDB_DEFAULT_DB_TTL_OPTION) return -1;
|
||||
if (pCfg->ttl < TSDB_MIN_DB_TTL) return -1;
|
||||
if (pCfg->walLevel < TSDB_MIN_WAL_LEVEL || pCfg->walLevel > TSDB_MAX_WAL_LEVEL) return -1;
|
||||
if (pCfg->precision < TSDB_MIN_PRECISION && pCfg->precision > TSDB_MAX_PRECISION) return -1;
|
||||
if (pCfg->compression < TSDB_MIN_COMP_LEVEL || pCfg->compression > TSDB_MAX_COMP_LEVEL) return -1;
|
||||
if (pCfg->replications < TSDB_MIN_DB_REPLICA_OPTION || pCfg->replications > TSDB_MAX_DB_REPLICA_OPTION) return -1;
|
||||
if (pCfg->replications < TSDB_MIN_DB_REPLICA || pCfg->replications > TSDB_MAX_DB_REPLICA) return -1;
|
||||
if (pCfg->replications > mndGetDnodeSize(pMnode)) return -1;
|
||||
if (pCfg->quorum < TSDB_MIN_DB_QUORUM_OPTION || pCfg->quorum > TSDB_MAX_DB_QUORUM_OPTION) return -1;
|
||||
if (pCfg->quorum > pCfg->replications) return -1;
|
||||
if (pCfg->strict < TSDB_MIN_DB_STRICT || pCfg->strict > TSDB_MAX_DB_STRICT) return -1;
|
||||
if (pCfg->strict > pCfg->replications) return -1;
|
||||
if (pCfg->update < TSDB_MIN_DB_UPDATE || pCfg->update > TSDB_MAX_DB_UPDATE) return -1;
|
||||
if (pCfg->cacheLastRow < TSDB_MIN_DB_CACHE_LAST_ROW || pCfg->cacheLastRow > TSDB_MAX_DB_CACHE_LAST_ROW) return -1;
|
||||
if (pCfg->streamMode < TSDB_MIN_DB_STREAM_MODE || pCfg->streamMode > TSDB_MAX_DB_STREAM_MODE) return -1;
|
||||
if (pCfg->singleSTable < TSDB_MIN_DB_SINGLE_STABLE_OPTION || pCfg->streamMode > TSDB_MAX_DB_SINGLE_STABLE_OPTION) return -1;
|
||||
if (pCfg->singleSTable < TSDB_MIN_DB_SINGLE_STABLE || pCfg->streamMode > TSDB_MAX_DB_SINGLE_STABLE) return -1;
|
||||
if (pCfg->hashMethod != 1) return -1;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -299,20 +304,20 @@ static void mndSetDefaultDbCfg(SDbCfg *pCfg) {
|
|||
if (pCfg->daysToKeep0 < 0) pCfg->daysToKeep0 = TSDB_DEFAULT_KEEP;
|
||||
if (pCfg->daysToKeep1 < 0) pCfg->daysToKeep1 = pCfg->daysToKeep0;
|
||||
if (pCfg->daysToKeep2 < 0) pCfg->daysToKeep2 = pCfg->daysToKeep1;
|
||||
if (pCfg->minRows < 0) pCfg->minRows = TSDB_DEFAULT_MIN_ROW_FBLOCK;
|
||||
if (pCfg->maxRows < 0) pCfg->maxRows = TSDB_DEFAULT_MAX_ROW_FBLOCK;
|
||||
if (pCfg->minRows < 0) pCfg->minRows = TSDB_DEFAULT_MINROWS_FBLOCK;
|
||||
if (pCfg->maxRows < 0) pCfg->maxRows = TSDB_DEFAULT_MAXROWS_FBLOCK;
|
||||
if (pCfg->commitTime < 0) pCfg->commitTime = TSDB_DEFAULT_COMMIT_TIME;
|
||||
if (pCfg->fsyncPeriod < 0) pCfg->fsyncPeriod = TSDB_DEFAULT_FSYNC_PERIOD;
|
||||
if (pCfg->ttl < 0) pCfg->ttl = TSDB_DEFAULT_DB_TTL_OPTION;
|
||||
if (pCfg->ttl < 0) pCfg->ttl = TSDB_DEFAULT_DB_TTL;
|
||||
if (pCfg->walLevel < 0) pCfg->walLevel = TSDB_DEFAULT_WAL_LEVEL;
|
||||
if (pCfg->precision < 0) pCfg->precision = TSDB_DEFAULT_PRECISION;
|
||||
if (pCfg->compression < 0) pCfg->compression = TSDB_DEFAULT_COMP_LEVEL;
|
||||
if (pCfg->replications < 0) pCfg->replications = TSDB_DEFAULT_DB_REPLICA_OPTION;
|
||||
if (pCfg->quorum < 0) pCfg->quorum = TSDB_DEFAULT_DB_QUORUM_OPTION;
|
||||
if (pCfg->update < 0) pCfg->update = TSDB_DEFAULT_DB_UPDATE_OPTION;
|
||||
if (pCfg->replications < 0) pCfg->replications = TSDB_DEFAULT_DB_REPLICA;
|
||||
if (pCfg->strict < 0) pCfg->strict = TSDB_DEFAULT_DB_STRICT;
|
||||
if (pCfg->update < 0) pCfg->update = TSDB_DEFAULT_DB_UPDATE;
|
||||
if (pCfg->cacheLastRow < 0) pCfg->cacheLastRow = TSDB_DEFAULT_CACHE_LAST_ROW;
|
||||
if (pCfg->streamMode < 0) pCfg->streamMode = TSDB_DEFAULT_DB_STREAM_MODE;
|
||||
if (pCfg->singleSTable < 0) pCfg->singleSTable = TSDB_DEFAULT_DB_SINGLE_STABLE_OPTION;
|
||||
if (pCfg->singleSTable < 0) pCfg->singleSTable = TSDB_DEFAULT_DB_SINGLE_STABLE;
|
||||
if (pCfg->numOfRetensions < 0) pCfg->numOfRetensions = 0;
|
||||
}
|
||||
|
||||
|
@ -435,7 +440,6 @@ static int32_t mndCreateDb(SMnode *pMnode, SNodeMsg *pReq, SCreateDbReq *pCreate
|
|||
dbObj.uid = mndGenerateUid(dbObj.name, TSDB_DB_FNAME_LEN);
|
||||
dbObj.cfgVersion = 1;
|
||||
dbObj.vgVersion = 1;
|
||||
dbObj.hashMethod = 1;
|
||||
memcpy(dbObj.createUser, pUser->user, TSDB_USER_LEN);
|
||||
dbObj.cfg = (SDbCfg){
|
||||
.numOfVgroups = pCreate->numOfVgroups,
|
||||
|
@ -454,11 +458,12 @@ static int32_t mndCreateDb(SMnode *pMnode, SNodeMsg *pReq, SCreateDbReq *pCreate
|
|||
.precision = pCreate->precision,
|
||||
.compression = pCreate->compression,
|
||||
.replications = pCreate->replications,
|
||||
.quorum = pCreate->quorum,
|
||||
.strict = pCreate->strict,
|
||||
.update = pCreate->update,
|
||||
.cacheLastRow = pCreate->cacheLastRow,
|
||||
.streamMode = pCreate->streamMode,
|
||||
.singleSTable = pCreate->singleSTable,
|
||||
.hashMethod = 1,
|
||||
};
|
||||
|
||||
dbObj.cfg.numOfRetensions = pCreate->numOfRetensions;
|
||||
|
@ -486,21 +491,21 @@ static int32_t mndCreateDb(SMnode *pMnode, SNodeMsg *pReq, SCreateDbReq *pCreate
|
|||
|
||||
int32_t code = -1;
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_TYPE_CREATE_DB, &pReq->rpcMsg);
|
||||
if (pTrans == NULL) goto CREATE_DB_OVER;
|
||||
if (pTrans == NULL) goto _OVER;
|
||||
|
||||
mDebug("trans:%d, used to create db:%s", pTrans->id, pCreate->db);
|
||||
|
||||
mndTransSetDbInfo(pTrans, &dbObj);
|
||||
if (mndSetCreateDbRedoLogs(pMnode, pTrans, &dbObj, pVgroups) != 0) goto CREATE_DB_OVER;
|
||||
if (mndSetCreateDbUndoLogs(pMnode, pTrans, &dbObj, pVgroups) != 0) goto CREATE_DB_OVER;
|
||||
if (mndSetCreateDbCommitLogs(pMnode, pTrans, &dbObj, pVgroups) != 0) goto CREATE_DB_OVER;
|
||||
if (mndSetCreateDbRedoActions(pMnode, pTrans, &dbObj, pVgroups) != 0) goto CREATE_DB_OVER;
|
||||
if (mndSetCreateDbUndoActions(pMnode, pTrans, &dbObj, pVgroups) != 0) goto CREATE_DB_OVER;
|
||||
if (mndTransPrepare(pMnode, pTrans) != 0) goto CREATE_DB_OVER;
|
||||
if (mndSetCreateDbRedoLogs(pMnode, pTrans, &dbObj, pVgroups) != 0) goto _OVER;
|
||||
if (mndSetCreateDbUndoLogs(pMnode, pTrans, &dbObj, pVgroups) != 0) goto _OVER;
|
||||
if (mndSetCreateDbCommitLogs(pMnode, pTrans, &dbObj, pVgroups) != 0) goto _OVER;
|
||||
if (mndSetCreateDbRedoActions(pMnode, pTrans, &dbObj, pVgroups) != 0) goto _OVER;
|
||||
if (mndSetCreateDbUndoActions(pMnode, pTrans, &dbObj, pVgroups) != 0) goto _OVER;
|
||||
if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER;
|
||||
|
||||
code = 0;
|
||||
|
||||
CREATE_DB_OVER:
|
||||
_OVER:
|
||||
taosMemoryFree(pVgroups);
|
||||
mndTransDrop(pTrans);
|
||||
return code;
|
||||
|
@ -515,7 +520,7 @@ static int32_t mndProcessCreateDbReq(SNodeMsg *pReq) {
|
|||
|
||||
if (tDeserializeSCreateDbReq(pReq->rpcMsg.pCont, pReq->rpcMsg.contLen, &createReq) != 0) {
|
||||
terrno = TSDB_CODE_INVALID_MSG;
|
||||
goto CREATE_DB_OVER;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
mDebug("db:%s, start to create, vgroups:%d", createReq.db, createReq.numOfVgroups);
|
||||
|
@ -525,28 +530,28 @@ static int32_t mndProcessCreateDbReq(SNodeMsg *pReq) {
|
|||
if (createReq.ignoreExist) {
|
||||
mDebug("db:%s, already exist, ignore exist is set", createReq.db);
|
||||
code = 0;
|
||||
goto CREATE_DB_OVER;
|
||||
goto _OVER;
|
||||
} else {
|
||||
terrno = TSDB_CODE_MND_DB_ALREADY_EXIST;
|
||||
goto CREATE_DB_OVER;
|
||||
goto _OVER;
|
||||
}
|
||||
} else if (terrno != TSDB_CODE_MND_DB_NOT_EXIST) {
|
||||
goto CREATE_DB_OVER;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
pUser = mndAcquireUser(pMnode, pReq->user);
|
||||
if (pUser == NULL) {
|
||||
goto CREATE_DB_OVER;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
if (mndCheckCreateDbAuth(pUser) != 0) {
|
||||
goto CREATE_DB_OVER;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
code = mndCreateDb(pMnode, pReq, &createReq, pUser);
|
||||
if (code == 0) code = TSDB_CODE_MND_ACTION_IN_PROGRESS;
|
||||
|
||||
CREATE_DB_OVER:
|
||||
_OVER:
|
||||
if (code != 0 && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) {
|
||||
mError("db:%s, failed to create since %s", createReq.db, terrstr());
|
||||
}
|
||||
|
@ -591,8 +596,8 @@ static int32_t mndSetDbCfgFromAlterDbReq(SDbObj *pDb, SAlterDbReq *pAlter) {
|
|||
terrno = 0;
|
||||
}
|
||||
|
||||
if (pAlter->quorum >= 0 && pAlter->quorum != pDb->cfg.quorum) {
|
||||
pDb->cfg.quorum = pAlter->quorum;
|
||||
if (pAlter->strict >= 0 && pAlter->strict != pDb->cfg.strict) {
|
||||
pDb->cfg.strict = pAlter->strict;
|
||||
terrno = 0;
|
||||
}
|
||||
|
||||
|
@ -601,6 +606,11 @@ static int32_t mndSetDbCfgFromAlterDbReq(SDbObj *pDb, SAlterDbReq *pAlter) {
|
|||
terrno = 0;
|
||||
}
|
||||
|
||||
if (pAlter->replications >= 0 && pAlter->replications != pDb->cfg.replications) {
|
||||
pDb->cfg.replications = pAlter->replications;
|
||||
terrno = 0;
|
||||
}
|
||||
|
||||
return terrno;
|
||||
}
|
||||
|
||||
|
@ -716,7 +726,7 @@ static int32_t mndProcessAlterDbReq(SNodeMsg *pReq) {
|
|||
goto ALTER_DB_OVER;
|
||||
}
|
||||
|
||||
if (mndCheckAlterDropCompactSyncDbAuth(pUser, pDb) != 0) {
|
||||
if (mndCheckAlterDropCompactDbAuth(pUser, pDb) != 0) {
|
||||
goto ALTER_DB_OVER;
|
||||
}
|
||||
|
||||
|
@ -745,11 +755,11 @@ ALTER_DB_OVER:
|
|||
}
|
||||
|
||||
static int32_t mndProcessGetDbCfgReq(SNodeMsg *pReq) {
|
||||
SMnode *pMnode = pReq->pNode;
|
||||
int32_t code = -1;
|
||||
SDbObj *pDb = NULL;
|
||||
SDbCfgReq cfgReq = {0};
|
||||
SDbCfgRsp cfgRsp = {0};
|
||||
SMnode *pMnode = pReq->pNode;
|
||||
int32_t code = -1;
|
||||
SDbObj *pDb = NULL;
|
||||
SDbCfgReq cfgReq = {0};
|
||||
SDbCfgRsp cfgRsp = {0};
|
||||
|
||||
if (tDeserializeSDbCfgReq(pReq->rpcMsg.pCont, pReq->rpcMsg.contLen, &cfgReq) != 0) {
|
||||
terrno = TSDB_CODE_INVALID_MSG;
|
||||
|
@ -762,27 +772,27 @@ static int32_t mndProcessGetDbCfgReq(SNodeMsg *pReq) {
|
|||
goto GET_DB_CFG_OVER;
|
||||
}
|
||||
|
||||
cfgRsp.numOfVgroups = pDb->cfg.numOfVgroups;
|
||||
cfgRsp.numOfVgroups = pDb->cfg.numOfVgroups;
|
||||
cfgRsp.cacheBlockSize = pDb->cfg.cacheBlockSize;
|
||||
cfgRsp.totalBlocks = pDb->cfg.totalBlocks;
|
||||
cfgRsp.daysPerFile = pDb->cfg.daysPerFile;
|
||||
cfgRsp.daysToKeep0 = pDb->cfg.daysToKeep0;
|
||||
cfgRsp.daysToKeep1 = pDb->cfg.daysToKeep1;
|
||||
cfgRsp.daysToKeep2 = pDb->cfg.daysToKeep2;
|
||||
cfgRsp.minRows = pDb->cfg.minRows;
|
||||
cfgRsp.maxRows = pDb->cfg.maxRows;
|
||||
cfgRsp.commitTime = pDb->cfg.commitTime;
|
||||
cfgRsp.fsyncPeriod = pDb->cfg.fsyncPeriod;
|
||||
cfgRsp.ttl = pDb->cfg.ttl;
|
||||
cfgRsp.walLevel = pDb->cfg.walLevel;
|
||||
cfgRsp.precision = pDb->cfg.precision;
|
||||
cfgRsp.compression = pDb->cfg.compression;
|
||||
cfgRsp.replications = pDb->cfg.replications;
|
||||
cfgRsp.quorum = pDb->cfg.quorum;
|
||||
cfgRsp.update = pDb->cfg.update;
|
||||
cfgRsp.cacheLastRow = pDb->cfg.cacheLastRow;
|
||||
cfgRsp.streamMode = pDb->cfg.streamMode;
|
||||
cfgRsp.singleSTable = pDb->cfg.singleSTable;
|
||||
cfgRsp.totalBlocks = pDb->cfg.totalBlocks;
|
||||
cfgRsp.daysPerFile = pDb->cfg.daysPerFile;
|
||||
cfgRsp.daysToKeep0 = pDb->cfg.daysToKeep0;
|
||||
cfgRsp.daysToKeep1 = pDb->cfg.daysToKeep1;
|
||||
cfgRsp.daysToKeep2 = pDb->cfg.daysToKeep2;
|
||||
cfgRsp.minRows = pDb->cfg.minRows;
|
||||
cfgRsp.maxRows = pDb->cfg.maxRows;
|
||||
cfgRsp.commitTime = pDb->cfg.commitTime;
|
||||
cfgRsp.fsyncPeriod = pDb->cfg.fsyncPeriod;
|
||||
cfgRsp.ttl = pDb->cfg.ttl;
|
||||
cfgRsp.walLevel = pDb->cfg.walLevel;
|
||||
cfgRsp.precision = pDb->cfg.precision;
|
||||
cfgRsp.compression = pDb->cfg.compression;
|
||||
cfgRsp.replications = pDb->cfg.replications;
|
||||
cfgRsp.strict = pDb->cfg.strict;
|
||||
cfgRsp.update = pDb->cfg.update;
|
||||
cfgRsp.cacheLastRow = pDb->cfg.cacheLastRow;
|
||||
cfgRsp.streamMode = pDb->cfg.streamMode;
|
||||
cfgRsp.singleSTable = pDb->cfg.singleSTable;
|
||||
|
||||
int32_t contLen = tSerializeSDbCfgRsp(NULL, 0, &cfgRsp);
|
||||
void *pRsp = rpcMallocCont(contLen);
|
||||
|
@ -808,7 +818,6 @@ GET_DB_CFG_OVER:
|
|||
return code;
|
||||
}
|
||||
|
||||
|
||||
static int32_t mndSetDropDbRedoLogs(SMnode *pMnode, STrans *pTrans, SDbObj *pDb) {
|
||||
SSdbRaw *pRedoRaw = mndDbActionEncode(pDb);
|
||||
if (pRedoRaw == NULL) return -1;
|
||||
|
@ -945,25 +954,25 @@ static int32_t mndBuildDropDbRsp(SDbObj *pDb, int32_t *pRspLen, void **ppRsp, bo
|
|||
static int32_t mndDropDb(SMnode *pMnode, SNodeMsg *pReq, SDbObj *pDb) {
|
||||
int32_t code = -1;
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_TYPE_DROP_DB, &pReq->rpcMsg);
|
||||
if (pTrans == NULL) goto DROP_DB_OVER;
|
||||
if (pTrans == NULL) goto _OVER;
|
||||
|
||||
mDebug("trans:%d, used to drop db:%s", pTrans->id, pDb->name);
|
||||
mndTransSetDbInfo(pTrans, pDb);
|
||||
|
||||
if (mndSetDropDbRedoLogs(pMnode, pTrans, pDb) != 0) goto DROP_DB_OVER;
|
||||
if (mndSetDropDbCommitLogs(pMnode, pTrans, pDb) != 0) goto DROP_DB_OVER;
|
||||
if (mndSetDropDbRedoActions(pMnode, pTrans, pDb) != 0) goto DROP_DB_OVER;
|
||||
if (mndSetDropDbRedoLogs(pMnode, pTrans, pDb) != 0) goto _OVER;
|
||||
if (mndSetDropDbCommitLogs(pMnode, pTrans, pDb) != 0) goto _OVER;
|
||||
if (mndSetDropDbRedoActions(pMnode, pTrans, pDb) != 0) goto _OVER;
|
||||
|
||||
int32_t rspLen = 0;
|
||||
void *pRsp = NULL;
|
||||
if (mndBuildDropDbRsp(pDb, &rspLen, &pRsp, false) < 0) goto DROP_DB_OVER;
|
||||
if (mndBuildDropDbRsp(pDb, &rspLen, &pRsp, false) < 0) goto _OVER;
|
||||
mndTransSetRpcRsp(pTrans, pRsp, rspLen);
|
||||
|
||||
if (mndTransPrepare(pMnode, pTrans) != 0) goto DROP_DB_OVER;
|
||||
if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER;
|
||||
|
||||
code = 0;
|
||||
|
||||
DROP_DB_OVER:
|
||||
_OVER:
|
||||
mndTransDrop(pTrans);
|
||||
return code;
|
||||
}
|
||||
|
@ -977,7 +986,7 @@ static int32_t mndProcessDropDbReq(SNodeMsg *pReq) {
|
|||
|
||||
if (tDeserializeSDropDbReq(pReq->rpcMsg.pCont, pReq->rpcMsg.contLen, &dropReq) != 0) {
|
||||
terrno = TSDB_CODE_INVALID_MSG;
|
||||
goto DROP_DB_OVER;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
mDebug("db:%s, start to drop", dropReq.db);
|
||||
|
@ -986,26 +995,26 @@ static int32_t mndProcessDropDbReq(SNodeMsg *pReq) {
|
|||
if (pDb == NULL) {
|
||||
if (dropReq.ignoreNotExists) {
|
||||
code = mndBuildDropDbRsp(pDb, &pReq->rspLen, &pReq->pRsp, true);
|
||||
goto DROP_DB_OVER;
|
||||
goto _OVER;
|
||||
} else {
|
||||
terrno = TSDB_CODE_MND_DB_NOT_EXIST;
|
||||
goto DROP_DB_OVER;
|
||||
goto _OVER;
|
||||
}
|
||||
}
|
||||
|
||||
pUser = mndAcquireUser(pMnode, pReq->user);
|
||||
if (pUser == NULL) {
|
||||
goto DROP_DB_OVER;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
if (mndCheckAlterDropCompactSyncDbAuth(pUser, pDb) != 0) {
|
||||
goto DROP_DB_OVER;
|
||||
if (mndCheckAlterDropCompactDbAuth(pUser, pDb) != 0) {
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
code = mndDropDb(pMnode, pReq, pDb);
|
||||
if (code == 0) code = TSDB_CODE_MND_ACTION_IN_PROGRESS;
|
||||
|
||||
DROP_DB_OVER:
|
||||
_OVER:
|
||||
if (code != 0 && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) {
|
||||
mError("db:%s, failed to drop since %s", dropReq.db, terrstr());
|
||||
}
|
||||
|
@ -1100,7 +1109,7 @@ int32_t mndExtractDbInfo(SMnode *pMnode, SDbObj *pDb, SUseDbRsp *pRsp, const SUs
|
|||
pRsp->uid = pDb->uid;
|
||||
pRsp->vgVersion = pDb->vgVersion;
|
||||
pRsp->vgNum = taosArrayGetSize(pRsp->pVgroupInfos);
|
||||
pRsp->hashMethod = pDb->hashMethod;
|
||||
pRsp->hashMethod = pDb->cfg.hashMethod;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1243,7 +1252,7 @@ int32_t mndValidateDbInfo(SMnode *pMnode, SDbVgVersion *pDbs, int32_t numOfDbs,
|
|||
usedbRsp.uid = pDb->uid;
|
||||
usedbRsp.vgVersion = pDb->vgVersion;
|
||||
usedbRsp.vgNum = (int32_t)taosArrayGetSize(usedbRsp.pVgroupInfos);
|
||||
usedbRsp.hashMethod = pDb->hashMethod;
|
||||
usedbRsp.hashMethod = pDb->cfg.hashMethod;
|
||||
|
||||
taosArrayPush(batchUseRsp.pArray, &usedbRsp);
|
||||
mndReleaseDb(pMnode, pDb);
|
||||
|
@ -1265,47 +1274,6 @@ int32_t mndValidateDbInfo(SMnode *pMnode, SDbVgVersion *pDbs, int32_t numOfDbs,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int32_t mndProcessSyncDbReq(SNodeMsg *pReq) {
|
||||
SMnode *pMnode = pReq->pNode;
|
||||
int32_t code = -1;
|
||||
SDbObj *pDb = NULL;
|
||||
SUserObj *pUser = NULL;
|
||||
SSyncDbReq syncReq = {0};
|
||||
|
||||
if (tDeserializeSSyncDbReq(pReq->rpcMsg.pCont, pReq->rpcMsg.contLen, &syncReq) != 0) {
|
||||
terrno = TSDB_CODE_INVALID_MSG;
|
||||
goto SYNC_DB_OVER;
|
||||
}
|
||||
|
||||
mDebug("db:%s, start to sync", syncReq.db);
|
||||
|
||||
pDb = mndAcquireDb(pMnode, syncReq.db);
|
||||
if (pDb == NULL) {
|
||||
goto SYNC_DB_OVER;
|
||||
}
|
||||
|
||||
pUser = mndAcquireUser(pMnode, pReq->user);
|
||||
if (pUser == NULL) {
|
||||
goto SYNC_DB_OVER;
|
||||
}
|
||||
|
||||
if (mndCheckAlterDropCompactSyncDbAuth(pUser, pDb) != 0) {
|
||||
goto SYNC_DB_OVER;
|
||||
}
|
||||
|
||||
// code = mndSyncDb();
|
||||
|
||||
SYNC_DB_OVER:
|
||||
if (code != 0) {
|
||||
mError("db:%s, failed to process sync db req since %s", syncReq.db, terrstr());
|
||||
}
|
||||
|
||||
mndReleaseDb(pMnode, pDb);
|
||||
mndReleaseUser(pMnode, pUser);
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t mndProcessCompactDbReq(SNodeMsg *pReq) {
|
||||
SMnode *pMnode = pReq->pNode;
|
||||
int32_t code = -1;
|
||||
|
@ -1313,30 +1281,30 @@ static int32_t mndProcessCompactDbReq(SNodeMsg *pReq) {
|
|||
SUserObj *pUser = NULL;
|
||||
SCompactDbReq compactReq = {0};
|
||||
|
||||
if (tDeserializeSSyncDbReq(pReq->rpcMsg.pCont, pReq->rpcMsg.contLen, &compactReq) != 0) {
|
||||
if (tDeserializeSCompactDbReq(pReq->rpcMsg.pCont, pReq->rpcMsg.contLen, &compactReq) != 0) {
|
||||
terrno = TSDB_CODE_INVALID_MSG;
|
||||
goto SYNC_DB_OVER;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
mDebug("db:%s, start to sync", compactReq.db);
|
||||
|
||||
pDb = mndAcquireDb(pMnode, compactReq.db);
|
||||
if (pDb == NULL) {
|
||||
goto SYNC_DB_OVER;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
pUser = mndAcquireUser(pMnode, pReq->user);
|
||||
if (pUser == NULL) {
|
||||
goto SYNC_DB_OVER;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
if (mndCheckAlterDropCompactSyncDbAuth(pUser, pDb) != 0) {
|
||||
goto SYNC_DB_OVER;
|
||||
if (mndCheckAlterDropCompactDbAuth(pUser, pDb) != 0) {
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
// code = mndSyncDb();
|
||||
// code = mndCompactDb();
|
||||
|
||||
SYNC_DB_OVER:
|
||||
_OVER:
|
||||
if (code != 0) {
|
||||
mError("db:%s, failed to process compact db req since %s", compactReq.db, terrstr());
|
||||
}
|
||||
|
@ -1347,27 +1315,23 @@ SYNC_DB_OVER:
|
|||
return code;
|
||||
}
|
||||
|
||||
char *mndGetDbStr(char *src) {
|
||||
const char *mndGetDbStr(const char *src) {
|
||||
char *pos = strstr(src, TS_PATH_DELIMITER);
|
||||
if (pos != NULL) ++pos;
|
||||
|
||||
if (pos == NULL) {
|
||||
return src;
|
||||
}
|
||||
|
||||
if (pos == NULL) return src;
|
||||
return pos;
|
||||
}
|
||||
|
||||
static void dumpDbInfoData(SSDataBlock* pBlock, SDbObj *pDb, SShowObj *pShow, int32_t rows, int64_t numOfTables, bool sysDb) {
|
||||
static void dumpDbInfoData(SSDataBlock *pBlock, SDbObj *pDb, SShowObj *pShow, int32_t rows, int64_t numOfTables,
|
||||
bool sysDb) {
|
||||
int32_t cols = 0;
|
||||
|
||||
char* buf = taosMemoryMalloc(pShow->bytes[cols]);
|
||||
char *name = mndGetDbStr(pDb->name);
|
||||
char *buf = taosMemoryMalloc(pShow->bytes[cols]);
|
||||
const char *name = mndGetDbStr(pDb->name);
|
||||
if (name != NULL) {
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(buf, name, pShow->bytes[cols]);
|
||||
} else {
|
||||
// STR_TO_VARSTR(pWrite, "NULL");
|
||||
ASSERT(0);
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(buf, "NULL", pShow->bytes[cols]);
|
||||
}
|
||||
|
||||
char *status = "ready";
|
||||
|
@ -1375,8 +1339,8 @@ static void dumpDbInfoData(SSDataBlock* pBlock, SDbObj *pDb, SShowObj *pShow, in
|
|||
STR_WITH_SIZE_TO_VARSTR(b, status, strlen(status));
|
||||
|
||||
if (sysDb) {
|
||||
for(int32_t i = 0; i < pShow->numOfColumns; ++i) {
|
||||
SColumnInfoData* pColInfo = taosArrayGet(pBlock->pDataBlock, i);
|
||||
for (int32_t i = 0; i < pShow->numOfColumns; ++i) {
|
||||
SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, i);
|
||||
if (i == 0) {
|
||||
colDataAppend(pColInfo, rows, buf, false);
|
||||
} else if (i == 3) {
|
||||
|
@ -1404,8 +1368,11 @@ static void dumpDbInfoData(SSDataBlock* pBlock, SDbObj *pDb, SShowObj *pShow, in
|
|||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.replications, false);
|
||||
|
||||
const char *src = pDb->cfg.strict ? "strict" : "nostrict";
|
||||
char b[10 + VARSTR_HEADER_SIZE] = {0};
|
||||
STR_WITH_SIZE_TO_VARSTR(b, src, strlen(src));
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.quorum, false);
|
||||
colDataAppend(pColInfo, rows, (const char *)b, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.daysPerFile, false);
|
||||
|
@ -1484,7 +1451,6 @@ static void dumpDbInfoData(SSDataBlock* pBlock, SDbObj *pDb, SShowObj *pShow, in
|
|||
|
||||
// pWrite = getDataPosition(data, pShow, cols, rows, rowCapacity);
|
||||
// *(int8_t *)pWrite = pDb->cfg.update;
|
||||
|
||||
}
|
||||
|
||||
static void setInformationSchemaDbCfg(SDbObj *pDbObj) {
|
||||
|
@ -1493,19 +1459,19 @@ static void setInformationSchemaDbCfg(SDbObj *pDbObj) {
|
|||
|
||||
pDbObj->createdTime = 0;
|
||||
pDbObj->cfg.numOfVgroups = 0;
|
||||
pDbObj->cfg.quorum = 1;
|
||||
pDbObj->cfg.strict = 1;
|
||||
pDbObj->cfg.replications = 1;
|
||||
pDbObj->cfg.update = 1;
|
||||
pDbObj->cfg.precision = TSDB_TIME_PRECISION_MILLI;
|
||||
}
|
||||
|
||||
static void setPerfSchemaDbCfg(SDbObj* pDbObj) {
|
||||
static void setPerfSchemaDbCfg(SDbObj *pDbObj) {
|
||||
ASSERT(pDbObj != NULL);
|
||||
strncpy(pDbObj->name, TSDB_PERFORMANCE_SCHEMA_DB, tListLen(pDbObj->name));
|
||||
|
||||
pDbObj->createdTime = 0;
|
||||
pDbObj->cfg.numOfVgroups = 0;
|
||||
pDbObj->cfg.quorum = 1;
|
||||
pDbObj->cfg.strict = 1;
|
||||
pDbObj->cfg.replications = 1;
|
||||
pDbObj->cfg.update = 1;
|
||||
pDbObj->cfg.precision = TSDB_TIME_PRECISION_MILLI;
|
||||
|
@ -1519,7 +1485,7 @@ static bool mndGetTablesOfDbFp(SMnode *pMnode, void *pObj, void *p1, void *p2, v
|
|||
return true;
|
||||
}
|
||||
|
||||
static int32_t mndRetrieveDbs(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock* pBlock, int32_t rowsCapacity) {
|
||||
static int32_t mndRetrieveDbs(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rowsCapacity) {
|
||||
SMnode *pMnode = pReq->pNode;
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
int32_t numOfRows = 0;
|
||||
|
@ -1567,10 +1533,10 @@ static void mndCancelGetNextDb(SMnode *pMnode, void *pIter) {
|
|||
|
||||
static int32_t mndProcessGetIndexReq(SNodeMsg *pReq) {
|
||||
SUserIndexReq indexReq = {0};
|
||||
SMnode *pMnode = pReq->pNode;
|
||||
int32_t code = -1;
|
||||
SMnode *pMnode = pReq->pNode;
|
||||
int32_t code = -1;
|
||||
SUserIndexRsp rsp = {0};
|
||||
bool exist = false;
|
||||
bool exist = false;
|
||||
|
||||
if (tDeserializeSUserIndexReq(pReq->rpcMsg.pCont, pReq->rpcMsg.contLen, &indexReq) != 0) {
|
||||
terrno = TSDB_CODE_INVALID_MSG;
|
||||
|
@ -1583,7 +1549,7 @@ static int32_t mndProcessGetIndexReq(SNodeMsg *pReq) {
|
|||
}
|
||||
|
||||
if (!exist) {
|
||||
//TODO GET INDEX FROM FULLTEXT
|
||||
// TODO GET INDEX FROM FULLTEXT
|
||||
code = -1;
|
||||
terrno = TSDB_CODE_MND_DB_INDEX_NOT_EXIST;
|
||||
} else {
|
||||
|
@ -1594,9 +1560,9 @@ static int32_t mndProcessGetIndexReq(SNodeMsg *pReq) {
|
|||
code = -1;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
|
||||
tSerializeSUserIndexRsp(pRsp, contLen, &rsp);
|
||||
|
||||
|
||||
pReq->pRsp = pRsp;
|
||||
pReq->rspLen = contLen;
|
||||
|
||||
|
@ -1610,4 +1576,3 @@ _OVER:
|
|||
|
||||
return code;
|
||||
}
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ static const SInfosTableSchema userDBSchema[] = {
|
|||
{.name = "vgroups", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT},
|
||||
{.name = "ntables", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT},
|
||||
{.name = "replica", .bytes = 2, .type = TSDB_DATA_TYPE_TINYINT},
|
||||
{.name = "quorum", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT},
|
||||
{.name = "strict", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "days", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "keep", .bytes = 24 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "cache", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
|
|
|
@ -205,7 +205,7 @@ void *mndBuildCreateVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVg
|
|||
createReq.walLevel = pDb->cfg.walLevel;
|
||||
createReq.precision = pDb->cfg.precision;
|
||||
createReq.compression = pDb->cfg.compression;
|
||||
createReq.quorum = pDb->cfg.quorum;
|
||||
createReq.strict = pDb->cfg.strict;
|
||||
createReq.update = pDb->cfg.update;
|
||||
createReq.cacheLastRow = pDb->cfg.cacheLastRow;
|
||||
createReq.replica = pVgroup->replica;
|
||||
|
@ -213,7 +213,7 @@ void *mndBuildCreateVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVg
|
|||
createReq.streamMode = pVgroup->streamMode;
|
||||
createReq.hashBegin = pVgroup->hashBegin;
|
||||
createReq.hashEnd = pVgroup->hashEnd;
|
||||
createReq.hashMethod = pDb->hashMethod;
|
||||
createReq.hashMethod = pDb->cfg.hashMethod;
|
||||
createReq.numOfRetensions = pDb->cfg.numOfRetensions;
|
||||
createReq.pRetensions = pDb->cfg.pRetensions;
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ TEST_F(MndTestDb, 02_Create_Alter_Drop_Db) {
|
|||
createReq.precision = 0;
|
||||
createReq.compression = 2;
|
||||
createReq.replications = 1;
|
||||
createReq.quorum = 1;
|
||||
createReq.strict = 1;
|
||||
createReq.update = 0;
|
||||
createReq.cacheLastRow = 0;
|
||||
createReq.ignoreExist = 1;
|
||||
|
@ -82,7 +82,7 @@ TEST_F(MndTestDb, 02_Create_Alter_Drop_Db) {
|
|||
alterdbReq.daysToKeep2 = 500;
|
||||
alterdbReq.fsyncPeriod = 4000;
|
||||
alterdbReq.walLevel = 2;
|
||||
alterdbReq.quorum = 2;
|
||||
alterdbReq.strict = 2;
|
||||
alterdbReq.cacheLastRow = 1;
|
||||
|
||||
int32_t contLen = tSerializeSAlterDbReq(NULL, 0, &alterdbReq);
|
||||
|
@ -144,7 +144,7 @@ TEST_F(MndTestDb, 03_Create_Use_Restart_Use_Db) {
|
|||
createReq.precision = 0;
|
||||
createReq.compression = 2;
|
||||
createReq.replications = 1;
|
||||
createReq.quorum = 1;
|
||||
createReq.strict = 1;
|
||||
createReq.update = 0;
|
||||
createReq.cacheLastRow = 0;
|
||||
createReq.ignoreExist = 1;
|
||||
|
|
|
@ -54,7 +54,7 @@ void* MndTestSma::BuildCreateDbReq(const char* dbname, int32_t* pContLen) {
|
|||
createReq.precision = 0;
|
||||
createReq.compression = 2;
|
||||
createReq.replications = 1;
|
||||
createReq.quorum = 1;
|
||||
createReq.strict = 1;
|
||||
createReq.update = 0;
|
||||
createReq.cacheLastRow = 0;
|
||||
createReq.ignoreExist = 1;
|
||||
|
|
|
@ -55,7 +55,7 @@ void* MndTestStb::BuildCreateDbReq(const char* dbname, int32_t* pContLen) {
|
|||
createReq.precision = 0;
|
||||
createReq.compression = 2;
|
||||
createReq.replications = 1;
|
||||
createReq.quorum = 1;
|
||||
createReq.strict = 1;
|
||||
createReq.update = 0;
|
||||
createReq.cacheLastRow = 0;
|
||||
createReq.ignoreExist = 1;
|
||||
|
|
|
@ -47,7 +47,7 @@ void* MndTestTopic::BuildCreateDbReq(const char* dbname, int32_t* pContLen) {
|
|||
createReq.precision = 0;
|
||||
createReq.compression = 2;
|
||||
createReq.replications = 1;
|
||||
createReq.quorum = 1;
|
||||
createReq.strict = 1;
|
||||
createReq.update = 0;
|
||||
createReq.cacheLastRow = 0;
|
||||
createReq.ignoreExist = 1;
|
||||
|
|
|
@ -300,7 +300,7 @@ TEST_F(MndTestUser, 03_Alter_User) {
|
|||
createReq.precision = 0;
|
||||
createReq.compression = 2;
|
||||
createReq.replications = 1;
|
||||
createReq.quorum = 1;
|
||||
createReq.strict = 1;
|
||||
createReq.update = 0;
|
||||
createReq.cacheLastRow = 0;
|
||||
createReq.ignoreExist = 1;
|
||||
|
|
|
@ -601,26 +601,26 @@ static int32_t tsdbCheckAndSetDefaultCfg(STsdbCfg *pCfg) {
|
|||
|
||||
// Check minRowsPerFileBlock and maxRowsPerFileBlock
|
||||
if (pCfg->minRowsPerFileBlock == -1) {
|
||||
pCfg->minRowsPerFileBlock = TSDB_DEFAULT_MIN_ROW_FBLOCK;
|
||||
pCfg->minRowsPerFileBlock = TSDB_DEFAULT_MINROWS_FBLOCK;
|
||||
} else {
|
||||
if (pCfg->minRowsPerFileBlock < TSDB_MIN_MIN_ROW_FBLOCK || pCfg->minRowsPerFileBlock > TSDB_MAX_MIN_ROW_FBLOCK) {
|
||||
if (pCfg->minRowsPerFileBlock < TSDB_MIN_MINROWS_FBLOCK || pCfg->minRowsPerFileBlock > TSDB_MAX_MINROWS_FBLOCK) {
|
||||
tsdbError(
|
||||
"vgId:%d invalid minRowsPerFileBlock configuration! minRowsPerFileBlock %d TSDB_MIN_MIN_ROW_FBLOCK %d "
|
||||
"TSDB_MAX_MIN_ROW_FBLOCK %d",
|
||||
pCfg->tsdbId, pCfg->minRowsPerFileBlock, TSDB_MIN_MIN_ROW_FBLOCK, TSDB_MAX_MIN_ROW_FBLOCK);
|
||||
"vgId:%d invalid minRowsPerFileBlock configuration! minRowsPerFileBlock %d TSDB_MIN_MINROWS_FBLOCK %d "
|
||||
"TSDB_MAX_MINROWS_FBLOCK %d",
|
||||
pCfg->tsdbId, pCfg->minRowsPerFileBlock, TSDB_MIN_MINROWS_FBLOCK, TSDB_MAX_MINROWS_FBLOCK);
|
||||
terrno = TSDB_CODE_TDB_INVALID_CONFIG;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (pCfg->maxRowsPerFileBlock == -1) {
|
||||
pCfg->maxRowsPerFileBlock = TSDB_DEFAULT_MAX_ROW_FBLOCK;
|
||||
pCfg->maxRowsPerFileBlock = TSDB_DEFAULT_MAXROWS_FBLOCK;
|
||||
} else {
|
||||
if (pCfg->maxRowsPerFileBlock < TSDB_MIN_MAX_ROW_FBLOCK || pCfg->maxRowsPerFileBlock > TSDB_MAX_MAX_ROW_FBLOCK) {
|
||||
if (pCfg->maxRowsPerFileBlock < TSDB_MIN_MAXROWS_FBLOCK || pCfg->maxRowsPerFileBlock > TSDB_MAX_MAXROWS_FBLOCK) {
|
||||
tsdbError(
|
||||
"vgId:%d invalid maxRowsPerFileBlock configuration! maxRowsPerFileBlock %d TSDB_MIN_MAX_ROW_FBLOCK %d "
|
||||
"TSDB_MAX_MAX_ROW_FBLOCK %d",
|
||||
pCfg->tsdbId, pCfg->maxRowsPerFileBlock, TSDB_MIN_MIN_ROW_FBLOCK, TSDB_MAX_MIN_ROW_FBLOCK);
|
||||
"vgId:%d invalid maxRowsPerFileBlock configuration! maxRowsPerFileBlock %d TSDB_MIN_MAXROWS_FBLOCK %d "
|
||||
"TSDB_MAX_MAXROWS_FBLOCK %d",
|
||||
pCfg->tsdbId, pCfg->maxRowsPerFileBlock, TSDB_MIN_MINROWS_FBLOCK, TSDB_MAX_MINROWS_FBLOCK);
|
||||
terrno = TSDB_CODE_TDB_INVALID_CONFIG;
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -108,7 +108,7 @@ void sendCreateDbMsg(void *shandle, SEpSet *pEpSet) {
|
|||
createReq.precision = 0;
|
||||
createReq.compression = 2;
|
||||
createReq.replications = 1;
|
||||
createReq.quorum = 1;
|
||||
createReq.strict = 1;
|
||||
createReq.update = 0;
|
||||
createReq.cacheLastRow = 0;
|
||||
createReq.ignoreExist = 1;
|
||||
|
|
|
@ -451,8 +451,8 @@ static SSDataBlock* doBlockInfoScan(SOperatorInfo* pOperator, bool* newgroup) {
|
|||
STableBlockDistInfo tableBlockDist = {0};
|
||||
tableBlockDist.numOfTables = 1; // TODO set the correct number of tables
|
||||
|
||||
int32_t numRowSteps = TSDB_DEFAULT_MAX_ROW_FBLOCK / TSDB_BLOCK_DIST_STEP_ROWS;
|
||||
if (TSDB_DEFAULT_MAX_ROW_FBLOCK % TSDB_BLOCK_DIST_STEP_ROWS != 0) {
|
||||
int32_t numRowSteps = TSDB_DEFAULT_MAXROWS_FBLOCK / TSDB_BLOCK_DIST_STEP_ROWS;
|
||||
if (TSDB_DEFAULT_MAXROWS_FBLOCK % TSDB_BLOCK_DIST_STEP_ROWS != 0) {
|
||||
++numRowSteps;
|
||||
}
|
||||
|
||||
|
|
|
@ -4034,8 +4034,8 @@ static void mergeTableBlockDist(SResultRowEntryInfo* pResInfo, const STableBlock
|
|||
pDist->maxRows = pSrc->maxRows;
|
||||
pDist->minRows = pSrc->minRows;
|
||||
|
||||
int32_t maxSteps = TSDB_MAX_MAX_ROW_FBLOCK/TSDB_BLOCK_DIST_STEP_ROWS;
|
||||
if (TSDB_MAX_MAX_ROW_FBLOCK % TSDB_BLOCK_DIST_STEP_ROWS != 0) {
|
||||
int32_t maxSteps = TSDB_MAX_MAXROWS_FBLOCK/TSDB_BLOCK_DIST_STEP_ROWS;
|
||||
if (TSDB_MAX_MAXROWS_FBLOCK % TSDB_BLOCK_DIST_STEP_ROWS != 0) {
|
||||
++maxSteps;
|
||||
}
|
||||
pDist->dataBlockInfos = taosArrayInit(maxSteps, sizeof(SFileBlockInfo));
|
||||
|
|
|
@ -1350,21 +1350,21 @@ static int32_t buildCreateDbReq(STranslateContext* pCxt, SCreateDatabaseStmt* pS
|
|||
pReq->daysToKeep0 = GET_OPTION_VAL(nodesListGetNode(pStmt->pOptions->pKeep, 0), TSDB_DEFAULT_KEEP);
|
||||
pReq->daysToKeep1 = GET_OPTION_VAL(nodesListGetNode(pStmt->pOptions->pKeep, 1), TSDB_DEFAULT_KEEP);
|
||||
pReq->daysToKeep2 = GET_OPTION_VAL(nodesListGetNode(pStmt->pOptions->pKeep, 2), TSDB_DEFAULT_KEEP);
|
||||
pReq->minRows = GET_OPTION_VAL(pStmt->pOptions->pMinRowsPerBlock, TSDB_DEFAULT_MIN_ROW_FBLOCK);
|
||||
pReq->maxRows = GET_OPTION_VAL(pStmt->pOptions->pMaxRowsPerBlock, TSDB_DEFAULT_MAX_ROW_FBLOCK);
|
||||
pReq->minRows = GET_OPTION_VAL(pStmt->pOptions->pMinRowsPerBlock, TSDB_DEFAULT_MINROWS_FBLOCK);
|
||||
pReq->maxRows = GET_OPTION_VAL(pStmt->pOptions->pMaxRowsPerBlock, TSDB_DEFAULT_MAXROWS_FBLOCK);
|
||||
pReq->commitTime = -1;
|
||||
pReq->fsyncPeriod = GET_OPTION_VAL(pStmt->pOptions->pFsyncPeriod, TSDB_DEFAULT_FSYNC_PERIOD);
|
||||
pReq->walLevel = GET_OPTION_VAL(pStmt->pOptions->pWalLevel, TSDB_DEFAULT_WAL_LEVEL);
|
||||
pReq->precision = GET_OPTION_VAL(pStmt->pOptions->pPrecision, TSDB_TIME_PRECISION_MILLI);
|
||||
pReq->compression = GET_OPTION_VAL(pStmt->pOptions->pCompressionLevel, TSDB_DEFAULT_COMP_LEVEL);
|
||||
pReq->replications = GET_OPTION_VAL(pStmt->pOptions->pReplica, TSDB_DEFAULT_DB_REPLICA_OPTION);
|
||||
pReq->quorum = GET_OPTION_VAL(pStmt->pOptions->pQuorum, TSDB_DEFAULT_DB_QUORUM_OPTION);
|
||||
pReq->replications = GET_OPTION_VAL(pStmt->pOptions->pReplica, TSDB_DEFAULT_DB_REPLICA);
|
||||
pReq->strict = GET_OPTION_VAL(pStmt->pOptions->pQuorum, TSDB_DEFAULT_DB_STRICT);
|
||||
pReq->update = -1;
|
||||
pReq->cacheLastRow = GET_OPTION_VAL(pStmt->pOptions->pCachelast, TSDB_DEFAULT_CACHE_LAST_ROW);
|
||||
pReq->ignoreExist = pStmt->ignoreExists;
|
||||
pReq->streamMode = GET_OPTION_VAL(pStmt->pOptions->pStreamMode, TSDB_DEFAULT_DB_STREAM_MODE_OPTION);
|
||||
pReq->ttl = GET_OPTION_VAL(pStmt->pOptions->pTtl, TSDB_DEFAULT_DB_TTL_OPTION);
|
||||
pReq->singleSTable = GET_OPTION_VAL(pStmt->pOptions->pSingleStable, TSDB_DEFAULT_DB_SINGLE_STABLE_OPTION);
|
||||
pReq->streamMode = GET_OPTION_VAL(pStmt->pOptions->pStreamMode, TSDB_DEFAULT_DB_STREAM_MODE);
|
||||
pReq->ttl = GET_OPTION_VAL(pStmt->pOptions->pTtl, TSDB_DEFAULT_DB_TTL);
|
||||
pReq->singleSTable = GET_OPTION_VAL(pStmt->pOptions->pSingleStable, TSDB_DEFAULT_DB_SINGLE_STABLE);
|
||||
return buildCreateDbRetentions(pStmt->pOptions->pRetentions, pReq);
|
||||
}
|
||||
|
||||
|
@ -1431,8 +1431,8 @@ static int32_t checkTtlOption(STranslateContext* pCxt, SValueNode* pVal) {
|
|||
return pCxt->errCode;
|
||||
}
|
||||
int64_t val = pVal->datum.i;
|
||||
if (val < TSDB_MIN_DB_TTL_OPTION) {
|
||||
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_INVALID_TTL_OPTION, val, TSDB_MIN_DB_TTL_OPTION);
|
||||
if (val < TSDB_MIN_DB_TTL) {
|
||||
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_INVALID_TTL_OPTION, val, TSDB_MIN_DB_TTL);
|
||||
}
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -1539,12 +1539,12 @@ static int32_t checkDatabaseOptions(STranslateContext* pCxt, SDatabaseOptions* p
|
|||
code = checkRangeOption(pCxt, "fsyncPeriod", pOptions->pFsyncPeriod, TSDB_MIN_FSYNC_PERIOD, TSDB_MAX_FSYNC_PERIOD);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = checkRangeOption(pCxt, "maxRowsPerBlock", pOptions->pMaxRowsPerBlock, TSDB_MIN_MAX_ROW_FBLOCK,
|
||||
TSDB_MAX_MAX_ROW_FBLOCK);
|
||||
code = checkRangeOption(pCxt, "maxRowsPerBlock", pOptions->pMaxRowsPerBlock, TSDB_MIN_MAXROWS_FBLOCK,
|
||||
TSDB_MAX_MAXROWS_FBLOCK);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = checkRangeOption(pCxt, "minRowsPerBlock", pOptions->pMinRowsPerBlock, TSDB_MIN_MIN_ROW_FBLOCK,
|
||||
TSDB_MAX_MIN_ROW_FBLOCK);
|
||||
code = checkRangeOption(pCxt, "minRowsPerBlock", pOptions->pMinRowsPerBlock, TSDB_MIN_MINROWS_FBLOCK,
|
||||
TSDB_MAX_MINROWS_FBLOCK);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = checkKeepOption(pCxt, pOptions->pKeep);
|
||||
|
@ -1553,11 +1553,10 @@ static int32_t checkDatabaseOptions(STranslateContext* pCxt, SDatabaseOptions* p
|
|||
code = checkDbPrecisionOption(pCxt, pOptions->pPrecision);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = checkRangeOption(pCxt, "quorum", pOptions->pQuorum, TSDB_MIN_DB_QUORUM_OPTION, TSDB_MAX_DB_QUORUM_OPTION);
|
||||
code = checkRangeOption(pCxt, "quorum", pOptions->pQuorum, TSDB_MIN_DB_STRICT, TSDB_MAX_DB_STRICT);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = checkDbEnumOption(pCxt, "replications", pOptions->pReplica, TSDB_MIN_DB_REPLICA_OPTION,
|
||||
TSDB_MAX_DB_REPLICA_OPTION);
|
||||
code = checkDbEnumOption(pCxt, "replications", pOptions->pReplica, TSDB_MIN_DB_REPLICA, TSDB_MAX_DB_REPLICA);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = checkTtlOption(pCxt, pOptions->pTtl);
|
||||
|
@ -1569,12 +1568,12 @@ static int32_t checkDatabaseOptions(STranslateContext* pCxt, SDatabaseOptions* p
|
|||
code = checkRangeOption(pCxt, "vgroups", pOptions->pNumOfVgroups, TSDB_MIN_VNODES_PER_DB, TSDB_MAX_VNODES_PER_DB);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = checkDbEnumOption(pCxt, "singleStable", pOptions->pSingleStable, TSDB_MIN_DB_SINGLE_STABLE_OPTION,
|
||||
TSDB_MAX_DB_SINGLE_STABLE_OPTION);
|
||||
code = checkDbEnumOption(pCxt, "singleStable", pOptions->pSingleStable, TSDB_MIN_DB_SINGLE_STABLE,
|
||||
TSDB_MAX_DB_SINGLE_STABLE);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = checkDbEnumOption(pCxt, "streamMode", pOptions->pStreamMode, TSDB_MIN_DB_STREAM_MODE_OPTION,
|
||||
TSDB_MAX_DB_STREAM_MODE_OPTION);
|
||||
code =
|
||||
checkDbEnumOption(pCxt, "streamMode", pOptions->pStreamMode, TSDB_MIN_DB_STREAM_MODE, TSDB_MAX_DB_STREAM_MODE);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = checkDbRetentionsOption(pCxt, pOptions->pRetentions);
|
||||
|
@ -1640,7 +1639,7 @@ static void buildAlterDbReq(STranslateContext* pCxt, SAlterDatabaseStmt* pStmt,
|
|||
pReq->daysToKeep2 = GET_OPTION_VAL(nodesListGetNode(pStmt->pOptions->pKeep, 2), -1);
|
||||
pReq->fsyncPeriod = GET_OPTION_VAL(pStmt->pOptions->pFsyncPeriod, -1);
|
||||
pReq->walLevel = GET_OPTION_VAL(pStmt->pOptions->pWalLevel, -1);
|
||||
pReq->quorum = GET_OPTION_VAL(pStmt->pOptions->pQuorum, -1);
|
||||
pReq->strict = GET_OPTION_VAL(pStmt->pOptions->pQuorum, -1);
|
||||
pReq->cacheLastRow = GET_OPTION_VAL(pStmt->pOptions->pCachelast, -1);
|
||||
pReq->replications = GET_OPTION_VAL(pStmt->pOptions->pReplica, -1);
|
||||
return;
|
||||
|
|
Loading…
Reference in New Issue