Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
25c67f6e
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
25c67f6e
编写于
9月 02, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enh: add hash prefix and suffix option to db
上级
6603a2ed
变更
10
显示空白变更内容
内联
并排
Showing
10 changed file
with
54 addition
and
5 deletion
+54
-5
include/common/tmsg.h
include/common/tmsg.h
+4
-0
include/util/tdef.h
include/util/tdef.h
+6
-0
include/util/tutil.h
include/util/tutil.h
+3
-0
source/common/src/tmsg.c
source/common/src/tmsg.c
+8
-0
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
+5
-1
source/dnode/mnode/impl/inc/mndDef.h
source/dnode/mnode/impl/inc/mndDef.h
+4
-2
source/dnode/mnode/impl/src/mndDb.c
source/dnode/mnode/impl/src/mndDb.c
+11
-1
source/dnode/mnode/impl/src/mndVgroup.c
source/dnode/mnode/impl/src/mndVgroup.c
+2
-0
source/dnode/vnode/inc/vnode.h
source/dnode/vnode/inc/vnode.h
+2
-0
source/dnode/vnode/src/vnd/vnodeCfg.c
source/dnode/vnode/src/vnd/vnodeCfg.c
+9
-1
未找到文件。
include/common/tmsg.h
浏览文件 @
25c67f6e
...
...
@@ -785,6 +785,8 @@ typedef struct {
int32_t
walRollPeriod
;
int64_t
walSegmentSize
;
int32_t
sstTrigger
;
int16_t
hashPrefix
;
int16_t
hashSuffix
;
}
SCreateDbReq
;
int32_t
tSerializeSCreateDbReq
(
void
*
buf
,
int32_t
bufLen
,
SCreateDbReq
*
pReq
);
...
...
@@ -1193,6 +1195,8 @@ typedef struct {
int32_t
walRollPeriod
;
int64_t
walSegmentSize
;
int16_t
sstTrigger
;
int16_t
hashPrefix
;
int16_t
hashSuffix
;
}
SCreateVnodeReq
;
int32_t
tSerializeSCreateVnodeReq
(
void
*
buf
,
int32_t
bufLen
,
SCreateVnodeReq
*
pReq
);
...
...
include/util/tdef.h
浏览文件 @
25c67f6e
...
...
@@ -362,6 +362,12 @@ typedef enum ELogicConditionType {
#define TSDB_MIN_SST_TRIGGER 1
#define TSDB_MAX_SST_TRIGGER 128
#define TSDB_DEFAULT_SST_TRIGGER 8
#define TSDB_MIN_HASH_PREFIX 0
#define TSDB_MAX_HASH_PREFIX 128
#define TSDB_DEFAULT_HASH_PREFIX 0
#define TSDB_MIN_HASH_SUFFIX 0
#define TSDB_MAX_HASH_SUFFIX 128
#define TSDB_DEFAULT_HASH_SUFFIX 0
#define TSDB_DB_MIN_WAL_RETENTION_PERIOD -1
#define TSDB_REP_DEF_DB_WAL_RET_PERIOD 0
...
...
include/util/tutil.h
浏览文件 @
25c67f6e
...
...
@@ -20,6 +20,7 @@
#include "tcrc32c.h"
#include "tdef.h"
#include "tmd5.h"
#include "thash.h"
#ifdef __cplusplus
extern
"C"
{
...
...
@@ -68,6 +69,8 @@ static FORCE_INLINE void taosEncryptPass_c(uint8_t *inBuf, size_t len, char *tar
memcpy
(
target
,
buf
,
TSDB_PASSWORD_LEN
);
}
#define taosGetTbHashVal(tbname, tblen, method, prefix, suffix) MurmurHash3_32((tbname), (tblen))
#ifdef __cplusplus
}
#endif
...
...
source/common/src/tmsg.c
浏览文件 @
25c67f6e
...
...
@@ -2025,6 +2025,8 @@ int32_t tSerializeSCreateDbReq(void *buf, int32_t bufLen, SCreateDbReq *pReq) {
if
(
tEncodeI32
(
&
encoder
,
pReq
->
walRollPeriod
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
&
encoder
,
pReq
->
walSegmentSize
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
sstTrigger
)
<
0
)
return
-
1
;
if
(
tEncodeI16
(
&
encoder
,
pReq
->
hashPrefix
)
<
0
)
return
-
1
;
if
(
tEncodeI16
(
&
encoder
,
pReq
->
hashSuffix
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
ignoreExist
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
numOfRetensions
)
<
0
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
pReq
->
numOfRetensions
;
++
i
)
{
...
...
@@ -2072,6 +2074,8 @@ int32_t tDeserializeSCreateDbReq(void *buf, int32_t bufLen, SCreateDbReq *pReq)
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
walRollPeriod
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
&
decoder
,
&
pReq
->
walSegmentSize
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
sstTrigger
)
<
0
)
return
-
1
;
if
(
tDecodeI16
(
&
decoder
,
&
pReq
->
hashPrefix
)
<
0
)
return
-
1
;
if
(
tDecodeI16
(
&
decoder
,
&
pReq
->
hashSuffix
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
ignoreExist
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
numOfRetensions
)
<
0
)
return
-
1
;
pReq
->
pRetensions
=
taosArrayInit
(
pReq
->
numOfRetensions
,
sizeof
(
SRetention
));
...
...
@@ -3767,6 +3771,8 @@ int32_t tSerializeSCreateVnodeReq(void *buf, int32_t bufLen, SCreateVnodeReq *pR
if
(
tEncodeI32
(
&
encoder
,
pReq
->
walRollPeriod
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
&
encoder
,
pReq
->
walSegmentSize
)
<
0
)
return
-
1
;
if
(
tEncodeI16
(
&
encoder
,
pReq
->
sstTrigger
)
<
0
)
return
-
1
;
if
(
tEncodeI16
(
&
encoder
,
pReq
->
hashPrefix
)
<
0
)
return
-
1
;
if
(
tEncodeI16
(
&
encoder
,
pReq
->
hashSuffix
)
<
0
)
return
-
1
;
tEndEncode
(
&
encoder
);
...
...
@@ -3840,6 +3846,8 @@ int32_t tDeserializeSCreateVnodeReq(void *buf, int32_t bufLen, SCreateVnodeReq *
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
walRollPeriod
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
&
decoder
,
&
pReq
->
walSegmentSize
)
<
0
)
return
-
1
;
if
(
tDecodeI16
(
&
decoder
,
&
pReq
->
sstTrigger
)
<
0
)
return
-
1
;
if
(
tDecodeI16
(
&
decoder
,
&
pReq
->
hashPrefix
)
<
0
)
return
-
1
;
if
(
tDecodeI16
(
&
decoder
,
&
pReq
->
hashSuffix
)
<
0
)
return
-
1
;
tEndDecode
(
&
decoder
);
tDecoderClear
(
&
decoder
);
...
...
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
浏览文件 @
25c67f6e
...
...
@@ -171,6 +171,8 @@ static void vmGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) {
pCfg
->
hashBegin
=
pCreate
->
hashBegin
;
pCfg
->
hashEnd
=
pCreate
->
hashEnd
;
pCfg
->
hashMethod
=
pCreate
->
hashMethod
;
pCfg
->
hashPrefix
=
pCreate
->
hashPrefix
;
pCfg
->
hashSuffix
=
pCreate
->
hashSuffix
;
pCfg
->
standby
=
pCfg
->
standby
;
pCfg
->
syncCfg
.
myIndex
=
pCreate
->
selfIndex
;
...
...
@@ -220,9 +222,11 @@ int32_t vmProcessCreateVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
return
-
1
;
}
d
Debug
(
"vgId:%d, start to create vnode, tsma:%d standby:%d cacheLast:%d cacheLastSize:%d sstTrigger:%d"
,
d
Info
(
"vgId:%d, start to create vnode, tsma:%d standby:%d cacheLast:%d cacheLastSize:%d sstTrigger:%d"
,
createReq
.
vgId
,
createReq
.
isTsma
,
createReq
.
standby
,
createReq
.
cacheLast
,
createReq
.
cacheLastSize
,
createReq
.
sstTrigger
);
dInfo
(
"vgId:%d, hashMethod:%d begin:%u end:%u prefix:%d surfix:%d"
,
createReq
.
vgId
,
createReq
.
hashMethod
,
createReq
.
hashBegin
,
createReq
.
hashEnd
,
createReq
.
hashPrefix
,
createReq
.
hashSuffix
);
vmGenerateVnodeCfg
(
&
createReq
,
&
vnodeCfg
);
if
(
vmTsmaAdjustDays
(
&
vnodeCfg
,
&
createReq
)
<
0
)
{
...
...
source/dnode/mnode/impl/inc/mndDef.h
浏览文件 @
25c67f6e
...
...
@@ -305,13 +305,15 @@ typedef struct {
int8_t
hashMethod
;
// default is 1
int8_t
cacheLast
;
int8_t
schemaless
;
int16_t
hashPrefix
;
int16_t
hashSuffix
;
int16_t
sstTrigger
;
int32_t
numOfRetensions
;
SArray
*
pRetensions
;
int32_t
walRetentionPeriod
;
int64_t
walRetentionSize
;
int32_t
walRollPeriod
;
int64_t
walRetentionSize
;
int64_t
walSegmentSize
;
int16_t
sstTrigger
;
}
SDbCfg
;
typedef
struct
{
...
...
source/dnode/mnode/impl/src/mndDb.c
浏览文件 @
25c67f6e
...
...
@@ -30,7 +30,7 @@
#include "systable.h"
#define DB_VER_NUMBER 1
#define DB_RESERVE_SIZE
62
#define DB_RESERVE_SIZE
58
static
SSdbRaw
*
mndDbActionEncode
(
SDbObj
*
pDb
);
static
SSdbRow
*
mndDbActionDecode
(
SSdbRaw
*
pRaw
);
...
...
@@ -125,6 +125,8 @@ static SSdbRaw *mndDbActionEncode(SDbObj *pDb) {
SDB_SET_INT32
(
pRaw
,
dataPos
,
pDb
->
cfg
.
walRollPeriod
,
_OVER
)
SDB_SET_INT64
(
pRaw
,
dataPos
,
pDb
->
cfg
.
walSegmentSize
,
_OVER
)
SDB_SET_INT16
(
pRaw
,
dataPos
,
pDb
->
cfg
.
sstTrigger
,
_OVER
)
SDB_SET_INT16
(
pRaw
,
dataPos
,
pDb
->
cfg
.
hashPrefix
,
_OVER
)
SDB_SET_INT16
(
pRaw
,
dataPos
,
pDb
->
cfg
.
hashSuffix
,
_OVER
)
SDB_SET_RESERVE
(
pRaw
,
dataPos
,
DB_RESERVE_SIZE
,
_OVER
)
SDB_SET_DATALEN
(
pRaw
,
dataPos
,
_OVER
)
...
...
@@ -209,6 +211,8 @@ static SSdbRow *mndDbActionDecode(SSdbRaw *pRaw) {
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pDb
->
cfg
.
walRollPeriod
,
_OVER
)
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pDb
->
cfg
.
walSegmentSize
,
_OVER
)
SDB_GET_INT16
(
pRaw
,
dataPos
,
&
pDb
->
cfg
.
sstTrigger
,
_OVER
)
SDB_GET_INT16
(
pRaw
,
dataPos
,
&
pDb
->
cfg
.
hashPrefix
,
_OVER
)
SDB_GET_INT16
(
pRaw
,
dataPos
,
&
pDb
->
cfg
.
hashSuffix
,
_OVER
)
SDB_GET_RESERVE
(
pRaw
,
dataPos
,
DB_RESERVE_SIZE
,
_OVER
)
taosInitRWLatch
(
&
pDb
->
lock
);
...
...
@@ -334,6 +338,8 @@ static int32_t mndCheckDbCfg(SMnode *pMnode, SDbCfg *pCfg) {
if
(
pCfg
->
walRollPeriod
<
TSDB_DB_MIN_WAL_ROLL_PERIOD
)
return
-
1
;
if
(
pCfg
->
walSegmentSize
<
TSDB_DB_MIN_WAL_SEGMENT_SIZE
)
return
-
1
;
if
(
pCfg
->
sstTrigger
<
TSDB_MIN_SST_TRIGGER
||
pCfg
->
sstTrigger
>
TSDB_MAX_SST_TRIGGER
)
return
-
1
;
if
(
pCfg
->
hashPrefix
<
TSDB_MIN_HASH_PREFIX
||
pCfg
->
hashPrefix
>
TSDB_MAX_HASH_PREFIX
)
return
-
1
;
if
(
pCfg
->
hashSuffix
<
TSDB_MIN_HASH_SUFFIX
||
pCfg
->
hashSuffix
>
TSDB_MAX_HASH_SUFFIX
)
return
-
1
;
terrno
=
0
;
return
terrno
;
...
...
@@ -368,6 +374,8 @@ static void mndSetDefaultDbCfg(SDbCfg *pCfg) {
if
(
pCfg
->
walRollPeriod
<
0
)
pCfg
->
walRollPeriod
=
TSDB_REPS_DEF_DB_WAL_ROLL_PERIOD
;
if
(
pCfg
->
walSegmentSize
<
0
)
pCfg
->
walSegmentSize
=
TSDB_DEFAULT_DB_WAL_SEGMENT_SIZE
;
if
(
pCfg
->
sstTrigger
<=
0
)
pCfg
->
sstTrigger
=
TSDB_DEFAULT_SST_TRIGGER
;
if
(
pCfg
->
hashPrefix
<
0
)
pCfg
->
hashPrefix
=
TSDB_DEFAULT_HASH_PREFIX
;
if
(
pCfg
->
hashSuffix
<
0
)
pCfg
->
hashSuffix
=
TSDB_DEFAULT_HASH_SUFFIX
;
}
static
int32_t
mndSetCreateDbRedoLogs
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDbObj
*
pDb
,
SVgObj
*
pVgroups
)
{
...
...
@@ -485,6 +493,8 @@ static int32_t mndCreateDb(SMnode *pMnode, SRpcMsg *pReq, SCreateDbReq *pCreate,
.
walRollPeriod
=
pCreate
->
walRollPeriod
,
.
walSegmentSize
=
pCreate
->
walSegmentSize
,
.
sstTrigger
=
pCreate
->
sstTrigger
,
.
hashPrefix
=
pCreate
->
hashPrefix
,
.
hashSuffix
=
pCreate
->
hashSuffix
,
};
dbObj
.
cfg
.
numOfRetensions
=
pCreate
->
numOfRetensions
;
...
...
source/dnode/mnode/impl/src/mndVgroup.c
浏览文件 @
25c67f6e
...
...
@@ -235,6 +235,8 @@ void *mndBuildCreateVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVg
createReq
.
walRollPeriod
=
pDb
->
cfg
.
walRollPeriod
;
createReq
.
walSegmentSize
=
pDb
->
cfg
.
walSegmentSize
;
createReq
.
sstTrigger
=
pDb
->
cfg
.
sstTrigger
;
createReq
.
hashPrefix
=
pDb
->
cfg
.
hashPrefix
;
createReq
.
hashSuffix
=
pDb
->
cfg
.
hashSuffix
;
for
(
int32_t
v
=
0
;
v
<
pVgroup
->
replica
;
++
v
)
{
SReplica
*
pReplica
=
&
createReq
.
replicas
[
v
];
...
...
source/dnode/vnode/inc/vnode.h
浏览文件 @
25c67f6e
...
...
@@ -288,6 +288,8 @@ struct SVnodeCfg {
uint32_t
hashBegin
;
uint32_t
hashEnd
;
int16_t
sstTrigger
;
int16_t
hashPrefix
;
int16_t
hashSuffix
;
};
typedef
struct
{
...
...
source/dnode/vnode/src/vnd/vnodeCfg.c
浏览文件 @
25c67f6e
...
...
@@ -14,6 +14,7 @@
*/
#include "vnd.h"
#include "tutil.h"
const
SVnodeCfg
vnodeCfgDefault
=
{.
vgId
=
-
1
,
.
dbname
=
""
,
...
...
@@ -110,6 +111,8 @@ int vnodeEncodeConfig(const void *pObj, SJson *pJson) {
if
(
tjsonAddIntegerToObject
(
pJson
,
"hashBegin"
,
pCfg
->
hashBegin
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"hashEnd"
,
pCfg
->
hashEnd
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"hashMethod"
,
pCfg
->
hashMethod
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"hashPrefix"
,
pCfg
->
hashPrefix
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"hashSuffix"
,
pCfg
->
hashSuffix
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"syncCfg.replicaNum"
,
pCfg
->
syncCfg
.
replicaNum
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"syncCfg.myIndex"
,
pCfg
->
syncCfg
.
myIndex
)
<
0
)
return
-
1
;
...
...
@@ -214,6 +217,10 @@ int vnodeDecodeConfig(const SJson *pJson, void *pObj) {
if
(
code
<
0
)
return
-
1
;
tjsonGetNumberValue
(
pJson
,
"hashMethod"
,
pCfg
->
hashMethod
,
code
);
if
(
code
<
0
)
return
-
1
;
tjsonGetNumberValue
(
pJson
,
"hashPrefix"
,
pCfg
->
hashPrefix
,
code
);
if
(
code
<
0
)
return
-
1
;
tjsonGetNumberValue
(
pJson
,
"hashSuffix"
,
pCfg
->
hashSuffix
,
code
);
if
(
code
<
0
)
return
-
1
;
tjsonGetNumberValue
(
pJson
,
"syncCfg.replicaNum"
,
pCfg
->
syncCfg
.
replicaNum
,
code
);
if
(
code
<
0
)
return
-
1
;
...
...
@@ -250,7 +257,8 @@ int vnodeValidateTableHash(SVnode *pVnode, char *tableFName) {
switch
(
pVnode
->
config
.
hashMethod
)
{
default:
hashValue
=
MurmurHash3_32
(
tableFName
,
strlen
(
tableFName
));
hashValue
=
taosGetTbHashVal
(
tableFName
,
strlen
(
tableFName
),
pVnode
->
config
.
hashMethod
,
pVnode
->
config
.
hashPrefix
,
pVnode
->
config
.
hashSuffix
);
break
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录