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

Reply via email to