Re: BUG #14941: Vacuum crashes
Andres Freund <andres@anarazel.de>
From: Andres Freund <andres@anarazel.de>
To: "Bossart, Nathan" <bossartn@amazon.com>
Cc: Michael Paquier <michael@paquier.xyz>, Masahiko Sawada <sawada.mshk@gmail.com>, Robert Haas <robertmhaas@gmail.com>, Lyes Ameddah <lyes.amd@gmail.com>, Tomas Vondra <tomas.vondra@2ndquadrant.com>, "pgsql-hackers@postgresql.org" <pgsql-hackers@postgresql.org>, "pgsql-bugs@postgresql.org" <pgsql-bugs@postgresql.org>
Date: 2018-03-31T00:19:46Z
Lists: pgsql-bugs, pgsql-hackers
Hi,
On 2018-03-30 18:39:01 +0000, Bossart, Nathan wrote:
> I've noticed one more problem with ACCESS EXCLUSIVE. If an ACCESS
> EXCLUSIVE lock is held on a child relation of a partitioned table,
> an ANALYZE on the partitioned table will be blocked at
> acquire_inherited_sample_rows().
>
> static int
> acquire_inherited_sample_rows(Relation onerel, int elevel,
> HeapTuple *rows, int targrows,
> double *totalrows, double *totaldeadrows)
> {
> ...
> /*
> * Find all members of inheritance set. We only need AccessShareLock on
> * the children.
> */
> tableOIDs =
> find_all_inheritors(RelationGetRelid(onerel), AccessShareLock, NULL);
Right.
> It also seems possible for the call to vac_open_indexes() in
> do_analyze_rel() to block.
Yup.
> I think the most straightforward approach for fixing this is to add
> skip-locked functionality in find_all_inheritors(),
> find_inheritance_children(), and vac_open_indexes(), but I am curious
> what others think.
I'm actually wondering if we shouldn't just ignore this problem. While
the other cases VACUUM (SKIP LOCKED) are intended to solve seem common,
these seem less so. But it'd be a bit weird, too..
Could you post a rebased version of the patch, with an incremental
addition of what you propose in a separate patch?
Greetings,
Andres Freund
Commits
-
Add option SKIP_LOCKED to VACUUM and ANALYZE
- 803b1301e8c9 12.0 landed
-
Rename VACOPT_NOWAIT to VACOPT_SKIP_LOCKED
- edc6b41bd4a8 12.0 landed
-
Add parenthesized options syntax for ANALYZE.
- 854dd8cff523 11.0 landed
-
Don't allow VACUUM VERBOSE ANALYZE VERBOSE.
- 921059bd66c7 11.0 landed
-
Fix inadequate locking during get_rel_oids().
- 19de0ab23ccb 11.0 cited
-
Avoid having autovacuum workers wait for relation locks.
- 32896c40ca76 9.1.0 cited