Re: WAL reader APIs and WAL segment open/close callbacks

From: Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>
To: michael(at)paquier(dot)xyz
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org, ah(at)cybertec(dot)at, alvherre(at)2ndquadrant(dot)com
Subject: Re: WAL reader APIs and WAL segment open/close callbacks
Date: 2020-05-25 02:17:06
Message-ID: 20200525.111706.996399041886580951.horikyota.ntt@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

At Mon, 25 May 2020 07:44:09 +0900, Michael Paquier <michael(at)paquier(dot)xyz> wrote in
> Hi all,
>
> I have been playing with the new APIs of xlogreader.h, and while
> merging some of my stuff with 13, I found the handling around
> ->seg.ws_file overcomplicated and confusing as it is necessary for a
> plugin to manipulate directly the fd of an opened segment in the WAL
> segment open/close callbacks.

That depends on where we draw responsibility border, or who is
responsible to the value of ws_file. I think that this API change was
assuming the callbacks having full-knowledge of the xlogreader struct
and are responsible to maintain related struct members, and I agree to
that direction.

> Wouldn't it be cleaner to limit the exposition of ->seg.ws_file to the
> user if possible? There are cases like a WAL sender where you cannot
> do that, but something that came to my mind is to make
> WALSegmentOpenCB return the fd of the opened segment, and pass down the
> fd to close to WALSegmentCloseCB. Then xlogreader.c is in charge of
> resetting the field when a segment is closed.
>
> Any thoughts?

If we are going to hide the struct from the callbacks, we shouldn't
pass to the callbacks a pointer to the complete XLogReaderState
struct.

regards.

--
Kyotaro Horiguchi
NTT Open Source Software Center

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message shawn wang 2020-05-25 03:37:42 Re: [bug] Table not have typarray when created by single user mode
Previous Message Tomas Vondra 2020-05-25 02:10:45 Re: Trouble with hashagg spill I/O pattern and costing