Re: a problem about XLogReader callback system - Mailing list pgsql-hackers

From Alvaro Herrera
Subject Re: a problem about XLogReader callback system
Date
Msg-id 20200928135610.GA1123@alvherre.pgsql
Whole thread Raw
In response to a problem about XLogReader callback system  ("Wang, Shenhao" <wangsh.fnst@cn.fujitsu.com>)
List pgsql-hackers
Hello,

On 2020-Sep-28, Wang, Shenhao wrote:

> I have a problem about XLogReader callback system
> 
> In xlog.c, function StartupXLOG
> 
>     xlogreader =
>         XLogReaderAllocate(wal_segment_size, NULL,
>                            XL_ROUTINE(.page_read = &XLogPageRead,
>                                       .segment_open = NULL,
>                                       .segment_close = wal_segment_close),
>                            &private);
> 
> XLogPageReader uses readFile to store the fd, and I can't find any
> location to set the value of seg.ws_file.

Hmm, AFAICS (admittedly a quick look) you're right: because XLogPageRead
does not touch ws_file, wal_segment_close would always find that it's
unset (-1) so XLogReaderFree would have nothing to do.

The whole XLogReader abstraction remains pretty leaky, I'm afraid :-(
Ideally we would plug those holes.  Perhaps getting rid of readFile
completely would be a solution, but I haven't analyzed it.

> Is it necessary to set a segment_close callback?

For this case it seems useless but not actually harmful.  Have you come
across some scenario in which it causes a problem?

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services



pgsql-hackers by date:

Previous
From: Vladimir Sitnikov
Date:
Subject: Re: BLOB / CLOB support in PostgreSQL
Next
From: Tom Lane
Date:
Subject: Re: The return value of SPI_connect