On Wed, Sep 29, 2021 at 8:50 PM Robert Haas <robertmhaas@gmail.com> wrote:
>
> On Tue, Sep 21, 2021 at 6:48 PM Alvaro Herrera <alvherre@alvh.no-ip.org> wrote:
> > Document XLOG_INCLUDE_XID a little better
> >
> > I noticed that commit 0bead9af484c left this flag undocumented in
> > XLogSetRecordFlags, which led me to discover that the flag doesn't
> > actually do what the one comment on it said it does. Improve the
> > situation by adding some more comments.
> >
> > Backpatch to 14, where the aforementioned commit appears.
>
> I'm not sure that saying something is a "hack" is really all that
> useful as documentation.
>
> But more to the point, I think this hack is ugly and needs to be
> replaced with something less hacky.
>
I think we can do better than using XLOG_INCLUDE_XID flag in the
record being inserted. We need this flag so that we can mark
SubTransaction assigned after XLogInsertRecord() is successful. We
can instead output a flag (say sub_xact_assigned) from
XLogRecordAssemble() and pass it to XLogInsertRecord(). Then in
XLogInsertRecord(), we can mark SubTransactionAssigned once the record
is inserted (after or before calling
MarkCurrentTransactionIdLoggedIfAny()).
The other idea could be that in XLogInsertRecord(), we check
IsSubTransactionAssignmentPending() after the record is successfully
inserted and then mark SubTransaction assigned but I think the
previous one is better.
What do you think?
--
With Regards,
Amit Kapila.