aboutsummaryrefslogtreecommitdiff
path: root/src/backend/replication
diff options
context:
space:
mode:
authorAmit Kapila <akapila@postgresql.org>2021-03-23 09:43:33 +0530
committerAmit Kapila <akapila@postgresql.org>2021-03-23 09:43:33 +0530
commit4b82ed6eca41220e50d4712ab929c20030b30d35 (patch)
treeddf4ae99c963c35380a5eced540202b325de3f78 /src/backend/replication
parenta5f002ad9a2ddb501148a12281efbaacec6f6397 (diff)
downloadpostgresql-4b82ed6eca41220e50d4712ab929c20030b30d35.tar.gz
postgresql-4b82ed6eca41220e50d4712ab929c20030b30d35.zip
Fix dangling pointer reference in stream_cleanup_files.
We can't access the entry after it is removed from dynahash. Author: Peter Smith Discussion: https://postgr.es/m/CAHut+Ps-pL++f6CJwPx2+vUqXuew=Xt-9Bi-6kCyxn+Fwi2M7w@mail.gmail.com
Diffstat (limited to 'src/backend/replication')
-rw-r--r--src/backend/replication/logical/worker.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c
index 21d304a64c3..354fbe4b4bc 100644
--- a/src/backend/replication/logical/worker.c
+++ b/src/backend/replication/logical/worker.c
@@ -2740,14 +2740,14 @@ stream_cleanup_files(Oid subid, TransactionId xid)
{
char path[MAXPGPATH];
StreamXidHash *ent;
+ bool found = false;
- /* Remove the xid entry from the stream xid hash */
+ /* By this time we must have created the transaction entry */
ent = (StreamXidHash *) hash_search(xidhash,
(void *) &xid,
- HASH_REMOVE,
- NULL);
- /* By this time we must have created the transaction entry */
- Assert(ent != NULL);
+ HASH_FIND,
+ &found);
+ Assert(found);
/* Delete the change file and release the stream fileset memory */
changes_filename(path, subid, xid);
@@ -2763,6 +2763,9 @@ stream_cleanup_files(Oid subid, TransactionId xid)
pfree(ent->subxact_fileset);
ent->subxact_fileset = NULL;
}
+
+ /* Remove the xid entry from the stream xid hash */
+ hash_search(xidhash, (void *) &xid, HASH_REMOVE, NULL);
}
/*