Invental/Review lessons/Code that silently does the wrong thing

Code that silently does the wrong thing

A read-only backup role is not one grant

A “read-only backup role” in Postgres is not one grant: pg_read_all_data skips large objects, table owners skip RLS unless it is forced, and --schema dumps silently leave large objects out.

01 · Before and afterThe pattern

SQL
-- before: assumed to read everything
grant pg_read_all_data to backup_reader;

-- after: also cover what that role doesn't
-- run once per large-object owner (only the owner can grant)
-- ...grant select on large object <oid> to backup_reader;
alter table app.orders force row level security;  -- if the owner must obey policies
-- pg_dump ... --password --schema=public --large-objects

02 · Run it on your appThe check

Has anyone restored your “read-only” backup end to end, including large objects, using the exact role and flags in your runbook?

If the honest answer is no or not sure, this is worth a look before it reaches production.

Want this checked on your code?

Tell us what you are building and what worries you. We match a senior reviewer to your code and confirm scope before anything starts.

— Get in touch
hi@invental.co ↗
— Or
— What to include

A link or short description of the code or system, what you want checked, your stack, and when you need the answer. No repository access is needed until scope is agreed.

— Or leave a note
We reply within one business day.