Skip site navigation (1) Skip section navigation (2)

Re: PATCH to allow concurrent VACUUMs to not lock each

From: Neil Conway <neilc(at)samurai(dot)com>
To: hannu(at)skype(dot)net
Cc: pgsql-patches(at)postgresql(dot)org
Subject: Re: PATCH to allow concurrent VACUUMs to not lock each
Date: 2005-05-23 13:58:58
Message-ID: 4291E1A2.9050308@samurai.com (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-patches
Hannu Krosing wrote:
> *** src/backend/access/transam/xact.c	28 Apr 2005 21:47:10 -0000	1.200
> --- src/backend/access/transam/xact.c	17 May 2005 22:06:34 -0000
> ***************
> *** 1411,1416 ****
> --- 1411,1424 ----
>   	AfterTriggerBeginXact();
>   
>   	/*
> + 	 * mark the transaction as not VACUUM  (vacuum_rel will set isVacuum to true 
> + 	 * directly after calling BeginTransactionCommand() )
> + 	 */
> + 	if (MyProc != NULL)  
> + 	{
> + 		MyProc->inVacuum = false;
> + 	}

I'm a little worried about having this set to "true" after a VACUUM is 
executed, and only reset to false when the next transaction is begun: it 
shouldn't affect correctness right now, but it seems like asking for 
trouble. Resetting the flag to "false" after processing a transaction 
would probably be worth doing.

> *** src/backend/commands/vacuum.c	6 May 2005 17:24:53 -0000	1.308
> --- src/backend/commands/vacuum.c	17 May 2005 22:06:35 -0000
> ***************
> *** 420,425 ****
> --- 418,428 ----
>   				if (use_own_xacts)
>   				{
>   					StartTransactionCommand();
> + 					if (MyProc != NULL)  /* is this needed here ? */
> + 					{
> + 						/* so other vacuums don't look at our xid/xmin in GetOldestXmin() */
> + 						MyProc->inVacuum = true;
> + 					}
>   					/* functions in indexes may want a snapshot set */
>   					ActiveSnapshot = CopySnapshot(GetTransactionSnapshot());
>   				}

Is it valid to apply this optimization to ANALYZE? Since ANALYZE updates 
pg_statistic, ISTM it can affect tuple visibility.

> *** src/backend/storage/ipc/sinval.c	31 Dec 2004 22:00:56 -0000	1.75
> --- src/backend/storage/ipc/sinval.c	17 May 2005 22:06:36 -0000
> ***************
> *** 845,854 ****
>   			 * them as running anyway.	We also assume that such xacts
>   			 * can't compute an xmin older than ours, so they needn't be
>   			 * considered in computing globalxmin.
>   			 */
>   			if (proc == MyProc ||
>   				!TransactionIdIsNormal(xid) ||
> ! 				TransactionIdFollowsOrEquals(xid, xmax))
>   				continue;
>   
>   			if (TransactionIdPrecedes(xid, xmin))
> --- 845,858 ----
>   			 * them as running anyway.	We also assume that such xacts
>   			 * can't compute an xmin older than ours, so they needn't be
>   			 * considered in computing globalxmin.
> + 			 *
> + 			 * there is also no need to consider transaxtions runnibg the 
> + 			 * vacuum command as it will not affect tuple visibility
>   			 */

Typos.

-Neil

In response to

Responses

pgsql-hackers by date

Next:From: Christopher Kings-LynneDate: 2005-05-23 14:06:53
Subject: Re: INSTEAD OF trigger on VIEWs
Previous:From: Richard HuxtonDate: 2005-05-23 13:40:55
Subject: Re: subquery returning array

pgsql-patches by date

Next:From: Tom LaneDate: 2005-05-23 14:16:06
Subject: Re: PATCH to allow concurrent VACUUMs to not lock each
Previous:From: Bruce MomjianDate: 2005-05-23 13:13:31
Subject: Re: PATCH to allow concurrent VACUUMs to not lock each other

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group