Fix handling of copy_file_range() return value

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Fix handling of copy_file_range() return value
Date: 2026-06-22 07:19:59
Message-ID: 3208cf7a-c7f3-41eb-92f6-33cbeff4df40@eisentraut.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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.

Attachment Content-Type Size
0001-Fix-handling-of-copy_file_range-return-value.patch text/plain 1.2 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Kyotaro Horiguchi 2026-06-22 07:46:42 Re: doc: should pg_createsubscriber be grouped as a client application?
Previous Message Henson Choi 2026-06-22 07:07:43 Re: Row pattern recognition