Re: Fix some error handling for read() and errno - Mailing list pgsql-hackers

From Robbie Harwood
Subject Re: Fix some error handling for read() and errno
Date
Msg-id jlg1sddhuev.fsf@redhat.com
Whole thread Raw
In response to Re: Fix some error handling for read() and errno  (Michael Paquier <michael@paquier.xyz>)
Responses Re: Fix some error handling for read() and errno
List 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


Attachment

pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: Needless additional partition check in INSERT?
Next
From: Michael Paquier
Date:
Subject: Re: pgsql: Fix and document lock handling for in-memory replicationslot da