Re: Avoid orphaned objects dependencies, take 3

Bertrand Drouvot <bertranddrouvot.pg@gmail.com>

From: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
To: Jeff Davis <pgsql@j-davis.com>
Cc: Heikki Linnakangas <hlinnaka@iki.fi>, Robert Haas <robertmhaas@gmail.com>, Roman Eskin <r.eskin@arenadata.io>, Michael Paquier <michael@paquier.xyz>, Alexander Lakhin <exclusion@gmail.com>, pgsql-hackers@lists.postgresql.org, Tom Lane <tgl@sss.pgh.pa.us>
Date: 2026-06-25T11:10:58Z
Lists: pgsql-hackers

Attachments

Hi,

On Fri, Jun 19, 2026 at 01:28:21PM +0000, Bertrand Drouvot wrote:
> Hi,
> 
> On Thu, Jun 18, 2026 at 04:21:33PM -0700, Jeff Davis wrote:
> 
> > We could keep the transaction ID in the tracking record, and ignore
> > entries from an aborted subxact. But it's getting fairly complex and
> > delicate.

As discussed off-list, let's move forward with this proposal (as the save a copy
of the object's ACL + ROLE membership mentioned in [1] would be more complex and
fragile).

So PFA the new version doing so. It's the same patch series as the previous one
except that it adds:

0004: Discard ACL tracking entries from aborted subtransactions

It stores SubTransactionId in each AclCheckEntry at recording time.
On subtransaction abort, AtEOSubXact_AclTrack() discards entries whose subxid
is >= the aborting subtransaction's ID.

The code is pretty simple but I suspect that adding a test would probably need to
create a brand new module (say test_acltrack) with C code forcing
recordDependencyOn() and BeginInternalSubTransaction()) and I'm not sure it's
worth it. Indeed, I think the test would need to do things similar to what you
shared in [2].

The patch is split to ease the review but should probably be merged as a single
patch.

[1]: https://postgr.es/m/ajVF7YWf%2Bpxs4cOf%40bdtpg
[2]: https://postgr.es/m/5c629d2455946ad2fde3c184f64ea2c323ef2133.camel@j-davis.com

Regards,

-- 
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Avoid orphaned objects dependencies

  2. Don't try to record dependency on a dropped column's datatype