Skip to content

Commit 357cb8f

Browse files
author
Amit Kapila
committed
Fix valgrind issue in pgoutput.c.
We use a tuple conversion map for partitions when replicating using an ancestor's schema to convert tuples from partition's type to the ancestor's. Before this map got initialized, we were processing invalidation messages which access this map. This issue happens only in version 13 as in HEAD we already have a code that initializes each relation entry before we can process any invalidation message. This issue is introduced by commit d250568 in version 13. Reported-by: Tom Lane, as per buildfarm meber skink Author: Amit Langote Reviewed-by: Dilip Kumar, Amit Kapila Discussion: https://www.postgresql.org/message-id/648020.1623854904@sss.pgh.pa.us
1 parent 42f782b commit 357cb8f

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/backend/replication/pgoutput/pgoutput.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,20 @@ get_rel_sync_entry(PGOutputData *data, Oid relid)
685685
Assert(entry != NULL);
686686

687687
/* Not found means schema wasn't sent */
688-
if (!found || !entry->replicate_valid)
688+
if (!found)
689+
{
690+
/*
691+
* immediately make a new entry valid enough to satisfy callbacks
692+
*/
693+
entry->schema_sent = false;
694+
entry->replicate_valid = false;
695+
entry->pubactions.pubinsert = entry->pubactions.pubupdate =
696+
entry->pubactions.pubdelete = entry->pubactions.pubtruncate = false;
697+
entry->publish_as_relid = InvalidOid;
698+
entry->map = NULL; /* will be set by maybe_send_schema() if needed */
699+
}
700+
701+
if (!entry->replicate_valid)
689702
{
690703
List *pubids = GetRelationPublications(relid);
691704
ListCell *lc;
@@ -782,13 +795,9 @@ get_rel_sync_entry(PGOutputData *data, Oid relid)
782795
list_free(pubids);
783796

784797
entry->publish_as_relid = publish_as_relid;
785-
entry->map = NULL; /* will be set by maybe_send_schema() if needed */
786798
entry->replicate_valid = true;
787799
}
788800

789-
if (!found)
790-
entry->schema_sent = false;
791-
792801
return entry;
793802
}
794803

0 commit comments

Comments
 (0)