Re: pg_basebackup throttling doesn't throttle as promised
Antonin Houska <ah@cybertec.at>
From: Antonin Houska <ah@cybertec.at>
To: Jeff Janes <jeff.janes@gmail.com>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2017-09-02T08:32:53Z
Lists: pgsql-hackers
Jeff Janes <jeff.janes@gmail.com> wrote:
> On Fri, Sep 1, 2017 at 1:32 PM, Jeff Janes <jeff.janes@gmail.com> wrote:
>
> The "-r" option to pg_basebackup is supposed to throttle the rate of the
> backup. But it only works properly if the server is mostly idle.
>
> Every non-trivial call to XLogFlush or XLogBackgroundFlush will wake up the
> wal sender (the one which is not really sending wal, but base files), and
> the throttling routine doesn't go back to sleep after being awoke
> early. Rather, it releases another 32kb of data.
Sorry, I missed this fact when coding the feature.
> Should the basebackup.c throttle sleep in a loop until its time has
> expired?
I think this is the correct approach because latch can be set for unrelated
reasons.
The patch makes sense to me. I just recommend moving this part in front of the
loop because elapsed_min does not have to be re-computed each time:
/* How much should have elapsed at minimum? */
elapsed_min = elapsed_min_unit * (throttling_counter / throttling_sample);
And also a comment explaining the purpose of the loop would be
appreciated. Thanks.
--
Antonin Houska
Cybertec Schönig & Schönig GmbH
Gröhrmühlgasse 26
A-2700 Wiener Neustadt
Web: http://www.postgresql-support.de, http://www.cybertec.at
Commits
-
Correct base backup throttling
- 1861b20cd63b 10.0 landed
- ebd346caf41b 11.0 landed