Tighten ACL check in repack_is_permitted_for_relation()

From: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Cc: Álvaro Herrera <alvherre(at)kurilemu(dot)de>
Subject: Tighten ACL check in repack_is_permitted_for_relation()
Date: 2026-08-04 08:13:00
Message-ID: CALj2ACVExk=_m=7nuwVE5Nb3kwsYm1498NSO=u0uOOSWjDCdTQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

(CC-ing Álvaro Herrera for some thoughts)

repack_is_permitted_for_relation() uses pg_class_aclcheck_ext() to
silently skip a concurrently-dropped relation. That's wrong for a
caller that may already hold a lock on the relation whose ACL is
checked, where missing a relation is not fine, and it makes the
single-relation REPACK cases more brittle
(https://www.postgresql.org/message-id/akPhEffRipH4isWF@nathan) So
only detect a missing relation where that's expected, following the
fix for vacuum_is_permitted_for_relation() in commit 824d5f6. The new
missing_ok behavior is limited to get_tables_to_repack() and
get_tables_to_repack_partitioned(). All other callers of
repack_is_permitted_for_relation() hold a lock on the relation that
prevents it from being concurrently dropped, so this commit also adds
an assertion to that effect.

I posted this in the thread but starting a new discussion to get some
quick thoughts:
https://www.postgresql.org/message-id/CALj2ACX3pyuRS8%2B%2B6L20cJUMRTf_qbbVp69J1btJ3y6%3D77e5gw%40mail.gmail.com

Please find the attached patch for review.

--
Bharath Rupireddy
Amazon Web Services: https://aws.amazon.com

Attachment Content-Type Size
v2-0001-Tighten-ACL-check-in-repack_is_permitted_for_rela.patch application/octet-stream 4.9 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message Neil Chen 2026-08-04 08:13:42 Re: [PATCH] Fix vacuum_delay_point happening inside lock
Previous Message Fujii Masao 2026-08-04 08:12:20 Re: Fix error handling in getCopyDataMessage and pqFunctionCall3