Re: modify error report in mdwrite/mdextend

Поиск
Список
Период
Сортировка
От Bharath Rupireddy
Тема Re: modify error report in mdwrite/mdextend
Дата
Msg-id CALj2ACUGtujMGoE+6ZYkt+YyxGyMv9RYVPtFGOO9uRTJKcUy6A@mail.gmail.com
обсуждение исходный текст
Ответ на modify error report in mdwrite/mdextend  ("蔡梦娟(玊于)" <mengjuan.cmj@alibaba-inc.com>)
Ответы Re: modify error report in mdwrite/mdextend  (Alvaro Herrera <alvherre@alvh.no-ip.org>)
Список pgsql-hackers
On Mon, Oct 18, 2021 at 1:45 PM 蔡梦娟(玊于) <mengjuan.cmj@alibaba-inc.com> wrote:
>
>
> Hi, all
> I noticed that the "else" is missing during the error report after FileWrite() of mdwrite()/mdextend(), short write
erroris supposed to be reported when written bytes is not less than 0. 
> I modified it in the attached patch:
> diff --git a/src/backend/storage/smgr/md.c b/src/backend/storage/smgr/md.c
> index b4bca7eed6..dd60479b65 100644
> --- a/src/backend/storage/smgr/md.c
> +++ b/src/backend/storage/smgr/md.c
> @@ -450,13 +450,14 @@ mdextend(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
>        errmsg("could not extend file \"%s\": %m",
>         FilePathName(v->mdfd_vfd)),
>        errhint("Check free disk space.")));
> -  /* short write: complain appropriately */
> -  ereport(ERROR,
> -    (errcode(ERRCODE_DISK_FULL),
> -     errmsg("could not extend file \"%s\": wrote only %d of %d bytes at block %u",
> -      FilePathName(v->mdfd_vfd),
> -      nbytes, BLCKSZ, blocknum),
> -     errhint("Check free disk space.")));
> +  else
> +   /* short write: complain appropriately */
> +   ereport(ERROR,
> +     (errcode(ERRCODE_DISK_FULL),
> +      errmsg("could not extend file \"%s\": wrote only %d of %d bytes at block %u",
> +       FilePathName(v->mdfd_vfd),
> +       nbytes, BLCKSZ, blocknum),
> +      errhint("Check free disk space.")));
>   }
>
> Does this match your previous expectations? Hope to get your reply.

The control from the below ereport(ERROR, doesn't reach the short
write error part. IMO, the existing way does no harm, it is a mere
programming choice.

        if (nbytes < 0)
            ereport(ERROR,
                    (errcode_for_file_access(),
                     errmsg("could not write block %u in file \"%s\": %m",
                            blocknum, FilePathName(v->mdfd_vfd))));
        /* short write: complain appropriately */
        ereport(ERROR,

Regards,
Bharath Rupireddy.



В списке pgsql-hackers по дате отправления:

Предыдущее
От: "蔡梦娟(玊于)"
Дата:
Сообщение: modify error report in mdwrite/mdextend
Следующее
От: Masahiko Sawada
Дата:
Сообщение: Re: Added schema level support for publication.