Improve handling a changing target throttle rate mid-compaction

patch by J.B. Langston; reviewed by jbellis for CASSANDRA-5087
This commit is contained in:
Jonathan Ellis 2012-12-27 09:32:38 -05:00
parent 6018709abf
commit 3d01ec7e75
2 changed files with 12 additions and 3 deletions

View File

@ -1,4 +1,5 @@
1.1.9
* Improve handling a changing target throttle rate mid-compaction (CASSANDRA-5087)
* fix multithreaded compaction deadlock (CASSANDRA-4492)
* fix specifying and altering crc_check_chance (CASSANDRA-5053)
* Don't expire columns sooner than they should in 2ndary indexes (CASSANDRA-5079)

View File

@ -52,7 +52,7 @@ public class Throttle
throttleDelta(currentBytes - bytesAtLastDelay);
}
/** @param bytesDelta Bytes of throughput since the last call to throttle*(). */
/** @param bytesDelta Bytes of throughput since the last call to throttle*() */
public void throttleDelta(long bytesDelta)
{
int newTargetBytesPerMS = fun.targetThroughput();
@ -60,10 +60,18 @@ public class Throttle
// throttling disabled
return;
// if the target changed, log
if (newTargetBytesPerMS != targetBytesPerMS)
{
// restart throttling based on the new target to avoid getting bogus answers based on comparing
// the rate under the old throttle, with the desired rate under the new. (If the new rate is higher
// than the old, it doesn't much matter, but if the new rate is lower, it would result in a long
// sleep to bring the average down. See CASSANDRA-5087.)
logger.debug("{} target throughput now {} bytes/ms.", this, newTargetBytesPerMS);
targetBytesPerMS = newTargetBytesPerMS;
targetBytesPerMS = newTargetBytesPerMS;
bytesAtLastDelay += bytesDelta;
timeAtLastDelay = System.currentTimeMillis();
return;
}
// time passed since last delay
long msSinceLast = System.currentTimeMillis() - timeAtLastDelay;