回复:logical decoding: skip unnecessary snapshot distribution.

From: "yangboyu" <yangboyu(dot)yby(at)alibaba-inc(dot)com>
To: "Shlok Kyal" <shlok(dot)kyal(dot)oss(at)gmail(dot)com>
Cc: "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: 回复:logical decoding: skip unnecessary snapshot distribution.
Date: 2026-10-16 03:51:28
Message-ID: f4e38ebb-f3c7-4303-8c0c-472938fb9803.yangboyu.yby@alibaba-inc.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


Hi Shlok, 
> For a SHAREDINVALRELCACHE_ID message, dbId == InvalidOid and
> relId == InvalidOid mean "invalidate the whole relcache".  They do not mean
> that a shared relation changed.  CacheInvalidateRelcacheAll() creates this
> message for publication DDL, such as ALTER PUBLICATION ... SET ALL TABLES.
>
> InvalidationsTouchSharedCatalog() returns true for this message.  Therefore,
> for a commit from another database, 'distribute' stays true and the snapshot
> and invalidations are still distributed.
>
> Since this message alone does not mean that a shared catalog changed, should
> we ignore it when deciding whether to distribute changes from another
> database?
   
Your observation is right. And in my idea, it's better to be conservative here.
   
Considering the meaning of CacheInvalidateRelcacheAll(), all relcaches contain
the relcaches of shared relations, such as pg_database. So such invalidation
message should be sent to all backends. While for publication DDLs, as there
is not a "CacheInvalidateLocalRelcacheAll()", CacheInvalidateRelcacheAll() is a
reasonable way to invalidate all local tables' relcache.
   
Although publication ddls are now the only caller of CacheInvalidateRelcacheAll(),
I think it's more reasonable to regard it as a shared catalog change. And
LocalExecuteInvalidationMessage() is also in the same way.
   
Regards,
Boyu Yang

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Smith 2026-10-16 03:56:32 Re: PSQL schema "describe" \dn is not escaping quotes
Previous Message David Rowley 2026-10-16 03:50:57 Re: Parallel TID Range Scan returns wrong results on rescan