Re: blkreftable.c needs more sanity checks

Поиск
Список
Период
Сортировка
Искать

Re: blkreftable.c needs more sanity checks

От:
Robert Haas <robertmhaas@gmail.com>
Дата:
On Tue, Jul 14, 2026 at 3:27 AM Daniel Gustafsson  wrote:
> +       reader->error_callback(reader->error_callback_arg,
> +                              "file \"%s\" has oversized chunk",
> +                              reader->error_filename);
>
> Any reason not to print the offending chunk size to aid debugging of this type
> of should-never-happen scenario?

I can if you want, but I think if this happens IRL, you've probably
run pg_walsummary on something that was never intended as a WAL
summary file in the first place, and knowing what random nibble you
interpreted as a chunk size probably isn't going to help anything.

More broadly: To me, this is kind of the epitome of an AI-generated
bug report. It is definitely wrong. It should definitely be fixed. But
if AI hadn't found it, and we'd just waited for someone to discover it
by running into it, I'd guess that it would have taken decades for
that to happen, or maybe it would never have happened. So in some
sense we might be better off not knowing, because fixing this kind of
theoretical bug is taking up a lot of resources right now that we
could be spending on problems that matter more. Fixing this kind of
stuff seems essential at this point if only to prevent the same issues
from being re-reported over and over again and consuming even more
resources, and even if that were no issue, I'm too conscientious to
want to ignore stuff like this once I know about it. At the same time,
the benefit to PostgreSQL users is de minimis.

-- 
Robert Haas
EDB: http://www.enterprisedb.com


Re: blkreftable.c needs more sanity checks

От:
Daniel Gustafsson <daniel@yesql.se>
Дата:
> On 14 Jul 2026, at 13:21, Robert Haas  wrote:
> 
> On Tue, Jul 14, 2026 at 3:27 AM Daniel Gustafsson  wrote:
>> +       reader->error_callback(reader->error_callback_arg,
>> +                              "file \"%s\" has oversized chunk",
>> +                              reader->error_filename);
>> 
>> Any reason not to print the offending chunk size to aid debugging of this type
>> of should-never-happen scenario?
> 
> I can if you want, but I think if this happens IRL, you've probably
> run pg_walsummary on something that was never intended as a WAL
> summary file in the first place, and knowing what random nibble you
> interpreted as a chunk size probably isn't going to help anything.

A more likely scenario is that you are hacking in this code and have made silly
errors.  It mostly seemed consistent with how the forknum error is reported,
but is not important.

> More broadly: To me, this is kind of the epitome of an AI-generated
> bug report. It is definitely wrong. It should definitely be fixed. But
> if AI hadn't found it, and we'd just waited for someone to discover it
> by running into it, I'd guess that it would have taken decades for
> that to happen, or maybe it would never have happened. So in some
> sense we might be better off not knowing, because fixing this kind of
> theoretical bug is taking up a lot of resources right now that we
> could be spending on problems that matter more. Fixing this kind of
> stuff seems essential at this point if only to prevent the same issues
> from being re-reported over and over again and consuming even more
> resources, and even if that were no issue, I'm too conscientious to
> want to ignore stuff like this once I know about it. At the same time,
> the benefit to PostgreSQL users is de minimis.

No disagreement there, which is why I tried to get it reviewed quickly so it
can be applied and forgotten about and we can move on to more important
matters.

--
Daniel Gustafsson



Re: blkreftable.c needs more sanity checks

От:
Robert Haas <robertmhaas@gmail.com>
Дата:
Вложения:
On Tue, Jul 14, 2026 at 7:31 AM Daniel Gustafsson  wrote:
> A more likely scenario is that you are hacking in this code and have made silly
> errors.  It mostly seemed consistent with how the forknum error is reported,
> but is not important.

Upon reflection, it occurred to me that I would probably rather have
the chunk offset than the chunk size if this ever trips, so I added
both to the error message. Here's v2.

> No disagreement there, which is why I tried to get it reviewed quickly so it
> can be applied and forgotten about and we can move on to more important
> matters.

Thanks for reviewing.

-- 
Robert Haas
EDB: http://www.enterprisedb.com

pgsql: Fix concurrency issues with DROP TABLESPACE

От:
Andrew Dunstan <andrew@dunslane.net>
Дата:
Вложения:
Fix concurrency issues with DROP TABLESPACE

DROP TABLESPACE checked pg_shdepend for dependent objects without
first locking the tablespace.  A concurrent command that recorded a
shared dependency on the tablespace right after that check could still
commit, leaving an object whose pg_shdepend entry (or, for a relation,
pg_class.reltablespace) pointed to a tablespace that no longer existed.

Close the race by having DropTableSpace() take an AccessExclusiveLock
on the tablespace before calling checkSharedDependencies().  That
conflicts with the AccessShareLock shdepLockAndCheckObject() takes when
recording a new dependency, so the loser of the race blocks and
rechecks once the winner commits.

That AccessExclusiveLock creates a new deadlock: ALTER TABLESPACE
RENAME/SET and the internal ACL/owner updates in DROP OWNED and
REASSIGN OWNED touched the catalog tuple without locking the
tablespace, risking a lock-order cycle with DROP.  Fix by taking an
AccessShareLock first in all four paths, rechecking pg_shdepend after
any wait in the DROP OWNED and REASSIGN OWNED cases.  GRANT, REVOKE,
and ALTER TABLESPACE ... OWNER TO already lock the object.

Add isolation tests covering both orderings of the original race
(dependency-first and drop-first) and all four previously-unlocked
update paths.

Author: Ayush Tiwari 
Reviewed-by: Andrew Dunstan 
Discussion: https://postgr.es/m/CAJTYsWXjAQFnGKzXsht3XK8KHhyhontwFJw4JAHsUSfs_ptR4g@mail.gmail.com
Backpatch-through: 14

Branch
------
REL_18_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/d77627daac5baa895a1d37d2d12666bbf55585a5

Modified Files
--------------
src/backend/catalog/pg_shdepend.c                  | 40 +++++++--
src/backend/commands/tablespace.c                  | 18 +++-
.../expected/tablespace-dependency-locking.out     | 84 +++++++++++++++++++
src/test/isolation/isolation_schedule              |  1 +
.../specs/tablespace-dependency-locking.spec       | 98 ++++++++++++++++++++++
5 files changed, 234 insertions(+), 7 deletions(-)

FAQ