Re: invalid data in file backup_label problem on windows

From: David Steele <david(at)pgmasters(dot)net>
To: "wangsh(dot)fnst(at)fujitsu(dot)com" <wangsh(dot)fnst(at)fujitsu(dot)com>
Cc: Michael Paquier <michael(at)paquier(dot)xyz>, "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: invalid data in file backup_label problem on windows
Date: 2021-03-19 13:05:56
Message-ID: ab224724-f1c1-03a8-38d3-3f29f1a5d8ad@pgmasters.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 3/19/21 6:11 AM, wangsh(dot)fnst(at)fujitsu(dot)com wrote:
> David Steele <david(at)pgmasters(dot)net> wrote:
>
>> I'm not sure how I feel about this patch (not really a Windows person)
>> but I do think that you shouldn't modify the backup_label when writing
>> it, i.e. you should be writing backup_label in binary mode to avoid this
>> issue.
>
> IMO, I don't modify backup_lable, I just execute select * FROM pg_stop_backup(),
> copy the result from terminal to a file and save the file, but most of editor on
> Windows will using CRLF as default to edit file, such as notepad, notepad++.

It's not clear to me what text editors have to do with this? Are you
editing the file manually?

> BTW, in [1]
>> The pg_stop_backup will return one row with three values. The second
>> of these fields should be written to a file named backup_label in the root
>> directory of the backup. The third field should be written to a file named
>> tablespace_map unless the field is empty. These files are vital to the backup
>> working, and must be written without modification.
>
> Do not use CRLF to edit a backup_label on windows is not mentioned.

"These files are vital to the backup working, and must be written
without modification" seems pretty clear to me.

>> No objections from me if it gets committed but I'm not sure it should be
>> classified as a "bug fix" since the backup_label was modified from what
>> postgres provided, unless I am misunderstanding.
>
> I think the backup_label is not a postgres provided file(using Non-Exclusive Low Level API),
> this file must be created by user.

It is provided by postgres via pg_stop_backup(). It should be simply
saved as-is to a file.

> If users use Exclusive Low Level API or pg_basebakup, this file will be auto created, and
> users will not edit this file.

You keep saying "edit the file" but perhaps you mean "save the file"?

Regards,
--
-David
david(at)pgmasters(dot)net

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Hannu Krosing 2021-03-19 13:14:24 Re: pl/pgsql feature request: shorthand for argument and local variable references
Previous Message Justin Pryzby 2021-03-19 12:57:00 Re: Asynchronous Append on postgres_fdw nodes.