pgsql: Make archiver process an auxiliary process.

Started by Fujii Masaoover 5 years ago6 messagescommitters
Jump to latest
#1Fujii Masao
fujii@postgresql.org

Make archiver process an auxiliary process.

This commit changes WAL archiver process so that it's treated as
an auxiliary process and can use shared memory. This is an infrastructure
patch required for upcoming shared-memory based stats collector patch
series. These patch series basically need any processes including archiver
that can report the statistics to access to shared memory. Since this patch
itself is useful to simplify the code and when users monitor the status of
archiver, it's committed separately in advance.

This commit simplifies the code for WAL archiving. For example, previously
backends need to signal to archiver via postmaster when they notify
archiver that there are some WAL files to archive. On the other hand,
this commit removes that signal to postmaster and enables backends to
notify archier directly using shared latch.

Also, as the side of this change, the information about archiver process
becomes viewable at pg_stat_activity view.

Author: Kyotaro Horiguchi
Reviewed-by: Andres Freund, Álvaro Herrera, Julien Rouhaud, Tomas Vondra, Arthur Zakirov, Fujii Masao
Discussion: /messages/by-id/20180629.173418.190173462.horiguchi.kyotaro@lab.ntt.co.jp

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/d75288fb27b8fe0a926aaab7d75816f091ecdc27

Modified Files
--------------
doc/src/sgml/monitoring.sgml | 1 +
src/backend/access/transam/xlogarchive.c | 4 +-
src/backend/bootstrap/bootstrap.c | 22 +--
src/backend/postmaster/pgarch.c | 239 +++++++++++++------------------
src/backend/postmaster/postmaster.c | 81 +++++------
src/backend/storage/ipc/ipci.c | 2 +
src/include/miscadmin.h | 2 +
src/include/postmaster/pgarch.h | 14 +-
src/include/storage/pmsignal.h | 1 -
src/include/storage/proc.h | 8 +-
src/tools/pgindent/typedefs.list | 1 +
11 files changed, 162 insertions(+), 213 deletions(-)

#2Thomas Munro
thomas.munro@gmail.com
In reply to: Fujii Masao (#1)
Re: pgsql: Make archiver process an auxiliary process.

On Mon, Mar 15, 2021 at 5:14 PM Fujii Masao <fujii@postgresql.org> wrote:

Make archiver process an auxiliary process.

This commit changes WAL archiver process so that it's treated as
an auxiliary process and can use shared memory. This is an infrastructure
patch required for upcoming shared-memory based stats collector patch
series. These patch series basically need any processes including archiver
that can report the statistics to access to shared memory. Since this patch
itself is useful to simplify the code and when users monitor the status of
archiver, it's committed separately in advance.

I think this needs to handle ProcSignalBarrierPending. Otherwise,
code that tries to use proc signal barriers (like CF #2962 and #2602)
might hang forever when an archiver is running.

#3Fujii Masao
masao.fujii@oss.nttdata.com
In reply to: Thomas Munro (#2)
Re: pgsql: Make archiver process an auxiliary process.

On 2021/06/12 19:36, Thomas Munro wrote:

On Mon, Mar 15, 2021 at 5:14 PM Fujii Masao <fujii@postgresql.org> wrote:

Make archiver process an auxiliary process.

This commit changes WAL archiver process so that it's treated as
an auxiliary process and can use shared memory. This is an infrastructure
patch required for upcoming shared-memory based stats collector patch
series. These patch series basically need any processes including archiver
that can report the statistics to access to shared memory. Since this patch
itself is useful to simplify the code and when users monitor the status of
archiver, it's committed separately in advance.

I think this needs to handle ProcSignalBarrierPending. Otherwise,
code that tries to use proc signal barriers (like CF #2962 and #2602)
might hang forever when an archiver is running.

Thanks for the comment! I will investigate this.

Regards,

--
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION

#4Fujii Masao
masao.fujii@oss.nttdata.com
In reply to: Fujii Masao (#3)
Re: pgsql: Make archiver process an auxiliary process.

On 2021/06/16 13:29, Fujii Masao wrote:

On 2021/06/12 19:36, Thomas Munro wrote:

On Mon, Mar 15, 2021 at 5:14 PM Fujii Masao <fujii@postgresql.org> wrote:

Make archiver process an auxiliary process.

This commit changes WAL archiver process so that it's treated as
an auxiliary process and can use shared memory. This is an infrastructure
patch required for upcoming shared-memory based stats collector patch
series. These patch series basically need any processes including archiver
that can report the statistics to access to shared memory. Since this patch
itself is useful to simplify the code and when users monitor the status of
archiver, it's committed separately in advance.

I think this needs to handle ProcSignalBarrierPending.  Otherwise,
code that tries to use proc signal barriers (like CF #2962 and #2602)
might hang forever when an archiver is running.

Thanks for the comment! I will investigate this.

Attached patch changes archiver so that it also handles barrier events.

Regards,

--
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION

Attachments:

archiver_handles_signal_barrier_v1.patchtext/plain; charset=UTF-8; name=archiver_handles_signal_barrier_v1.patch; x-mac-creator=0; x-mac-type=0Download+27-14
#5Thomas Munro
thomas.munro@gmail.com
In reply to: Fujii Masao (#4)
Re: pgsql: Make archiver process an auxiliary process.

On Thu, Jun 17, 2021 at 11:28 PM Fujii Masao
<masao.fujii@oss.nttdata.com> wrote:

Attached patch changes archiver so that it also handles barrier events.

LGTM. Thanks!

#6Fujii Masao
masao.fujii@oss.nttdata.com
In reply to: Thomas Munro (#5)
Re: pgsql: Make archiver process an auxiliary process.

On 2021/06/17 20:32, Thomas Munro wrote:

On Thu, Jun 17, 2021 at 11:28 PM Fujii Masao
<masao.fujii@oss.nttdata.com> wrote:

Attached patch changes archiver so that it also handles barrier events.

LGTM. Thanks!

Pushed. Thanks!

Regards,

--
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION