Can autovac try to lock multiple tables at once?

Started by Tom Lanealmost 19 years ago4 messageshackers
Jump to latest
#1Tom Lane
tgl@sss.pgh.pa.us

$subject would be bad because of potential deadlocks against other
transactions that might try to exclusive-lock more than one table.

We should be OK for actual vacuum operations, but I think that if
autovac chooses to just ANALYZE multiple tables, it will do it in
one transaction and accumulate locks. Probably the use_own_xacts
logic in vacuum() ought to special-case IsAutoVacuumWorkerProcess.

regards, tom lane

#2Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: Tom Lane (#1)
Re: Can autovac try to lock multiple tables at once?

Tom Lane wrote:

$subject would be bad because of potential deadlocks against other
transactions that might try to exclusive-lock more than one table.

We should be OK for actual vacuum operations, but I think that if
autovac chooses to just ANALYZE multiple tables, it will do it in
one transaction and accumulate locks. Probably the use_own_xacts
logic in vacuum() ought to special-case IsAutoVacuumWorkerProcess.

Sure, it can do that. I think it's easy enough to correct this problem;
see attached patch. Should this be backpatched? Earlier releases also
fall foul of this problem AFAICT.

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

Attachments:

av-analyze-ownxact.patchtext/x-diff; charset=us-asciiDownload+7-7
#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Alvaro Herrera (#2)
Re: Can autovac try to lock multiple tables at once?

Alvaro Herrera <alvherre@commandprompt.com> writes:

Sure, it can do that. I think it's easy enough to correct this problem;
see attached patch. Should this be backpatched? Earlier releases also
fall foul of this problem AFAICT.

Yeah, because what made me think about it was a gripe from an 8.2
user ... maybe this wasn't his problem, but it could be.

regards, tom lane

#4Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: Tom Lane (#3)
Re: Can autovac try to lock multiple tables at once?

Tom Lane wrote:

Alvaro Herrera <alvherre@commandprompt.com> writes:

Sure, it can do that. I think it's easy enough to correct this problem;
see attached patch. Should this be backpatched? Earlier releases also
fall foul of this problem AFAICT.

Yeah, because what made me think about it was a gripe from an 8.2
user ... maybe this wasn't his problem, but it could be.

Backpatched all the way back to 8.1.

--
Alvaro Herrera Developer, http://www.PostgreSQL.org/
Y dijo Dios: "Que sea Satan�s, para que la gente no me culpe de todo a m�."
"Y que hayan abogados, para que la gente no culpe de todo a Satan�s"