pgsql: pg_rewind: Fix some problems when copying files >2GB.

From: Robert Haas <rhaas(at)postgresql(dot)org>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: pg_rewind: Fix some problems when copying files >2GB.
Date: 2017-07-22 02:10:27
Message-ID: E1dYjsB-0006tn-3l@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

pg_rewind: Fix some problems when copying files >2GB.

When incrementally updating a file larger than 2GB, the old code could
either fail outright (if the client asked the server for bytes beyond
the 2GB boundary) or fail to copy all the blocks that had actually
been modified (if the server reported a file size to the client in
excess of 2GB), resulting in data corruption. Generally, such files
won't occur anyway, but they might if using a non-default segment size
or if there the directory contains stray files unrelated to
PostgreSQL. Fix by a more prudent choice of data types.

Even with these improvements, this code still uses a mix of different
types (off_t, size_t, uint64, int64) to represent file sizes and
offsets, not all of which necessarily have the same width or
signedness, so further cleanup might be in order here. However, at
least now they all have the potential to be 64 bits wide on 64-bit
platforms.

Kuntal Ghosh and Michael Paquier, with a tweak by me.

Discussion: http://postgr.es/m/CAGz5QC+8gbkz=Brp0TgoKNqHWTzonbPtPex80U0O6Uh_bevbaA@mail.gmail.com

Branch
------
REL9_6_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/73fbf3d3d0a59d79f75a8202e03863fe462d052f

Modified Files
--------------
src/bin/pg_rewind/libpq_fetch.c | 47 ++++++++++++++++++++++++++++++-----------
1 file changed, 35 insertions(+), 12 deletions(-)

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2017-07-22 16:15:35 pgsql: Update expected results for collate.linux.utf8 regression test.
Previous Message Robert Haas 2017-07-22 02:10:21 pgsql: pg_rewind: Fix some problems when copying files >2GB.

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2017-07-22 05:50:29 Re: Error while copying a large file in pg_rewind
Previous Message Alvaro Herrera 2017-07-22 01:33:18 Re: More race conditions in logical replication