From: | Alvaro Herrera <alvherre(at)2ndquadrant(dot)com> |
---|---|
To: | "Wang, Shenhao" <wangsh(dot)fnst(at)cn(dot)fujitsu(dot)com> |
Cc: | "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: a problem about XLogReader callback system |
Date: | 2020-09-28 13:56:10 |
Message-ID: | 20200928135610.GA1123@alvherre.pgsql |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2020-09-28 14:02:31 | Re: The return value of SPI_connect |
Previous Message | Vladimir Sitnikov | 2020-09-28 13:46:43 | Re: BLOB / CLOB support in PostgreSQL |