Re: [HACKERS] Microvacuum support for Hash Index - Mailing list pgsql-hackers

From Ashutosh Sharma
Subject Re: [HACKERS] Microvacuum support for Hash Index
Date
Msg-id CAE9k0P=OXww6RQCGrmDNa8=L3EeB01SGbYuP23y-qZJ=4td38Q@mail.gmail.com
Whole thread Raw
In response to Re: [HACKERS] Microvacuum support for Hash Index  (Robert Haas <robertmhaas@gmail.com>)
Responses Re: [HACKERS] Microvacuum support for Hash Index  (Robert Haas <robertmhaas@gmail.com>)
List pgsql-hackers
> +    action = XLogReadBufferForRedo(record, 0, &buffer);
> +
> +    if (!IsBufferCleanupOK(buffer))
> +        elog(PANIC, "hash_xlog_vacuum_one_page: failed to acquire
> cleanup lock");
>
> That could fail, I think, because of a pin from a Hot Standby backend.
> You want to call XLogReadBufferForRedoExtended() with a third argument
> of true.

Yes, there is a possibility that a new backend may start in standby
after we kill the conflicting backends. If the new backend has pin on
the buffer which the startup process is trying to read then
'IsBufferCleanupOK' will fail thereby causing a startup process to
PANIC.

 Come to think of it, shouldn't hash_xlog_split_allocate_page
> be changed the same way?

No, the reason being we are trying to allocate a new bucket page on
standby so there can't be any backend which could have pin on a page
that is yet to initialised.

>
> +            /*
> +             * Let us mark the page as clean if vacuum removes the DEAD tuples
> +             * from an index page. We do this by clearing
> LH_PAGE_HAS_DEAD_TUPLES
> +             * flag.
> +             */
>
> Maybe add: Clearing this flag is just a hint; replay won't redo this.

Added. Please check the attached v9 patch.

>
> +     * Hash Index records that are marked as LP_DEAD and being removed during
> +     * hash index tuple insertion can conflict with standby queries.You might
>
> The word Index shouldn't be capitalized here.  There should be a space
> before "You".

Corrected.

>
> The formatting of this comment is oddly narrow:
>
> + * _hash_vacuum_one_page - vacuum just one index page.
> + * Try to remove LP_DEAD items from the given page.  We
> + * must acquire cleanup lock on the page being modified
> + * before calling this function.
>
> I'd add a blank line after the first line and reflow the rest to be
> something more like 75 characters.  pgindent evidently doesn't think
> this needs reformatting, but it's oddly narrow.

Corrected.

>
> I suggest changing the header comment of
> hash_xlog_vacuum_get_latestRemovedXid like this:
>
> + * Get the latestRemovedXid from the heap pages pointed at by the index
> + * tuples being deleted.  See also btree_xlog_delete_get_latestRemovedXid,
> + * on which this function is based.
>
> This is looking good.

Changed as per suggestions. Attached v9 patch. Thanks.

--
With Regards,
Ashutosh Sharma
EnterpriseDB:http://www.enterprisedb.com

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Attachment

pgsql-hackers by date:

Previous
From: "Joshua D. Drake"
Date:
Subject: [HACKERS] Odd listen_addresses behavior
Next
From: Tom Lane
Date:
Subject: Re: [HACKERS] Odd listen_addresses behavior