RE: invalid data in file backup_label problem on windows

From: "Wang, Shenhao" <wangsh(dot)fnst(at)cn(dot)fujitsu(dot)com>
To: "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-01-15 03:29:57
Message-ID: d5a0b4ca690d46539adf4bc4490b2779@G08CNEXMBPEKD06.g08.fujitsu.local
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi, again:

On windows, if a backup_label file contains a windows(CRLF) line ending.
Recovering from this backup will failed.

I think this is a problem, can I add this to commitfest?

Best Regards,
Shenhao Wang

-----Original Message-----
From: Wang, Shenhao <wangsh(dot)fnst(at)cn(dot)fujitsu(dot)com>
Sent: Sunday, January 10, 2021 8:58 PM
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: invalid data in file backup_label problem on windows

Hi hackers.

When I using a Non-Exclusive Low-Level Backup on windows, "invalid data in file backup_label" will be shown.

The code are listed below

if (fscanf(lfp, "START WAL LOCATION: %X/%X (file %08X%16s)%c",
&hi, &lo, &tli_from_walseg, startxlogfilename, &ch) != 5 || ch != '\n')
ereport(FATAL,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg("invalid data in file \"%s\"", BACKUP_LABEL_FILE)));

When I wrote the backup_label on windows, CRLF will at the end of line, so the ch will be '\r'.

I'm not sure that these two files(tablespace_map and backup_label) should not use CRLF new line style is mentioned in manual[1].
How about setting the text mode when reading these 2 files like patch listed in attachment?

Any thought?

[1] https://www.postgresql.org/docs/13/continuous-archiving.html#BACKUP-LOWLEVEL-BASE-BACKUP

Best Regards,
Shenhao Wang

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2021-01-15 03:37:31 Re: invalid data in file backup_label problem on windows
Previous Message Amit Kapila 2021-01-15 03:09:32 Re: Logical Replication - behavior of ALTER PUBLICATION .. DROP TABLE and ALTER SUBSCRIPTION .. REFRESH PUBLICATION