Re: Handle concurrent drop when doing whole database vacuum

From: cca5507 <cca5507(at)qq(dot)com>
To: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, surya poondla <suryapoondla4(at)gmail(dot)com>, Michael Paquier <michael(at)paquier(dot)xyz>
Subject: Re: Handle concurrent drop when doing whole database vacuum
Date: 2026-06-25 05:53:39
Message-ID: tencent_67C6166FFDE0CA2E25F4AC90A97621454605@qq.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

> Some comments on the v3 patches:
>
> 1/
> + *
> + * Note: use pg_class_aclcheck_ext() to detect a concurrent drop.
>
> This comment seems redundant - the function call, the missing_ok
> check, and the warning message already make it clear.

Yeah, the code can explain itself clearly, so removed.

> 2/
> + * Note that the relation might not be locked, so it can be dropped
> concurrently.
> + * This can happen when doing a whole database vacuum or analyze in
> + * get_all_vacuum_rels().  We issue a WARNING log message and return false in
> + * this case.
>
> Instead of saying "relation might not be locked", can we be more
> explicit about the exact cases? For example: For database-wide
> vacuums, this function is called without holding a relation lock, so
> the table can be dropped concurrently. In that case, issue a WARNING
> and return false.

Fixed.

> I couldn't think of a good way to reproduce this other than creating a
> large number of tables to make the pg_class scan costlier. For
> predictable testing I might agree to adding an injection point.
> However, I have some comments:
>
> 3/
> +# Make sure that current user is not the owner of current database.
> +step setrole1
> +{
> +    SET ROLE regress_vacuum;
> +}
>
> Is this necessary?

Yes, we won't check MAINTAIN privilege on the table if current user is the
owner of current database.

> 4/
> +step analyze1
> +{
> +    ANALYZE;
> +}
>
> I think just testing VACUUM or VACUUM ANALYZE in a single test keeps
> things smaller, since the underlying code is the same for both.

Yeah, the ANALYZE might also increase the test time, so removed.

> 5/
> +++ b/src/test/modules/injection_points/specs/vacuum_concurrent_drop.spec
>
> Why do you need isolation tests with an injection point? Why not a TAP
> test under src/test/modules/test_misc? A TAP test with just VACUUM
> (not ANALYZE) would keep the test simpler with fewer lines of code.

The src/test/perl/README says:

It's used to drive tests for backup and restore, replication, etc - anything that can't
really be expressed using pg_regress or the isolation test framework.

I can write a TAP test if we decide to use it.

> 6/
> + INJECTION_POINT("vacuum-constructing-vacuumable-rels", NULL);
>
> Nit: How about a shorter name like vacuum-get-rels or vacuum-build-rels?

I think the current one is ok, so I didn't change this.

--
Regards,
ChangAo Chen

Attachment Content-Type Size
v4-0001-Handle-concurrent-drop-when-doing-whole-database-.patch application/octet-stream 3.1 KB
v4-0002-Add-test-case-for-vacuum-with-a-concurrent-drop.patch application/octet-stream 4.6 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Smith 2026-06-25 05:57:46 Re: Include sequences in publications created by pg_createsubscriber
Previous Message Ashutosh Sharma 2026-06-25 05:35:06 Re: Include sequences in publications created by pg_createsubscriber