Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
1a2983c0
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
1a2983c0
编写于
11月 24, 2022
作者:
M
Minglei Jin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(tdb): zero pOlds[i]'s nOverflow and assert it's zero when committing
上级
01e8b03b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
19 addition
and
19 deletion
+19
-19
source/libs/tdb/src/db/tdbBtree.c
source/libs/tdb/src/db/tdbBtree.c
+2
-4
source/libs/tdb/src/db/tdbPager.c
source/libs/tdb/src/db/tdbPager.c
+17
-15
未找到文件。
source/libs/tdb/src/db/tdbBtree.c
浏览文件 @
1a2983c0
...
@@ -741,14 +741,12 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx, TXN *pTx
...
@@ -741,14 +741,12 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx, TXN *pTx
tdbPageCreate
(
pOlds
[
0
]
->
pageSize
,
&
pOldsCopy
[
i
],
tdbDefaultMalloc
,
NULL
);
tdbPageCreate
(
pOlds
[
0
]
->
pageSize
,
&
pOldsCopy
[
i
],
tdbDefaultMalloc
,
NULL
);
tdbBtreeInitPage
(
pOldsCopy
[
i
],
&
iarg
,
0
);
tdbBtreeInitPage
(
pOldsCopy
[
i
],
&
iarg
,
0
);
tdbPageCopy
(
pOlds
[
i
],
pOldsCopy
[
i
],
0
);
tdbPageCopy
(
pOlds
[
i
],
pOldsCopy
[
i
],
0
);
}
pOlds
[
i
]
->
nOverflow
=
0
;
for
(
iNew
=
0
;
iNew
<
nNews
;
++
iNew
)
{
tdbBtreeInitPage
(
pNews
[
iNew
],
&
iarg
,
0
);
}
}
iNew
=
0
;
iNew
=
0
;
nNewCells
=
0
;
nNewCells
=
0
;
tdbBtreeInitPage
(
pNews
[
iNew
],
&
iarg
,
0
);
for
(
int
iOld
=
0
;
iOld
<
nOlds
;
iOld
++
)
{
for
(
int
iOld
=
0
;
iOld
<
nOlds
;
iOld
++
)
{
SPage
*
pPage
;
SPage
*
pPage
;
...
...
source/libs/tdb/src/db/tdbPager.c
浏览文件 @
1a2983c0
...
@@ -28,12 +28,12 @@ typedef struct {
...
@@ -28,12 +28,12 @@ typedef struct {
TDB_STATIC_ASSERT
(
sizeof
(
SFileHdr
)
==
128
,
"Size of file header is not correct"
);
TDB_STATIC_ASSERT
(
sizeof
(
SFileHdr
)
==
128
,
"Size of file header is not correct"
);
struct
hashset_st
{
struct
hashset_st
{
size_t
nbits
;
size_t
nbits
;
size_t
mask
;
size_t
mask
;
size_t
capacity
;
size_t
capacity
;
size_t
*
items
;
size_t
*
items
;
size_t
nitems
;
size_t
nitems
;
double
load_factor
;
double
load_factor
;
};
};
static
const
unsigned
int
prime
=
39
;
static
const
unsigned
int
prime
=
39
;
...
@@ -68,11 +68,11 @@ void hashset_destroy(hashset_t set) {
...
@@ -68,11 +68,11 @@ void hashset_destroy(hashset_t set) {
}
}
int
hashset_add_member
(
hashset_t
set
,
void
*
item
)
{
int
hashset_add_member
(
hashset_t
set
,
void
*
item
)
{
size_t
value
=
(
size_t
)
item
;
size_t
value
=
(
size_t
)
item
;
size_t
h
;
size_t
h
;
if
(
value
==
0
)
{
if
(
value
==
0
)
{
return
-
1
;
return
-
1
;
}
}
for
(
h
=
set
->
mask
&
(
prime
*
value
);
set
->
items
[
h
]
!=
0
;
h
=
set
->
mask
&
(
h
+
prime2
))
{
for
(
h
=
set
->
mask
&
(
prime
*
value
);
set
->
items
[
h
]
!=
0
;
h
=
set
->
mask
&
(
h
+
prime2
))
{
...
@@ -103,7 +103,7 @@ int hashset_add(hashset_t set, void *item) {
...
@@ -103,7 +103,7 @@ int hashset_add(hashset_t set, void *item) {
set
->
nitems
=
0
;
set
->
nitems
=
0
;
for
(
size_t
i
=
0
;
i
<
old_capacity
;
++
i
)
{
for
(
size_t
i
=
0
;
i
<
old_capacity
;
++
i
)
{
hashset_add_member
(
set
,
(
void
*
)
old_items
[
i
]);
hashset_add_member
(
set
,
(
void
*
)
old_items
[
i
]);
}
}
tdbOsFree
(
old_items
);
tdbOsFree
(
old_items
);
}
}
...
@@ -112,7 +112,7 @@ int hashset_add(hashset_t set, void *item) {
...
@@ -112,7 +112,7 @@ int hashset_add(hashset_t set, void *item) {
}
}
int
hashset_remove
(
hashset_t
set
,
void
*
item
)
{
int
hashset_remove
(
hashset_t
set
,
void
*
item
)
{
size_t
value
=
(
size_t
)
item
;
size_t
value
=
(
size_t
)
item
;
for
(
size_t
h
=
set
->
mask
&
(
prime
*
value
);
set
->
items
[
h
]
!=
0
;
h
=
set
->
mask
&
(
h
+
prime2
))
{
for
(
size_t
h
=
set
->
mask
&
(
prime
*
value
);
set
->
items
[
h
]
!=
0
;
h
=
set
->
mask
&
(
h
+
prime2
))
{
if
(
set
->
items
[
h
]
==
value
)
{
if
(
set
->
items
[
h
]
==
value
)
{
...
@@ -126,7 +126,7 @@ int hashset_remove(hashset_t set, void *item) {
...
@@ -126,7 +126,7 @@ int hashset_remove(hashset_t set, void *item) {
}
}
int
hashset_contains
(
hashset_t
set
,
void
*
item
)
{
int
hashset_contains
(
hashset_t
set
,
void
*
item
)
{
size_t
value
=
(
size_t
)
item
;
size_t
value
=
(
size_t
)
item
;
for
(
size_t
h
=
set
->
mask
&
(
prime
*
value
);
set
->
items
[
h
]
!=
0
;
h
=
set
->
mask
&
(
h
+
prime2
))
{
for
(
size_t
h
=
set
->
mask
&
(
prime
*
value
);
set
->
items
[
h
]
!=
0
;
h
=
set
->
mask
&
(
h
+
prime2
))
{
if
(
set
->
items
[
h
]
==
value
)
{
if
(
set
->
items
[
h
]
==
value
)
{
...
@@ -319,7 +319,8 @@ int tdbPagerWrite(SPager *pPager, SPage *pPage) {
...
@@ -319,7 +319,8 @@ int tdbPagerWrite(SPager *pPager, SPage *pPage) {
tRBTreePut
(
&
pPager
->
rbt
,
(
SRBTreeNode
*
)
pPage
);
tRBTreePut
(
&
pPager
->
rbt
,
(
SRBTreeNode
*
)
pPage
);
// Write page to journal if neccessary
// Write page to journal if neccessary
if
(
TDB_PAGE_PGNO
(
pPage
)
<=
pPager
->
dbOrigSize
&&
(
pPager
->
jPageSet
==
NULL
||
!
hashset_contains
(
pPager
->
jPageSet
,
(
void
*
)((
long
)
TDB_PAGE_PGNO
(
pPage
)))))
{
if
(
TDB_PAGE_PGNO
(
pPage
)
<=
pPager
->
dbOrigSize
&&
(
pPager
->
jPageSet
==
NULL
||
!
hashset_contains
(
pPager
->
jPageSet
,
(
void
*
)((
long
)
TDB_PAGE_PGNO
(
pPage
)))))
{
ret
=
tdbPagerWritePageToJournal
(
pPager
,
pPage
);
ret
=
tdbPagerWritePageToJournal
(
pPager
,
pPage
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
tdbError
(
"failed to write page to journal since %s"
,
tstrerror
(
terrno
));
tdbError
(
"failed to write page to journal since %s"
,
tstrerror
(
terrno
));
...
@@ -327,7 +328,7 @@ int tdbPagerWrite(SPager *pPager, SPage *pPage) {
...
@@ -327,7 +328,7 @@ int tdbPagerWrite(SPager *pPager, SPage *pPage) {
}
}
if
(
pPager
->
jPageSet
)
{
if
(
pPager
->
jPageSet
)
{
hashset_add
(
pPager
->
jPageSet
,
(
void
*
)((
long
)
TDB_PAGE_PGNO
(
pPage
)));
hashset_add
(
pPager
->
jPageSet
,
(
void
*
)((
long
)
TDB_PAGE_PGNO
(
pPage
)));
}
}
}
}
...
@@ -372,6 +373,7 @@ int tdbPagerCommit(SPager *pPager, TXN *pTxn) {
...
@@ -372,6 +373,7 @@ int tdbPagerCommit(SPager *pPager, TXN *pTxn) {
SRBTreeNode
*
pNode
=
NULL
;
SRBTreeNode
*
pNode
=
NULL
;
while
((
pNode
=
tRBTreeIterNext
(
&
iter
))
!=
NULL
)
{
while
((
pNode
=
tRBTreeIterNext
(
&
iter
))
!=
NULL
)
{
pPage
=
(
SPage
*
)
pNode
;
pPage
=
(
SPage
*
)
pNode
;
ASSERT
(
pPage
->
nOverflow
==
0
);
ret
=
tdbPagerWritePageToDB
(
pPager
,
pPage
);
ret
=
tdbPagerWritePageToDB
(
pPager
,
pPage
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
tdbError
(
"failed to write page to db since %s"
,
tstrerror
(
terrno
));
tdbError
(
"failed to write page to db since %s"
,
tstrerror
(
terrno
));
...
@@ -391,7 +393,7 @@ int tdbPagerCommit(SPager *pPager, TXN *pTxn) {
...
@@ -391,7 +393,7 @@ int tdbPagerCommit(SPager *pPager, TXN *pTxn) {
tRBTreeDrop
(
&
pPager
->
rbt
,
(
SRBTreeNode
*
)
pPage
);
tRBTreeDrop
(
&
pPager
->
rbt
,
(
SRBTreeNode
*
)
pPage
);
if
(
pPager
->
jPageSet
)
{
if
(
pPager
->
jPageSet
)
{
hashset_remove
(
pPager
->
jPageSet
,
(
void
*
)((
long
)
TDB_PAGE_PGNO
(
pPage
)));
hashset_remove
(
pPager
->
jPageSet
,
(
void
*
)((
long
)
TDB_PAGE_PGNO
(
pPage
)));
}
}
tdbPCacheRelease
(
pPager
->
pCache
,
pPage
,
pTxn
);
tdbPCacheRelease
(
pPager
->
pCache
,
pPage
,
pTxn
);
}
}
...
@@ -503,7 +505,7 @@ int tdbPagerAbort(SPager *pPager, TXN *pTxn) {
...
@@ -503,7 +505,7 @@ int tdbPagerAbort(SPager *pPager, TXN *pTxn) {
return
-
1
;
return
-
1
;
}
}
u8
*
pageBuf
=
tdbOsCalloc
(
1
,
pPager
->
pageSize
);
u8
*
pageBuf
=
tdbOsCalloc
(
1
,
pPager
->
pageSize
);
if
(
pageBuf
==
NULL
)
{
if
(
pageBuf
==
NULL
)
{
return
-
1
;
return
-
1
;
}
}
...
@@ -560,7 +562,7 @@ int tdbPagerAbort(SPager *pPager, TXN *pTxn) {
...
@@ -560,7 +562,7 @@ int tdbPagerAbort(SPager *pPager, TXN *pTxn) {
pPage
->
isDirty
=
0
;
pPage
->
isDirty
=
0
;
tRBTreeDrop
(
&
pPager
->
rbt
,
(
SRBTreeNode
*
)
pPage
);
tRBTreeDrop
(
&
pPager
->
rbt
,
(
SRBTreeNode
*
)
pPage
);
hashset_remove
(
pPager
->
jPageSet
,
(
void
*
)((
long
)
TDB_PAGE_PGNO
(
pPage
)));
hashset_remove
(
pPager
->
jPageSet
,
(
void
*
)((
long
)
TDB_PAGE_PGNO
(
pPage
)));
tdbPCacheRelease
(
pPager
->
pCache
,
pPage
,
pTxn
);
tdbPCacheRelease
(
pPager
->
pCache
,
pPage
,
pTxn
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录