Re: [HACKERS] pg_basebackup throttling doesn't throttle as promised - Mailing list pgsql-hackers

From Antonin Houska
Subject Re: [HACKERS] pg_basebackup throttling doesn't throttle as promised
Date
Msg-id 5299.1504341173@localhost
Whole thread Raw
In response to Re: [HACKERS] pg_basebackup throttling doesn't throttle as promised  (Jeff Janes <jeff.janes@gmail.com>)
List 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



pgsql-hackers by date:

Previous
From: Noah Misch
Date:
Subject: Re: [HACKERS] Parallel worker error
Next
From: Devrim Gündüz
Date:
Subject: Re: [HACKERS] configure issue - warnings sort: No such file ordirectory