MVCC vacuum error - Mailing list pgsql-hackers

From Hiroshi Inoue
Subject MVCC vacuum error
Date
Msg-id 001701be9930$c9cd2fa0$2801007e@cadzone.tpf.co.jp
Whole thread Raw
List pgsql-hackers
Hello all,

I got some errors when testing vacuum with other concurrent 
sessions. The following patch would fix some of the cases such that  
1.ERROR : moving chain: failed to add item with len = ......2.ERROR : Cannot insert a duplicate key into a unique
index


Another bug seems to remain unsolved.

VACUUM showsNOTICE :NUMBER OF INDEX' TUPLES (...) IS NOT THE SAME    AS HEAP' (...)

and after vacuum other sessions show ERROR : Cannot insert a duplicate key into a unique index

AFAIC when moving update chain of tuples,vpd_offsets is maintained 
only for one page,even if tuples in chain exist in plural pages.
So there seems to be cases that some index tuples remain alive 
which point out invalid(or nonexistent by truncation) tids after vacuum. 

Thanks.

Hiroshi Inoue
Inoue@tpf.co.jp

*** backend/commands/vacuum.c.orig    Tue Apr 13 16:01:16 1999
--- backend/commands/vacuum.c    Sat May  8 17:23:50 1999
***************
*** 1336,1342 ****                      */                     ToPage = BufferGetPage(cur_buffer);
/*if this page was not used before - clean it */
 
!                     if (!PageIsEmpty(ToPage) && vtmove[i].cleanVpd)                         vc_vacpage(ToPage,
vtmove[ti].vpd);                    heap_copytuple_with_tuple(&tuple, &newtup);
RelationInvalidateHeapTuple(onerel,&tuple);
 
--- 1336,1342 ----                      */                     ToPage = BufferGetPage(cur_buffer);
/*if this page was not used before - clean it */
 
!                     if (!PageIsEmpty(ToPage) && vtmove[ti].cleanVpd)                         vc_vacpage(ToPage,
vtmove[ti].vpd);                    heap_copytuple_with_tuple(&tuple, &newtup);
RelationInvalidateHeapTuple(onerel,&tuple);
 
***************
*** 1355,1361 ****                     newitemid = PageGetItemId(ToPage, newoff);
pfree(newtup.t_data);                    newtup.t_data = (HeapTupleHeader) PageGetItem(ToPage, newitemid);
 
!                     ItemPointerSet(&(newtup.t_self), vtmove[i].vpd->vpd_blkno, newoff);                     /*
             * Set t_ctid pointing to itself for last tuple in                      * chain and to next tuple in chain
otherwise.
--- 1355,1361 ----                     newitemid = PageGetItemId(ToPage, newoff);
pfree(newtup.t_data);                    newtup.t_data = (HeapTupleHeader) PageGetItem(ToPage, newitemid);
 
!                     ItemPointerSet(&(newtup.t_self), vtmove[ti].vpd->vpd_blkno, newoff);                     /*
              * Set t_ctid pointing to itself for last tuple in                      * chain and to next tuple in chain
otherwise.



pgsql-hackers by date:

Previous
From: Thomas Lockhart
Date:
Subject: Re: [HACKERS] NUMERIC type conversions leave much to be desired
Next
From: Chris Bitmead
Date:
Subject: Date/Time Flaw in pg_dump ?