mirror of
https://github.com/block/buzz.git
synced 2026-12-01 13:42:45 +00:00
fix(db): preserve partition reader grants (#8485)
## Summary PostgreSQL does not copy parent table grants to new partitions. A reader can query the `events` parent but fail direct partition reads after the relay creates another month or replaces its catch-all. Copy each managed parent's explicit table-level `SELECT` grants to its new children inside the existing maintenance transaction. The parent ACL supplies the policy; there is no new setting or deployment-specific role name. Writes, column-only grants, owner entries, and grant options are excluded. A grant failure rolls back the table's partition changes. Existing children and manually created or attached partitions still need grants from database provisioning. Apply the [companion initializer fix](https://github.com/squareup/bb-utility/pull/2253) for existing partitions before relying on automatic grants for future ones. ### Related issue No duplicate found. The closest related PR is #8464, which enables catch-all advancement by default; this change independently preserves reader access during that maintenance. ### Testing No manual testing. Production rollout and the Fivetran setup check remain pending. Generated with Codex Signed-off-by: coder2 <4acc49cb93576448ba82e631688c51a40bf03d6a889d78fddf57917d198de10f@buzz.block.builderlab.xyz> Co-authored-by: coder2 <4acc49cb93576448ba82e631688c51a40bf03d6a889d78fddf57917d198de10f@buzz.block.builderlab.xyz>
This commit is contained in:
@@ -30,6 +30,23 @@ later. Once its upper bound is at or before the start of the current month, it i
|
||||
historical. It remains in the per-child report as `legacy_leaf` but no longer
|
||||
degrades the table.
|
||||
|
||||
## Reader grants on new partitions
|
||||
|
||||
When maintenance creates a monthly partition or replaces the empty catch-all,
|
||||
it copies explicit table-level `SELECT` grants from that parent to the new
|
||||
children before committing. Group roles and explicit `PUBLIC` grants are
|
||||
included; the owner's ACL entry, column-only grants, writes, and grant options
|
||||
are not copied. No additional relay setting is needed. A grant failure rolls
|
||||
back that table's entire maintenance transaction.
|
||||
|
||||
Existing children and manually created or attached partitions still need their
|
||||
own grants. Maintenance does not reconcile grants on existing tables or revoke
|
||||
old grants when the parent ACL changes. Replacing the catch-all drops and
|
||||
recreates it, so grants added directly to the old catch-all are lost; only the
|
||||
parent's `SELECT` grants carry over. Keep those permissions aligned through
|
||||
the database's provisioning process. Initial schema bootstrap runs before
|
||||
deployment-specific reader grants are provisioned.
|
||||
|
||||
## Metrics
|
||||
|
||||
Per-table gauges are set only by a successful audit of that table:
|
||||
|
||||
Reference in New Issue
Block a user