diff --git a/src/backend/access/gin/ginfast.c b/src/backend/access/gin/ginfast.c
new file mode 100644
index c5732c3..2d2bd54
*** a/src/backend/access/gin/ginfast.c
--- b/src/backend/access/gin/ginfast.c
***************
*** 24,29 ****
--- 24,30 ----
  #include "miscadmin.h"
  #include "utils/memutils.h"
  #include "utils/rel.h"
+ #include "storage/lmgr.h"
  
  /* GUC parameter */
  int			gin_pending_list_limit = 0;
*************** ginInsertCleanup(GinState *ginstate,
*** 745,750 ****
--- 746,757 ----
  	KeyArray	datums;
  	BlockNumber blkno;
  
+ //	if (vac_delay) 
+ 		LockPage(index,GIN_METAPAGE_BLKNO,ShareUpdateExclusiveLock);
+ //	else 
+ //		if (!ConditionalLockPage(index,GIN_METAPAGE_BLKNO,ShareUpdateExclusiveLock))
+ //			return;
+ 
  	metabuffer = ReadBuffer(index, GIN_METAPAGE_BLKNO);
  	LockBuffer(metabuffer, GIN_SHARE);
  	metapage = BufferGetPage(metabuffer);
*************** ginInsertCleanup(GinState *ginstate,
*** 754,759 ****
--- 761,767 ----
  	{
  		/* Nothing to do */
  		UnlockReleaseBuffer(metabuffer);
+ 		UnlockPage(index,GIN_METAPAGE_BLKNO,ShareUpdateExclusiveLock);
  		return;
  	}
  
*************** ginInsertCleanup(GinState *ginstate,
*** 929,934 ****
--- 937,943 ----
  		page = BufferGetPage(buffer);
  	}
  
+ 	UnlockPage(index,GIN_METAPAGE_BLKNO,ShareUpdateExclusiveLock);
  	ReleaseBuffer(metabuffer);
  
  	/* Clean up temporary space */
diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c
new file mode 100644
index 93f2656..ee6f1f9
*** a/src/backend/storage/lmgr/proc.c
--- b/src/backend/storage/lmgr/proc.c
*************** ProcSleep(LOCALLOCK *locallock, LockMeth
*** 1139,1147 ****
  
  		/*
  		 * If we are not deadlocked, but are waiting on an autovacuum-induced
! 		 * task, send a signal to interrupt it.
  		 */
! 		if (deadlock_state == DS_BLOCKED_BY_AUTOVACUUM && allow_autovacuum_cancel)
  		{
  			PGPROC	   *autovac = GetBlockingAutoVacuumPgproc();
  			PGXACT	   *autovac_pgxact = &ProcGlobal->allPgXact[autovac->pgprocno];
--- 1139,1152 ----
  
  		/*
  		 * If we are not deadlocked, but are waiting on an autovacuum-induced
! 		 * task, send a signal to interrupt it.  However, if we are waiting
! 		 * on a page lock for ShareUpdateExclusive, don't signal autovacuum.
! 		 * That is only used for cleaning the pending list of a GIN index.  
! 		 * If we kill the autovacuum, then we will just have to clean the 
! 		 * pending list ourselves anyway.
  		 */
! 		if (deadlock_state == DS_BLOCKED_BY_AUTOVACUUM && allow_autovacuum_cancel &&
! 			!(lock->tag.locktag_type == LOCKTAG_PAGE && lockmode == ShareUpdateExclusiveLock) )
  		{
  			PGPROC	   *autovac = GetBlockingAutoVacuumPgproc();
  			PGXACT	   *autovac_pgxact = &ProcGlobal->allPgXact[autovac->pgprocno];
