Re: Fix handling of copy_file_range() return value

From: Nazir Bilal Yavuz <byavuz81(at)gmail(dot)com>
To: Peter Eisentraut <peter(at)eisentraut(dot)org>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Fix handling of copy_file_range() return value
Date: 2026-06-22 08:17:44
Message-ID: CAN55FZ2wE7DgnqDVzdc8ZhMk2m_XYQNniufD5xw1sQyMtOvR4A@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Mon, 22 Jun 2026 at 10:20, Peter Eisentraut <peter(at)eisentraut(dot)org> wrote:
>
> While checking return/error handling of file system calls, I found that
> the copy_file_range() call in pg_combinebackup has a potential problem.
> If copy_file_range() returns 0, which is a documented condition, then
> the loop never makes progress and could spin forever.
>
> The other uses of copy_file_range() in the tree are surrounded by
> different logic and don't appear to have this problem.
>
> My suggested fix is to make a return value of 0 an error. It most
> likely indicates that the source file has an unexpected size.

You are right, that is a problem only with this use of
copy_file_range(), and your patch fixes it; LGTM.

--
Regards,
Nazir Bilal Yavuz
Microsoft

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message shveta malik 2026-06-22 08:26:19 Re: Proposal: Conflict log history table for Logical Replication
Previous Message Anton Voloshin 2026-06-22 08:15:50 Re: Reorganize GUC structs