mirror of
https://github.com/postgres/postgres.git
synced 2025-09-09 13:09:39 +03:00
Invalidate pgoutput's replication-decisions cache upon schema rename.
A schema rename should cause reporting the new qualified names of tables to logical replication subscribers, but that wasn't happening. Flush the RelationSyncCache to make it happen. (If you ask me, the new test case shows that the behavior in this area is still pretty dubious, but apparently it's operating as designed.) Vignesh C Discussion: https://postgr.es/m/CALDaNm32vLRv5KdrDFeVC-CU+4Wg1daA55hMqOxDGJBzvd76-w@mail.gmail.com
This commit is contained in:
@@ -1929,7 +1929,22 @@ init_rel_sync_cache(MemoryContext cachectx)
|
||||
|
||||
Assert(RelationSyncCache != NULL);
|
||||
|
||||
/* We must update the cache entry for a relation after a relcache flush */
|
||||
CacheRegisterRelcacheCallback(rel_sync_cache_relation_cb, (Datum) 0);
|
||||
|
||||
/*
|
||||
* Flush all cache entries after a pg_namespace change, in case it was a
|
||||
* schema rename affecting a relation being replicated.
|
||||
*/
|
||||
CacheRegisterSyscacheCallback(NAMESPACEOID,
|
||||
rel_sync_cache_publication_cb,
|
||||
(Datum) 0);
|
||||
|
||||
/*
|
||||
* Flush all cache entries after any publication changes. (We need no
|
||||
* callback entry for pg_publication, because publication_invalidation_cb
|
||||
* will take care of it.)
|
||||
*/
|
||||
CacheRegisterSyscacheCallback(PUBLICATIONRELMAP,
|
||||
rel_sync_cache_publication_cb,
|
||||
(Datum) 0);
|
||||
@@ -2325,8 +2340,8 @@ rel_sync_cache_relation_cb(Datum arg, Oid relid)
|
||||
/*
|
||||
* Publication relation/schema map syscache invalidation callback
|
||||
*
|
||||
* Called for invalidations on pg_publication, pg_publication_rel, and
|
||||
* pg_publication_namespace.
|
||||
* Called for invalidations on pg_publication, pg_publication_rel,
|
||||
* pg_publication_namespace, and pg_namespace.
|
||||
*/
|
||||
static void
|
||||
rel_sync_cache_publication_cb(Datum arg, int cacheid, uint32 hashvalue)
|
||||
@@ -2337,14 +2352,14 @@ rel_sync_cache_publication_cb(Datum arg, int cacheid, uint32 hashvalue)
|
||||
/*
|
||||
* We can get here if the plugin was used in SQL interface as the
|
||||
* RelSchemaSyncCache is destroyed when the decoding finishes, but there
|
||||
* is no way to unregister the relcache invalidation callback.
|
||||
* is no way to unregister the invalidation callbacks.
|
||||
*/
|
||||
if (RelationSyncCache == NULL)
|
||||
return;
|
||||
|
||||
/*
|
||||
* There is no way to find which entry in our cache the hash belongs to so
|
||||
* mark the whole cache as invalid.
|
||||
* We have no easy way to identify which cache entries this invalidation
|
||||
* event might have affected, so just mark them all invalid.
|
||||
*/
|
||||
hash_seq_init(&status, RelationSyncCache);
|
||||
while ((entry = (RelationSyncEntry *) hash_seq_search(&status)) != NULL)
|
||||
|
Reference in New Issue
Block a user