Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
7e14593d
G
Gpdb
项目概览
Greenplum
/
Gpdb
通知
7
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
Gpdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
7e14593d
编写于
5月 23, 1999
作者:
V
Vadim B. Mikheev
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix tuple chain moving bug found by "Hiroshi Inoue" <Inoue@tpf.co.jp>.
上级
b14c99d8
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
105 addition
and
17 deletion
+105
-17
src/backend/commands/vacuum.c
src/backend/commands/vacuum.c
+105
-17
未找到文件。
src/backend/commands/vacuum.c
浏览文件 @
7e14593d
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.10
2 1999/05/10 00:44:59 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.10
3 1999/05/23 09:10:24 vadim
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -87,7 +87,7 @@ static void vc_scanheap(VRelStats *vacrelstats, Relation onerel, VPageList vacuu
static
void
vc_rpfheap
(
VRelStats
*
vacrelstats
,
Relation
onerel
,
VPageList
vacuum_pages
,
VPageList
fraged_pages
,
int
nindices
,
Relation
*
Irel
);
static
void
vc_vacheap
(
VRelStats
*
vacrelstats
,
Relation
onerel
,
VPageList
vpl
);
static
void
vc_vacpage
(
Page
page
,
VPageDescr
vpd
);
static
void
vc_vaconeind
(
VPageList
vpl
,
Relation
indrel
,
int
num_tuples
);
static
void
vc_vaconeind
(
VPageList
vpl
,
Relation
indrel
,
int
num_tuples
,
int
keep_tuples
);
static
void
vc_scanoneind
(
Relation
indrel
,
int
num_tuples
);
static
void
vc_attrstats
(
Relation
onerel
,
VRelStats
*
vacrelstats
,
HeapTuple
tuple
);
static
void
vc_bucketcpy
(
Form_pg_attribute
attr
,
Datum
value
,
Datum
*
bucket
,
int16
*
bucket_len
);
...
...
@@ -541,7 +541,7 @@ vc_vacone(Oid relid, bool analyze, List *va_cols)
if
(
vacuum_pages
.
vpl_num_pages
>
0
)
{
for
(
i
=
0
;
i
<
nindices
;
i
++
)
vc_vaconeind
(
&
vacuum_pages
,
Irel
[
i
],
vacrelstats
->
num_tuples
);
vc_vaconeind
(
&
vacuum_pages
,
Irel
[
i
],
vacrelstats
->
num_tuples
,
0
);
}
else
/* just scan indices to update statistic */
...
...
@@ -1042,9 +1042,11 @@ vc_rpfheap(VRelStats *vacrelstats, Relation onerel,
num_fraged_pages
,
vacuumed_pages
;
int
checked_moved
,
num_tuples
;
num_tuples
,
keep_tuples
=
0
;
bool
isempty
,
dowrite
;
dowrite
,
chain_tuple_moved
;
struct
rusage
ru0
,
ru1
;
...
...
@@ -1126,6 +1128,7 @@ vc_rpfheap(VRelStats *vacrelstats, Relation onerel,
else
Assert
(
!
isempty
);
chain_tuple_moved
=
false
;
/* no one chain-tuple was moved off this page, yet */
vpc
->
vpd_blkno
=
blkno
;
maxoff
=
PageGetMaxOffsetNumber
(
page
);
for
(
offnum
=
FirstOffsetNumber
;
...
...
@@ -1145,11 +1148,39 @@ vc_rpfheap(VRelStats *vacrelstats, Relation onerel,
{
if
((
TransactionId
)
tuple
.
t_data
->
t_cmin
!=
myXID
)
elog
(
ERROR
,
"Invalid XID in t_cmin"
);
if
(
tuple
.
t_data
->
t_infomask
&
HEAP_MOVED_OFF
)
continue
;
/* already removed by me */
if
(
tuple
.
t_data
->
t_infomask
&
HEAP_MOVED_IN
)
break
;
elog
(
ERROR
,
"HEAP_MOVED_OFF/HEAP_MOVED_IN was expected"
);
elog
(
ERROR
,
"HEAP_MOVED_IN was not expected"
);
/*
* If this (chain) tuple is moved by me already then
* I have to check is it in vpc or not - i.e. is it
* moved while cleaning this page or some previous one.
*/
if
(
tuple
.
t_data
->
t_infomask
&
HEAP_MOVED_OFF
)
{
if
(
keep_tuples
==
0
)
continue
;
if
(
chain_tuple_moved
)
/* some chains was moved while */
{
/* cleaning this page */
Assert
(
vpc
->
vpd_offsets_free
>
0
);
for
(
i
=
0
;
i
<
vpc
->
vpd_offsets_free
;
i
++
)
{
if
(
vpc
->
vpd_offsets
[
i
]
==
offnum
)
break
;
}
if
(
i
>=
vpc
->
vpd_offsets_free
)
/* not found */
{
vpc
->
vpd_offsets
[
vpc
->
vpd_offsets_free
++
]
=
offnum
;
keep_tuples
--
;
}
}
else
{
vpc
->
vpd_offsets
[
vpc
->
vpd_offsets_free
++
]
=
offnum
;
keep_tuples
--
;
}
continue
;
}
elog
(
ERROR
,
"HEAP_MOVED_OFF was expected"
);
}
/*
...
...
@@ -1386,9 +1417,15 @@ moving chain: failed to add item with len = %u to page %u",
tuple
.
t_data
->
t_infomask
|=
HEAP_MOVED_OFF
;
num_moved
++
;
/*
* Remember that we moved tuple from the current page
* (corresponding index tuple will be cleaned).
*/
if
(
Cbuf
==
buf
)
vpc
->
vpd_offsets
[
vpc
->
vpd_offsets_free
++
]
=
ItemPointerGetOffsetNumber
(
&
(
tuple
.
t_self
));
else
keep_tuples
++
;
if
(
Irel
!=
(
Relation
*
)
NULL
)
{
...
...
@@ -1418,6 +1455,7 @@ moving chain: failed to add item with len = %u to page %u",
}
cur_buffer
=
InvalidBuffer
;
pfree
(
vtmove
);
chain_tuple_moved
=
true
;
continue
;
}
...
...
@@ -1532,10 +1570,58 @@ failed to add item with len = %u to page %u (free space %u, nusd %u, noff %u)",
}
/* walk along page */
if
(
offnum
<
maxoff
&&
keep_tuples
>
0
)
{
OffsetNumber
off
;
for
(
off
=
OffsetNumberNext
(
offnum
);
off
<=
maxoff
;
off
=
OffsetNumberNext
(
off
))
{
itemid
=
PageGetItemId
(
page
,
off
);
if
(
!
ItemIdIsUsed
(
itemid
))
continue
;
tuple
.
t_data
=
(
HeapTupleHeader
)
PageGetItem
(
page
,
itemid
);
if
(
tuple
.
t_data
->
t_infomask
&
HEAP_XMIN_COMMITTED
)
continue
;
if
((
TransactionId
)
tuple
.
t_data
->
t_cmin
!=
myXID
)
elog
(
ERROR
,
"Invalid XID in t_cmin (4)"
);
if
(
tuple
.
t_data
->
t_infomask
&
HEAP_MOVED_IN
)
elog
(
ERROR
,
"HEAP_MOVED_IN was not expected (2)"
);
if
(
tuple
.
t_data
->
t_infomask
&
HEAP_MOVED_OFF
)
{
if
(
chain_tuple_moved
)
/* some chains was moved while */
{
/* cleaning this page */
Assert
(
vpc
->
vpd_offsets_free
>
0
);
for
(
i
=
0
;
i
<
vpc
->
vpd_offsets_free
;
i
++
)
{
if
(
vpc
->
vpd_offsets
[
i
]
==
off
)
break
;
}
if
(
i
>=
vpc
->
vpd_offsets_free
)
/* not found */
{
vpc
->
vpd_offsets
[
vpc
->
vpd_offsets_free
++
]
=
off
;
Assert
(
keep_tuples
>
0
);
keep_tuples
--
;
}
}
else
{
vpc
->
vpd_offsets
[
vpc
->
vpd_offsets_free
++
]
=
off
;
Assert
(
keep_tuples
>
0
);
keep_tuples
--
;
}
}
}
}
if
(
vpc
->
vpd_offsets_free
>
0
)
/* some tuples were moved */
{
qsort
((
char
*
)
(
vpc
->
vpd_offsets
),
vpc
->
vpd_offsets_free
,
if
(
chain_tuple_moved
)
/* else - they are ordered */
{
qsort
((
char
*
)
(
vpc
->
vpd_offsets
),
vpc
->
vpd_offsets_free
,
sizeof
(
OffsetNumber
),
vc_cmp_offno
);
}
vc_reappage
(
&
Nvpl
,
vpc
);
WriteBuffer
(
buf
);
}
...
...
@@ -1559,7 +1645,6 @@ failed to add item with len = %u to page %u (free space %u, nusd %u, noff %u)",
if
(
num_moved
>
0
)
{
/*
* We have to commit our tuple' movings before we'll truncate
* relation, but we shouldn't lose our locks. And so - quick hack:
...
...
@@ -1610,7 +1695,7 @@ failed to add item with len = %u to page %u (free space %u, nusd %u, noff %u)",
else
if
(
tuple
.
t_data
->
t_infomask
&
HEAP_MOVED_OFF
)
tuple
.
t_data
->
t_infomask
|=
HEAP_XMIN_INVALID
;
else
elog
(
ERROR
,
"HEAP_MOVED_OFF/HEAP_MOVED_IN was expected
(2)
"
);
elog
(
ERROR
,
"HEAP_MOVED_OFF/HEAP_MOVED_IN was expected"
);
}
}
Assert
((
*
vpp
)
->
vpd_offsets_used
==
num_tuples
);
...
...
@@ -1647,8 +1732,10 @@ Elapsed %u/%u sec.",
*
vpleft
=
*
vpright
;
*
vpright
=
vpsave
;
}
Assert
(
keep_tuples
>=
0
);
for
(
i
=
0
;
i
<
nindices
;
i
++
)
vc_vaconeind
(
&
Nvpl
,
Irel
[
i
],
vacrelstats
->
num_tuples
);
vc_vaconeind
(
&
Nvpl
,
Irel
[
i
],
vacrelstats
->
num_tuples
,
keep_tuples
);
}
/*
...
...
@@ -1678,7 +1765,7 @@ Elapsed %u/%u sec.",
num_tuples
++
;
}
else
elog
(
ERROR
,
"HEAP_MOVED_OFF was expected"
);
elog
(
ERROR
,
"HEAP_MOVED_OFF was expected
(2)
"
);
}
}
...
...
@@ -1854,7 +1941,7 @@ vc_scanoneind(Relation indrel, int num_tuples)
* pg_class.
*/
static
void
vc_vaconeind
(
VPageList
vpl
,
Relation
indrel
,
int
num_tuples
)
vc_vaconeind
(
VPageList
vpl
,
Relation
indrel
,
int
num_tuples
,
int
keep_tuples
)
{
RetrieveIndexResult
res
;
IndexScanDesc
iscan
;
...
...
@@ -1911,11 +1998,12 @@ vc_vaconeind(VPageList vpl, Relation indrel, int num_tuples)
getrusage
(
RUSAGE_SELF
,
&
ru1
);
elog
(
MESSAGE_LEVEL
,
"Index %s: Pages %u; Tuples %u: Deleted %u. Elapsed %u/%u sec."
,
indrel
->
rd_rel
->
relname
.
data
,
num_pages
,
num_index_tuples
,
tups_vacuumed
,
indrel
->
rd_rel
->
relname
.
data
,
num_pages
,
num_index_tuples
-
keep_tuples
,
tups_vacuumed
,
ru1
.
ru_stime
.
tv_sec
-
ru0
.
ru_stime
.
tv_sec
,
ru1
.
ru_utime
.
tv_sec
-
ru0
.
ru_utime
.
tv_sec
);
if
(
num_index_tuples
!=
num_tuples
)
if
(
num_index_tuples
!=
num_tuples
+
keep_tuples
)
elog
(
NOTICE
,
"Index %s: NUMBER OF INDEX' TUPLES (%u) IS NOT THE SAME AS HEAP' (%u)"
,
indrel
->
rd_rel
->
relname
.
data
,
num_index_tuples
,
num_tuples
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录