diff options
author | Amit Kapila <akapila@postgresql.org> | 2021-09-02 08:13:46 +0530 |
---|---|---|
committer | Amit Kapila <akapila@postgresql.org> | 2021-09-02 08:13:46 +0530 |
commit | 31c389d8de915b705ee06c7a6e9246e20f36b9dc (patch) | |
tree | d90d353d2b81389163684cacadc780bf90dbeeec /src/backend/replication/logical/launcher.c | |
parent | 163074ea84efec6ffa4813db43cc956ac5d12565 (diff) |
Optimize fileset usage in apply worker.
Use one fileset for the entire worker lifetime instead of using
separate filesets for each streaming transaction. Now, the
changes/subxacts files for every streaming transaction will be
created under the same fileset and the files will be deleted
after the transaction is completed.
This patch extends the BufFileOpenFileSet and BufFileDeleteFileSet
APIs to allow users to specify whether to give an error on missing
files.
Author: Dilip Kumar, based on suggestion by Thomas Munro
Reviewed-by: Hou Zhijie, Masahiko Sawada, Amit Kapila
Discussion: https://postgr.es/m/E1mCC6U-0004Ik-Fs@gemulon.postgresql.org
Diffstat (limited to 'src/backend/replication/logical/launcher.c')
-rw-r--r-- | src/backend/replication/logical/launcher.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/backend/replication/logical/launcher.c b/src/backend/replication/logical/launcher.c index 8b1772db69e..3fb4caa8033 100644 --- a/src/backend/replication/logical/launcher.c +++ b/src/backend/replication/logical/launcher.c @@ -379,6 +379,7 @@ retry: worker->relid = relid; worker->relstate = SUBREL_STATE_UNKNOWN; worker->relstate_lsn = InvalidXLogRecPtr; + worker->stream_fileset = NULL; worker->last_lsn = InvalidXLogRecPtr; TIMESTAMP_NOBEGIN(worker->last_send_time); TIMESTAMP_NOBEGIN(worker->last_recv_time); @@ -648,8 +649,9 @@ logicalrep_worker_onexit(int code, Datum arg) logicalrep_worker_detach(); - /* Cleanup filesets used for streaming transactions. */ - logicalrep_worker_cleanupfileset(); + /* Cleanup fileset used for streaming transactions. */ + if (MyLogicalRepWorker->stream_fileset != NULL) + FileSetDeleteAll(MyLogicalRepWorker->stream_fileset); ApplyLauncherWakeup(); } |