diff options
author | Amit Kapila <akapila@postgresql.org> | 2023-01-13 08:28:05 +0530 |
---|---|---|
committer | Amit Kapila <akapila@postgresql.org> | 2023-01-13 08:28:05 +0530 |
commit | dca8b01f5f1f7c83c59a16393724fbd8a29ddecb (patch) | |
tree | 1acb6a3685042dd6131c6ebf8b171189422c6ea0 /src | |
parent | e753ae6397fe16db8e8e5b3e34ca6d53b4eded61 (diff) | |
download | postgresql-dca8b01f5f1f7c83c59a16393724fbd8a29ddecb.tar.gz postgresql-dca8b01f5f1f7c83c59a16393724fbd8a29ddecb.zip |
Avoid creating parallel apply state hash table unless required.
This hash table is used to cache the state of streaming transactions being
applied by the parallel apply workers. So, this should be created only
when we are successful in launching at least one worker. This avoids rare
case memory leak when we are never able to launch any worker.
Author: Ted Yu
Discussion: https://postgr.es/m/CALte62wg0rBR3Vj2beV=HiWo2qG9L0hzKcX=yULNER0wmf4aEw@mail.gmail.com
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/replication/logical/applyparallelworker.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/backend/replication/logical/applyparallelworker.c b/src/backend/replication/logical/applyparallelworker.c index 2e5914d5d95..3dfcff2798f 100644 --- a/src/backend/replication/logical/applyparallelworker.c +++ b/src/backend/replication/logical/applyparallelworker.c @@ -475,6 +475,10 @@ pa_allocate_worker(TransactionId xid) if (!pa_can_start()) return; + winfo = pa_launch_parallel_worker(); + if (!winfo) + return; + /* First time through, initialize parallel apply worker state hashtable. */ if (!ParallelApplyTxnHash) { @@ -490,10 +494,6 @@ pa_allocate_worker(TransactionId xid) HASH_ELEM | HASH_BLOBS | HASH_CONTEXT); } - winfo = pa_launch_parallel_worker(); - if (!winfo) - return; - /* Create an entry for the requested transaction. */ entry = hash_search(ParallelApplyTxnHash, &xid, HASH_ENTER, &found); if (found) |