1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-14 18:42:34 +03:00

Adopt the GNU convention for handling tar-archive members exceeding 8GB.

The POSIX standard for tar headers requires archive member sizes to be
printed in octal with at most 11 digits, limiting the representable file
size to 8GB.  However, GNU tar and apparently most other modern tars
support a convention in which oversized values can be stored in base-256,
allowing any practical file to be a tar member.  Adopt this convention
to remove two limitations:
* pg_dump with -Ft output format failed if the contents of any one table
exceeded 8GB.
* pg_basebackup failed if the data directory contained any file exceeding
8GB.  (This would be a fatal problem for installations configured with a
table segment size of 8GB or more, and it has also been seen to fail when
large core dump files exist in the data directory.)

File sizes under 8GB are still printed in octal, so that no compatibility
issues are created except in cases that would have failed entirely before.

In addition, this patch fixes several bugs in the same area:

* In 9.3 and later, we'd defined tarCreateHeader's file-size argument as
size_t, which meant that on 32-bit machines it would write a corrupt tar
header for file sizes between 4GB and 8GB, even though no error was raised.
This broke both "pg_dump -Ft" and pg_basebackup for such cases.

* pg_restore from a tar archive would fail on tables of size between 4GB
and 8GB, on machines where either "size_t" or "unsigned long" is 32 bits.
This happened even with an archive file not affected by the previous bug.

* pg_basebackup would fail if there were files of size between 4GB and 8GB,
even on 64-bit machines.

* In 9.3 and later, "pg_basebackup -Ft" failed entirely, for any file size,
on 64-bit big-endian machines.

In view of these potential data-loss bugs, back-patch to all supported
branches, even though removal of the documented 8GB limit might otherwise
be considered a new feature rather than a bug fix.
This commit is contained in:
Tom Lane
2015-11-21 20:21:31 -05:00
parent 074c5cfbfb
commit 00cdd83521
6 changed files with 126 additions and 117 deletions

View File

@ -272,12 +272,12 @@ PostgreSQL documentation
<listitem>
<para>
Output a <command>tar</command>-format archive suitable for input
into <application>pg_restore</application>. The tar-format is
compatible with the directory-format; extracting a tar-format
into <application>pg_restore</application>. The tar format is
compatible with the directory format: extracting a tar-format
archive produces a valid directory-format archive.
However, the tar-format does not support compression and has a
limit of 8 GB on the size of individual tables. Also, the relative
order of table data items cannot be changed during restore.
However, the tar format does not support compression. Also, when
using tar format the relative order of table data items cannot be
changed during restore.
</para>
</listitem>
</varlistentry>
@ -1140,15 +1140,6 @@ CREATE DATABASE foo WITH TEMPLATE template0;
catalogs might be left in the wrong state.
</para>
<para>
Members of tar archives are limited to a size less than 8 GB.
(This is an inherent limitation of the tar file format.) Therefore
this format cannot be used if the textual representation of any one table
exceeds that size. The total size of a tar archive and any of the
other output formats is not limited, except possibly by the
operating system.
</para>
<para>
The dump file produced by <application>pg_dump</application>
does not contain the statistics used by the optimizer to make