Re: heap vacuum & cleanup locks

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Simon Riggs <simon(at)2ndquadrant(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: heap vacuum & cleanup locks
Date: 2011-11-04 19:39:19
Message-ID: CA+TgmoZaRKaxeWn817ZgD27hLF+Km+RVMESM1_ufM1A2nBBroA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Nov 4, 2011 at 3:12 PM, Simon Riggs <simon(at)2ndquadrant(dot)com> wrote:
> On Fri, Nov 4, 2011 at 6:18 PM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
>
>> Here's a new version.  I fixed the second pass as discussed (which
>> turned out to be trivial).  To address the concern about relpages, I
>> moved this pre-existing line to after we get the buffer lock:
>>
>> +               vacrelstats->scanned_pages++;
>>
>> That appears to do the right thing.
>
> I think we need to count skipped pages also. I don't like the idea
> that vacuum would just report less pages than there are in the table.
> We'll just get requests to explain that.

It's been skipping pages due to the visibility map since 8.4. This
seems like small potatoes by comparison, but we could add some
counters if you like.

>> I found it kind of confusing that lazy_scan_page_for_wraparound()
>> returns with the pin either held or not held depending on the return
>> value, so I rearranged things very slightly so that it doesn't need to
>> do that.  I'm wondering whether we should rename that function to
>> something like lazy_check_needs_freeze().
>
> OK
>
>> I tested this out and discovered that "VACUUM FREEZE" doesn't set the
>> for_wraparound flag.  On further review, I think that we should
>> probably conditionalize the behavior on the scan_all flag that
>> lazy_vacuum_rel sets, rather than for_wraparound.  Otherwise, there's
>> no way for the user to manually force relfrozenxid to advance, which
>> doesn't seem good.  I haven't made that change in this version,
>> though.
>
> Agreed, separate patch.

Doing that actually makes the patch simpler, so I went ahead and did
that in the attached version, along with the renaming mentioned above.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

Attachment Content-Type Size
vacuum_skip_busy_pages.v3.patch application/octet-stream 5.7 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Treat 2011-11-04 19:47:52 Re: IDLE in transaction introspection
Previous Message Rodrigo Hjort 2011-11-04 19:35:47 Re: Strange behavior on to_tsquery()