Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2f8c2e9

Browse files
committed
Fix deleted tuples re-incarnation possible when vacuum transaction
start time equal to tuple->t_tmax.Privent shrinking if there are tuples modifyed by running transactions(it concerns system relations only, currently).
1 parent234776d commit2f8c2e9

File tree

1 file changed

+26
-38
lines changed

1 file changed

+26
-38
lines changed

‎src/backend/commands/vacuum.c

Lines changed: 26 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.32 1997/05/05 10:01:02 vadim Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.33 1997/06/0301:29:26 vadim Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -627,8 +627,6 @@ vc_scanheap (VRelStats *vacrelstats, Relation onerel,
627627
Pagepage,tempPage=NULL;
628628
OffsetNumberoffnum,maxoff;
629629
boolpgchanged,tupgone,dobufrel,notup;
630-
AbsoluteTimepurgetime,expiretime;
631-
RelativeTimepreservetime;
632630
char*relname;
633631
VPageDescrvpc,vp;
634632
uint32nvac,ntups,nunused,ncrash,nempg,nnepg,nchpg,nemend;
@@ -637,6 +635,7 @@ vc_scanheap (VRelStats *vacrelstats, Relation onerel,
637635
Sizemax_tlen=0;
638636
int32i/*, attr_cnt*/;
639637
structrusageru0,ru1;
638+
booldo_shrinking= true;
640639

641640
getrusage(RUSAGE_SELF,&ru0);
642641

@@ -647,22 +646,6 @@ vc_scanheap (VRelStats *vacrelstats, Relation onerel,
647646

648647
nblocks=RelationGetNumberOfBlocks(onerel);
649648

650-
/* calculate the purge time: tuples that expired before this time
651-
will be archived or deleted */
652-
purgetime=GetCurrentTransactionStartTime();
653-
expiretime= (AbsoluteTime)onerel->rd_rel->relexpires;
654-
preservetime= (RelativeTime)onerel->rd_rel->relpreserved;
655-
656-
if (RelativeTimeIsValid(preservetime)&& (preservetime)) {
657-
purgetime-=preservetime;
658-
if (AbsoluteTimeIsBackwardCompatiblyValid(expiretime)&&
659-
expiretime>purgetime)
660-
purgetime=expiretime;
661-
}
662-
663-
elseif (AbsoluteTimeIsBackwardCompatiblyValid(expiretime))
664-
purgetime=expiretime;
665-
666649
vpc= (VPageDescr)palloc (sizeof(VPageDescrData)+MaxOffsetNumber*sizeof(OffsetNumber));
667650
vpc->vpd_nusd=0;
668651

@@ -732,31 +715,36 @@ vc_scanheap (VRelStats *vacrelstats, Relation onerel,
732715
ncrash++;
733716
tupgone= true;
734717
}
735-
else {
736-
elog (MESSAGE_LEVEL,"Rel %.*s: TID %u/%u: InsertTransactionInProgress %u",
718+
else
719+
{
720+
elog (NOTICE,"Rel %.*s: TID %u/%u: InsertTransactionInProgress %u - can't shrink relation",
737721
NAMEDATALEN,relname,blkno,offnum,htup->t_xmin);
722+
do_shrinking= false;
738723
}
739724
}
740725

741-
if (TransactionIdIsValid((TransactionId)htup->t_xmax)) {
742-
if (TransactionIdDidAbort(htup->t_xmax)) {
726+
if (TransactionIdIsValid((TransactionId)htup->t_xmax))
727+
{
728+
if (TransactionIdDidAbort(htup->t_xmax))
729+
{
743730
StoreInvalidTransactionId(&(htup->t_xmax));
744731
pgchanged= true;
745-
}elseif (TransactionIdDidCommit(htup->t_xmax)) {
746-
if (!AbsoluteTimeIsBackwardCompatiblyReal(htup->t_tmax)) {
747-
748-
htup->t_tmax=TransactionIdGetCommitTime(htup->t_xmax);
749-
pgchanged= true;
750-
}
751-
752-
/*
753-
* Reap the dead tuple if its expiration time is
754-
* before purgetime.
732+
}
733+
elseif (TransactionIdDidCommit(htup->t_xmax))
734+
tupgone= true;
735+
elseif ( !TransactionIdIsInProgress (htup->t_xmax) ) {
736+
/*
737+
* Not Aborted, Not Committed, Not in Progress -
738+
* so it from crashed process. - vadim 06/02/97
755739
*/
756-
757-
if (htup->t_tmax<purgetime) {
758-
tupgone= true;
759-
}
740+
StoreInvalidTransactionId(&(htup->t_xmax));
741+
pgchanged= true;
742+
}
743+
else
744+
{
745+
elog (NOTICE,"Rel %.*s: TID %u/%u: DeleteTransactionInProgress %u - can't shrink relation",
746+
NAMEDATALEN,relname,blkno,offnum,htup->t_xmax);
747+
do_shrinking= false;
760748
}
761749
}
762750

@@ -880,7 +868,7 @@ DELETE_TRANSACTION_ID_VALID %d, TUPGONE %d.",
880868
* Try to make Fvpl keeping in mind that we can't use free space
881869
* of "empty" end-pages and last page if it reapped.
882870
*/
883-
if (Vvpl->vpl_npages-nemend>0 )
871+
if (do_shrinking&&Vvpl->vpl_npages-nemend>0 )
884872
{
885873
intnusf;/* blocks usefull for re-using */
886874

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp