aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmit Kapila <akapila@postgresql.org>2021-06-18 08:51:18 +0530
committerAmit Kapila <akapila@postgresql.org>2021-06-18 08:51:18 +0530
commit357cb8f07f95665ea533ff534821c22c35b01288 (patch)
treeee6afd6d342f13a309cb6b29528c44aa71f8d636
parent42f782be916807121fcce20811892c0bad95fca3 (diff)
downloadpostgresql-357cb8f07f95665ea533ff534821c22c35b01288.tar.gz
postgresql-357cb8f07f95665ea533ff534821c22c35b01288.zip
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 d250568121 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
-rw-r--r--src/backend/replication/pgoutput/pgoutput.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/backend/replication/pgoutput/pgoutput.c b/src/backend/replication/pgoutput/pgoutput.c
index 5b33b31515e..ddc01714ef1 100644
--- a/src/backend/replication/pgoutput/pgoutput.c
+++ b/src/backend/replication/pgoutput/pgoutput.c
@@ -685,7 +685,20 @@ get_rel_sync_entry(PGOutputData *data, Oid relid)
Assert(entry != NULL);
/* Not found means schema wasn't sent */
- if (!found || !entry->replicate_valid)
+ if (!found)
+ {
+ /*
+ * immediately make a new entry valid enough to satisfy callbacks
+ */
+ entry->schema_sent = false;
+ entry->replicate_valid = false;
+ entry->pubactions.pubinsert = entry->pubactions.pubupdate =
+ entry->pubactions.pubdelete = entry->pubactions.pubtruncate = false;
+ entry->publish_as_relid = InvalidOid;
+ entry->map = NULL; /* will be set by maybe_send_schema() if needed */
+ }
+
+ if (!entry->replicate_valid)
{
List *pubids = GetRelationPublications(relid);
ListCell *lc;
@@ -782,13 +795,9 @@ get_rel_sync_entry(PGOutputData *data, Oid relid)
list_free(pubids);
entry->publish_as_relid = publish_as_relid;
- entry->map = NULL; /* will be set by maybe_send_schema() if needed */
entry->replicate_valid = true;
}
- if (!found)
- entry->schema_sent = false;
-
return entry;
}