Skip to content

Commit 31c389d

Browse files
author
Amit Kapila
committed
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
1 parent 163074e commit 31c389d

File tree

7 files changed

+86
-219
lines changed

7 files changed

+86
-219
lines changed

src/backend/replication/logical/launcher.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ logicalrep_worker_launch(Oid dbid, Oid subid, const char *subname, Oid userid,
379379
worker->relid = relid;
380380
worker->relstate = SUBREL_STATE_UNKNOWN;
381381
worker->relstate_lsn = InvalidXLogRecPtr;
382+
worker->stream_fileset = NULL;
382383
worker->last_lsn = InvalidXLogRecPtr;
383384
TIMESTAMP_NOBEGIN(worker->last_send_time);
384385
TIMESTAMP_NOBEGIN(worker->last_recv_time);
@@ -648,8 +649,9 @@ logicalrep_worker_onexit(int code, Datum arg)
648649

649650
logicalrep_worker_detach();
650651

651-
/* Cleanup filesets used for streaming transactions. */
652-
logicalrep_worker_cleanupfileset();
652+
/* Cleanup fileset used for streaming transactions. */
653+
if (MyLogicalRepWorker->stream_fileset != NULL)
654+
FileSetDeleteAll(MyLogicalRepWorker->stream_fileset);
653655

654656
ApplyLauncherWakeup();
655657
}

0 commit comments

Comments
 (0)