Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
253a7608
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
253a7608
编写于
3月 15, 2023
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(query): set the correct cached tags list key length, and update some logs.
上级
15cbbd3a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
51 addition
and
42 deletion
+51
-42
source/dnode/mnode/impl/src/mndConsumer.c
source/dnode/mnode/impl/src/mndConsumer.c
+4
-4
source/dnode/vnode/src/meta/metaCache.c
source/dnode/vnode/src/meta/metaCache.c
+46
-37
source/dnode/vnode/src/tq/tqRead.c
source/dnode/vnode/src/tq/tqRead.c
+1
-1
未找到文件。
source/dnode/mnode/impl/src/mndConsumer.c
浏览文件 @
253a7608
...
...
@@ -77,7 +77,7 @@ void mndCleanupConsumer(SMnode *pMnode) {}
bool
mndRebTryStart
()
{
int32_t
old
=
atomic_val_compare_exchange_32
(
&
mqRebInExecCnt
,
0
,
1
);
m
Info
(
"tq timer, rebalance counter old val:%d"
,
old
);
m
Debug
(
"tq timer, rebalance counter old val:%d"
,
old
);
return
old
==
0
;
}
...
...
@@ -253,11 +253,11 @@ static int32_t mndProcessMqTimerMsg(SRpcMsg *pMsg) {
SMqConsumerObj
*
pConsumer
;
void
*
pIter
=
NULL
;
m
Trace
(
"start to process mq timer"
);
m
Debug
(
"start to process mq timer"
);
// rebalance cannot be parallel
if
(
!
mndRebTryStart
())
{
m
Info
(
"mq rebalance already in progress, do nothing"
);
m
Debug
(
"mq rebalance already in progress, do nothing"
);
return
0
;
}
...
...
@@ -356,7 +356,7 @@ static int32_t mndProcessMqTimerMsg(SRpcMsg *pMsg) {
}
else
{
taosHashCleanup
(
pRebMsg
->
rebSubHash
);
rpcFreeCont
(
pRebMsg
);
m
Info
(
"mq rebalance finished, no modification"
);
m
Debug
(
"mq rebalance finished, no modification"
);
mndRebEnd
();
}
return
0
;
...
...
source/dnode/vnode/src/meta/metaCache.c
浏览文件 @
253a7608
...
...
@@ -14,6 +14,7 @@
*/
#include "meta.h"
#define TAG_FILTER_RES_KEY_LEN 32
#define META_CACHE_BASE_BUCKET 1024
#define META_CACHE_STATS_BUCKET 16
...
...
@@ -34,7 +35,6 @@ typedef struct SMetaStbStatsEntry {
typedef
struct
STagFilterResEntry
{
SList
list
;
// the linked list of md5 digest, extracted from the serialized tag query condition
uint32_t
hitTimes
;
// queried times for current super table
uint32_t
accTime
;
}
STagFilterResEntry
;
struct
SMetaCache
{
...
...
@@ -457,24 +457,23 @@ static int checkAllEntriesInCache(const STagFilterResEntry* pEntry, SArray* pInv
int32_t
metaGetCachedTableUidList
(
SMeta
*
pMeta
,
tb_uid_t
suid
,
const
uint8_t
*
pKey
,
int32_t
keyLen
,
SArray
*
pList1
,
bool
*
acquireRes
)
{
int32_t
vgId
=
TD_VID
(
pMeta
->
pVnode
);
// generate the composed key for LRU cache
SLRUCache
*
pCache
=
pMeta
->
pCache
->
sTagFilterResCache
.
pUidResCache
;
SHashObj
*
pTableMap
=
pMeta
->
pCache
->
sTagFilterResCache
.
pTableEntry
;
TdThreadMutex
*
pLock
=
&
pMeta
->
pCache
->
sTagFilterResCache
.
lock
;
uint64_t
buf
[
4
];
*
acquireRes
=
0
;
buf
[
0
]
=
(
uint64_t
)
pTableMap
;
buf
[
1
]
=
suid
;
memcpy
(
&
buf
[
2
],
pKey
,
keyLen
);
uint64_t
key
[
4
];
key
[
0
]
=
(
uint64_t
)
pTableMap
;
key
[
1
]
=
suid
;
memcpy
(
&
key
[
2
],
pKey
,
keyLen
);
taosThreadMutexLock
(
pLock
);
pMeta
->
pCache
->
sTagFilterResCache
.
accTimes
+=
1
;
int32_t
len
=
keyLen
+
sizeof
(
uint64_t
)
*
2
;
LRUHandle
*
pHandle
=
taosLRUCacheLookup
(
pCache
,
buf
,
len
);
LRUHandle
*
pHandle
=
taosLRUCacheLookup
(
pCache
,
key
,
TAG_FILTER_RES_KEY_LEN
);
if
(
pHandle
==
NULL
)
{
taosThreadMutexUnlock
(
pLock
);
return
TSDB_CODE_SUCCESS
;
...
...
@@ -499,7 +498,7 @@ int32_t metaGetCachedTableUidList(SMeta* pMeta, tb_uid_t suid, const uint8_t* pK
uint32_t
acc
=
pMeta
->
pCache
->
sTagFilterResCache
.
accTimes
;
if
((
*
pEntry
)
->
hitTimes
%
5000
==
0
&&
(
*
pEntry
)
->
hitTimes
>
0
)
{
metaInfo
(
"
cache hit:%d, total acc:%d, rate:%.2f"
,
(
*
pEntry
)
->
hitTimes
,
acc
,
((
double
)(
*
pEntry
)
->
hitTimes
)
/
acc
);
metaInfo
(
"
vgId:%d cache hit:%d, total acc:%d, rate:%.2f"
,
vgId
,
(
*
pEntry
)
->
hitTimes
,
acc
,
((
double
)(
*
pEntry
)
->
hitTimes
)
/
acc
);
}
taosLRUCacheRelease
(
pCache
,
pHandle
,
false
);
...
...
@@ -560,13 +559,30 @@ static int32_t addNewEntry(SHashObj* pTableEntry, const void* pKey, int32_t keyL
return
0
;
}
static
FORCE_INLINE
void
setMD5DigestInKey
(
uint64_t
*
pBuf
,
const
char
*
key
,
int32_t
keyLen
)
{
// ASSERT(keyLen == sizeof(int64_t) * 2);
memcpy
(
&
pBuf
[
2
],
key
,
keyLen
);
}
// the format of key:
// hash table address(8bytes) + suid(8bytes) + MD5 digest(16bytes)
static
void
initCacheKey
(
uint64_t
*
buf
,
const
SHashObj
*
pHashMap
,
uint64_t
suid
,
const
char
*
key
,
int32_t
keyLen
)
{
buf
[
0
]
=
(
uint64_t
)
pHashMap
;
buf
[
1
]
=
suid
;
setMD5DigestInKey
(
buf
,
key
,
keyLen
);
ASSERT
(
keyLen
==
sizeof
(
uint64_t
)
*
2
);
}
// check both the payload size and selectivity ratio
int32_t
metaUidFilterCachePut
(
SMeta
*
pMeta
,
uint64_t
suid
,
const
void
*
pKey
,
int32_t
keyLen
,
void
*
pPayload
,
int32_t
payloadLen
,
double
selectivityRatio
)
{
int32_t
code
=
0
;
int32_t
vgId
=
TD_VID
(
pMeta
->
pVnode
);
if
(
selectivityRatio
>
tsSelectivityRatio
)
{
metaDebug
(
"vgId:%d, suid:%"
PRIu64
" failed to add to uid list cache, due to selectivity ratio %.2f less than threshold %.2f"
,
TD_VID
(
pMeta
->
pVnode
)
,
suid
,
selectivityRatio
,
tsSelectivityRatio
);
vgId
,
suid
,
selectivityRatio
,
tsSelectivityRatio
);
taosMemoryFree
(
pPayload
);
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -574,7 +590,7 @@ int32_t metaUidFilterCachePut(SMeta* pMeta, uint64_t suid, const void* pKey, int
if
(
payloadLen
>
tsTagFilterResCacheSize
)
{
metaDebug
(
"vgId:%d, suid:%"
PRIu64
" failed to add to uid list cache, due to payload length %d greater than threshold %d"
,
TD_VID
(
pMeta
->
pVnode
)
,
suid
,
payloadLen
,
tsTagFilterResCacheSize
);
vgId
,
suid
,
payloadLen
,
tsTagFilterResCacheSize
);
taosMemoryFree
(
pPayload
);
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -583,26 +599,17 @@ int32_t metaUidFilterCachePut(SMeta* pMeta, uint64_t suid, const void* pKey, int
SHashObj
*
pTableEntry
=
pMeta
->
pCache
->
sTagFilterResCache
.
pTableEntry
;
TdThreadMutex
*
pLock
=
&
pMeta
->
pCache
->
sTagFilterResCache
.
lock
;
// the format of key:
// hash table address(8bytes) + suid(8bytes) + MD5 digest(16bytes)
uint64_t
buf
[
4
]
=
{
0
};
buf
[
0
]
=
(
uint64_t
)
pTableEntry
;
buf
[
1
]
=
suid
;
memcpy
(
&
buf
[
2
],
pKey
,
keyLen
);
ASSERT
(
keyLen
==
16
);
uint64_t
key
[
4
]
=
{
0
};
initCacheKey
(
key
,
pTableEntry
,
suid
,
pKey
,
keyLen
);
int32_t
code
=
0
;
taosThreadMutexLock
(
pLock
);
STagFilterResEntry
**
pEntry
=
taosHashGet
(
pTableEntry
,
&
suid
,
sizeof
(
uint64_t
));
if
(
pEntry
==
NULL
)
{
code
=
addNewEntry
(
pTableEntry
,
pKey
,
keyLen
,
suid
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_end
;
}
}
else
{
// check if it exists or not
}
else
{
// check if it exists or not
size_t
size
=
listNEles
(
&
(
*
pEntry
)
->
list
);
if
(
size
==
0
)
{
tdListAppend
(
&
(
*
pEntry
)
->
list
,
pKey
);
...
...
@@ -620,12 +627,11 @@ int32_t metaUidFilterCachePut(SMeta* pMeta, uint64_t suid, const void* pKey, int
}
// add to cache.
taosLRUCacheInsert
(
pCache
,
buf
,
sizeof
(
uint64_t
)
*
2
+
keyLen
,
pPayload
,
payloadLen
,
freePayload
,
NULL
,
taosLRUCacheInsert
(
pCache
,
key
,
TAG_FILTER_RES_KEY_LEN
,
pPayload
,
payloadLen
,
freePayload
,
NULL
,
TAOS_LRU_PRIORITY_LOW
);
_end:
taosThreadMutexUnlock
(
pLock
);
metaDebug
(
"vgId:%d, suid:%"
PRIu64
" list cache added into cache, total:%d, tables:%d"
,
TD_VID
(
pMeta
->
pVnode
),
suid
,
metaDebug
(
"vgId:%d, suid:%"
PRIu64
" list cache added into cache, total:%d, tables:%d"
,
vgId
,
suid
,
(
int32_t
)
taosLRUCacheGetUsage
(
pCache
),
taosHashGetSize
(
pTableEntry
));
return
code
;
...
...
@@ -633,33 +639,36 @@ _end:
// remove the lru cache that are expired due to the tags value update, or creating, or dropping, of child tables
int32_t
metaUidCacheClear
(
SMeta
*
pMeta
,
uint64_t
suid
)
{
int32_t
keyLen
=
sizeof
(
uint64_t
)
*
3
;
uint64_t
p
[
4
]
=
{
0
};
uint64_t
p
[
4
]
=
{
0
};
int32_t
vgId
=
TD_VID
(
pMeta
->
pVnode
);
SHashObj
*
pEntryHashMap
=
pMeta
->
pCache
->
sTagFilterResCache
.
pTableEntry
;
p
[
0
]
=
(
uint64_t
)
pMeta
->
pCache
->
sTagFilterResCache
.
pTableEntry
;
p
[
1
]
=
suid
;
uint64_t
dummy
[
2
]
=
{
0
}
;
initCacheKey
(
p
,
pEntryHashMap
,
suid
,
(
char
*
)
&
dummy
[
0
],
16
)
;
TdThreadMutex
*
pLock
=
&
pMeta
->
pCache
->
sTagFilterResCache
.
lock
;
taosThreadMutexLock
(
pLock
);
STagFilterResEntry
**
pEntry
=
taosHashGet
(
pMeta
->
pCache
->
sTagFilterResCache
.
pTableEntry
,
&
suid
,
sizeof
(
uint64_t
));
STagFilterResEntry
**
pEntry
=
taosHashGet
(
pEntryHashMap
,
&
suid
,
sizeof
(
uint64_t
));
if
(
pEntry
==
NULL
||
listNEles
(
&
(
*
pEntry
)
->
list
)
==
0
)
{
taosThreadMutexUnlock
(
pLock
);
return
TSDB_CODE_SUCCESS
;
}
(
*
pEntry
)
->
hitTimes
=
0
;
SListIter
iter
=
{
0
};
tdListInitIter
(
&
(
*
pEntry
)
->
list
,
&
iter
,
TD_LIST_FORWARD
);
SListNode
*
pNode
=
NULL
;
while
((
pNode
=
tdListNext
(
&
iter
))
!=
NULL
)
{
memcpy
(
&
p
[
2
],
pNode
->
data
,
16
);
taosLRUCacheErase
(
pMeta
->
pCache
->
sTagFilterResCache
.
pUidResCache
,
p
,
keyLen
);
setMD5DigestInKey
(
p
,
pNode
->
data
,
2
*
sizeof
(
uint64_t
)
);
taosLRUCacheErase
(
pMeta
->
pCache
->
sTagFilterResCache
.
pUidResCache
,
p
,
TAG_FILTER_RES_KEY_LEN
);
}
(
*
pEntry
)
->
hitTimes
=
0
;
tdListEmpty
(
&
(
*
pEntry
)
->
list
);
taosThreadMutexUnlock
(
pLock
);
metaDebug
(
"vgId:%d suid:%"
PRId64
" cached related tag filter uid list cleared"
,
vgId
,
suid
);
return
TSDB_CODE_SUCCESS
;
}
source/dnode/vnode/src/tq/tqRead.c
浏览文件 @
253a7608
...
...
@@ -296,7 +296,7 @@ int32_t tqSeekVer(STqReader* pReader, int64_t ver, const char* id) {
// todo set the correct vgId
tqDebug
(
"tmq poll: wal seek to version:%"
PRId64
" %s"
,
ver
,
id
);
if
(
walReadSeekVer
(
pReader
->
pWalReader
,
ver
)
<
0
)
{
tq
Error
(
"tmq poll: wal reader failed to seek to ver:%"
PRId64
" code:%s, %s"
,
ver
,
tstrerror
(
terrno
),
id
);
tq
Debug
(
"tmq poll: wal reader failed to seek to ver:%"
PRId64
" code:%s, %s"
,
ver
,
tstrerror
(
terrno
),
id
);
return
-
1
;
}
else
{
tqDebug
(
"tmq poll: wal reader seek to ver:%"
PRId64
" %s"
,
ver
,
id
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录