Skip to content

Commit 10238fa

Browse files
committed
Fix base backup rate limiting in presence of slow i/o
When source i/o on disk was too slow compared to the rate limiting specified, the system could end up with a negative value for sleep that it never got out of, which caused rate limiting to effectively be turned off. Discussion: https://postgr.es/m/CABUevEy_-e0YvL4ayoX8bH_Ja9w%2BBHoP6jUgdxZuG2nEj3uAfQ%40mail.gmail.com Analysis by me, patch by Antonin Houska
1 parent cc07e06 commit 10238fa

File tree

1 file changed

+7
-17
lines changed

1 file changed

+7
-17
lines changed

src/backend/replication/basebackup.c

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1370,26 +1370,16 @@ throttle(size_t increment)
13701370
if (wait_result & WL_LATCH_SET)
13711371
CHECK_FOR_INTERRUPTS();
13721372
}
1373-
else
1374-
{
1375-
/*
1376-
* The actual transfer rate is below the limit. A negative value
1377-
* would distort the adjustment of throttled_last.
1378-
*/
1379-
wait_result = 0;
1380-
sleep = 0;
1381-
}
13821373

13831374
/*
1384-
* Only a whole multiple of throttling_sample was processed. The rest will
1385-
* be done during the next call of this function.
1375+
* As we work with integers, only whole multiple of throttling_sample was
1376+
* processed. The rest will be done during the next call of this function.
13861377
*/
13871378
throttling_counter %= throttling_sample;
13881379

1389-
/* Once the (possible) sleep has ended, new period starts. */
1390-
if (wait_result & WL_TIMEOUT)
1391-
throttled_last += elapsed + sleep;
1392-
else if (sleep > 0)
1393-
/* Sleep was necessary but might have been interrupted. */
1394-
throttled_last = GetCurrentIntegerTimestamp();
1380+
/*
1381+
* Time interval for the remaining amount and possible next increments
1382+
* starts now.
1383+
*/
1384+
throttled_last = GetCurrentIntegerTimestamp();
13951385
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy