Re: 2pc leaks fds - Mailing list pgsql-hackers

From Alvaro Herrera
Subject Re: 2pc leaks fds
Date
Msg-id 20200422175754.GA19858@alvherre.pgsql
Whole thread Raw
In response to Re: 2pc leaks fds  (Alvaro Herrera <alvherre@2ndquadrant.com>)
Responses Re: 2pc leaks fds
List pgsql-hackers
Concretely, I propose to have a new struct like

typedef struct xlogReaderFuncs
{
    XLogPageReadCB read_page;
    XLogSegmentOpenCB open_segment;
    XLogSegmentCloseCB open_segment;
} xlogReaderFuncs;

#define XLOGREADER_FUNCS(...) &(xlogReaderFuncs){__VA_ARGS__}

and then invoke it something like

    xlogreader = XLogReaderAllocate(wal_segment_size, NULL,
                                    XLOGREADER_FUNCS(.readpage = &read_local_xlog_page,
                                              .opensegment = &wal_segment_open),
                                              .closesegment = &wal_segment_close),
                                    NULL);

(with suitable definitions for XLogSegmentOpenCB etc) so that the
support functions are all available at the xlogreader level, instead of
"open" being buried at the read-page level.  Any additional support
functions can be added easily.

This would give xlogreader a simpler interface.

If people like this, I could make this change for pg13 and avoid
changing the API again in pg14.

Thougths?

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



pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: More efficient RI checks - take 2
Next
From: Bruce Momjian
Date:
Subject: Re: Do we need to handle orphaned prepared transactions in theserver?