Re: Fix some error handling for read() and errno

Robbie Harwood <rharwood@redhat.com>

From: Robbie Harwood <rharwood@redhat.com>
To: Michael Paquier <michael@paquier.xyz>, Kyotaro HORIGUCHI <horiguchi.kyotaro@lab.ntt.co.jp>
Cc: pgsql-hackers@postgresql.org, tgl@sss.pgh.pa.us, magnus@hagander.net, hlinnaka@iki.fi
Date: 2018-06-11T21:42:32Z
Lists: pgsql-hackers
Michael Paquier <michael@paquier.xyz> writes:

> diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
> index 87942b4cca..d487347cc6 100644
> --- a/src/backend/access/transam/slru.c
> +++ b/src/backend/access/transam/slru.c
> @@ -683,6 +683,11 @@ SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
>  	pgstat_report_wait_start(WAIT_EVENT_SLRU_READ);
>  	if (read(fd, shared->page_buffer[slotno], BLCKSZ) != BLCKSZ)
>  	{
> +		/*
> +		 * XXX: Note that this may actually report sucess if the number
> +		 * of bytes read is positive, but lacking data so that errno is
> +		 * not set.
> +		 */
>  		pgstat_report_wait_end();
>  		slru_errcause = SLRU_READ_FAILED;
>  		slru_errno = errno;

It might be less confusing to just set errno if it's not set already
(e.g., to EIO, or something).  Up to you though - this is a bit of a
niche case.

The rest of the patch looks good to me.

Thanks,
--Robbie

Commits

  1. Rework error messages around file handling