Re: [PATCH] Add missing XLogEnsureRecordSpace() call in LogLogicalMessage

From: Henson Choi <assam258(at)gmail(dot)com>
To: pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: [PATCH] Add missing XLogEnsureRecordSpace() call in LogLogicalMessage
Date: 2025-12-30 01:59:16
Message-ID: CAAAe_zCpb8=OTGowyGpnJOtnzfSjj=L=8aXP84-7E3VgCJiv3Q@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi hackers,

After further investigation, I'm withdrawing this patch.

I mistakenly thought XLogEnsureRecordSpace() was called before
every XLogBeginInsert(), but this is not the case. Many call sites
rely on the default MAX_GENERIC_XLOG_RDATAS allocation when their
rdata count is known to be small.

LogLogicalMessage() is working as intended. Sorry for the noise.

Best regards,
Henson

2025년 12월 30일 (화) AM 10:21, Henson Choi <assam258(at)gmail(dot)com>님이 작성:

> Hi hackers,
>
> LogLogicalMessage() in src/backend/replication/logical/message.c is
> missing the XLogEnsureRecordSpace() call that appears before every
> other XLogBeginInsert() in the codebase.
>
> While this currently works because the 3 rdatas used here fit within
> the default allocation of MAX_GENERIC_XLOG_RDATAS (20), this pattern
> inconsistency could cause issues if:
>
> 1. MAX_GENERIC_XLOG_RDATAS is reduced in the future
> 2. This function is modified to use more rdatas
> 3. Someone copies this code without realizing the omission
>
> All other WAL insertion code follows the pattern of calling
> XLogEnsureRecordSpace() before XLogBeginInsert(). This patch adds
> the missing call for consistency.
>
> XLogRecPtr
> LogLogicalMessage(const char *prefix, const char *message, size_t size,
> bool transactional, bool flush)
> {
> ...
> xlrec.prefix_size = strlen(prefix) + 1;
> xlrec.message_size = size;
>
> + XLogEnsureRecordSpace(0, 3);
> XLogBeginInsert();
> XLogRegisterData(&xlrec, SizeOfLogicalMessage);
> XLogRegisterData(prefix, xlrec.prefix_size);
> XLogRegisterData(message, size);
> ...
> }
>
> Best regards,
> Henson
>

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bryan Green 2025-12-30 02:06:30 Re: [PATCH] Allow complex data for GUC extra.
Previous Message Xuneng Zhou 2025-12-30 01:51:49 Re: Streamify more code paths