Program: 21057
Project: 21057
Buggy source:
/** 
 * Enable an experimental feature that will throttle requests made from   {@link BulkMutation}. The logic is as follows: <p> <ul> <li>To start: <ul> <li>reduce parallelism by 50% -- The parallelism is high to begin with. This reduction should reduce the impacts of a bursty job, such as those found in Dataflow. </ul> <li>every 20 seconds: <pre> if (rpc_latency &gt; threshold) { decrease parallelism by 10% of original maximum. } else if (rpc_latency &lt; threshold && rpcsWereThrottled()) { increase parallelism by 5% of original maximum. } </pre> NOTE: increases are capped by the initial maximum.  Decreases are floored at 2.5% of the original maximum so that there is some level of throughput. </ul>
 * @param bulkMutationRpcTargetMs the target for latency of MutateRows requests in milliseconds.
 */
public synchronized void throttle(final int bulkMutationRpcTargetMs){
  if (isThrottling) {
    return;
  }
  LOG.info("String_Node_Str" + "String_Node_Str",bulkMutationRpcTargetMs);
  final long highTargetNanos=TimeUnit.MILLISECONDS.toNanos((long)(bulkMutationRpcTargetMs * 1.2));
  final long lowTargetNanos=TimeUnit.MILLISECONDS.toNanos((long)(bulkMutationRpcTargetMs * 0.8));
  final int throttlingChangeStep=getAbsoluteMaxInFlightRpcs() / 20;
  final int minimumRpcCount=Math.max(throttlingChangeStep / 2,1);
  setCurrentInFlightMaxRpcs(getCurrentInFlightMaxRpcs() / 2);
  Runnable r=new Runnable(){
    @Override public void run(){
      BulkMutationsStats stats=BulkMutationsStats.getInstance();
      long meanLatencyNanos=(long)stats.getMutationTimer().getSnapshot().getMean();
      if (meanLatencyNanos >= highTargetNanos) {
        int current=getCurrentInFlightMaxRpcs();
        int newValue=Math.max(current - throttlingChangeStep,minimumRpcCount);
        if (newValue != current) {
          setCurrentInFlightMaxRpcs(newValue);
          LOG.debug("String_Node_Str",TimeUnit.NANOSECONDS.toMillis(meanLatencyNanos),current,newValue);
        }
      }
 else       if (meanLatencyNanos <= lowTargetNanos && (stats.getThrottlingTimer().getSnapshot().getMean() > TimeUnit.MILLISECONDS.toNanos(1))) {
        int current=getCurrentInFlightMaxRpcs();
        int newValue=Math.max(current + throttlingChangeStep,absoluteMaxInFlightRpcs);
        if (newValue != current) {
          setCurrentInFlightMaxRpcs(newValue);
          LOG.debug("String_Node_Str",TimeUnit.NANOSECONDS.toMillis(meanLatencyNanos),current,newValue);
        }
      }
    }
  }
;
  BigtableSessionSharedThreadPools.getInstance().getRetryExecutor().scheduleAtFixedRate(r,20,20,TimeUnit.SECONDS);
  isThrottling=true;
}

Fixed version (ground truth):
/** 
 * Enable an experimental feature that will throttle requests made from   {@link BulkMutation}. The logic is as follows: <p> <ul> <li>To start: <ul> <li>reduce parallelism by 50% -- The parallelism is high to begin with. This reduction should reduce the impacts of a bursty job, such as those found in Dataflow. </ul> <li>every 20 seconds: <pre> if (rpc_latency &gt; threshold) { decrease parallelism by 10% of original maximum. } else if (rpc_latency &lt; threshold && rpcsWereThrottled()) { increase parallelism by 5% of original maximum. } </pre> NOTE: increases are capped by the initial maximum.  Decreases are floored at 2.5% of the original maximum so that there is some level of throughput. </ul>
 * @param bulkMutationRpcTargetMs the target for latency of MutateRows requests in milliseconds.
 */
public synchronized void throttle(final int bulkMutationRpcTargetMs){
  if (isThrottling) {
    return;
  }
  LOG.info("String_Node_Str" + "String_Node_Str",bulkMutationRpcTargetMs);
  final long highTargetNanos=TimeUnit.MILLISECONDS.toNanos((long)(bulkMutationRpcTargetMs * 1.2));
  final long lowTargetNanos=TimeUnit.MILLISECONDS.toNanos((long)(bulkMutationRpcTargetMs * 0.8));
  final int throttlingChangeStep=getAbsoluteMaxInFlightRpcs() / 20;
  final int minimumRpcCount=Math.max(throttlingChangeStep / 2,1);
  setCurrentInFlightMaxRpcs(getCurrentInFlightMaxRpcs() / 2);
  Runnable r=new Runnable(){
    @Override public void run(){
      BulkMutationsStats stats=BulkMutationsStats.getInstance();
      long meanLatencyNanos=(long)stats.getMutationTimer().getSnapshot().getMean();
      if (meanLatencyNanos >= highTargetNanos) {
        int current=getCurrentInFlightMaxRpcs();
        int newValue=Math.max(current - throttlingChangeStep,minimumRpcCount);
        if (newValue != current) {
          setCurrentInFlightMaxRpcs(newValue);
          LOG.debug("String_Node_Str",TimeUnit.NANOSECONDS.toMillis(meanLatencyNanos),current,newValue);
        }
      }
 else       if (meanLatencyNanos <= lowTargetNanos && (stats.getThrottlingTimer().getSnapshot().getMean() > TimeUnit.MILLISECONDS.toNanos(1))) {
        int current=getCurrentInFlightMaxRpcs();
        int newValue=Math.min(current + throttlingChangeStep,absoluteMaxInFlightRpcs);
        if (newValue != current) {
          setCurrentInFlightMaxRpcs(newValue);
          LOG.debug("String_Node_Str",TimeUnit.NANOSECONDS.toMillis(meanLatencyNanos),current,newValue);
        }
      }
    }
  }
;
  BigtableSessionSharedThreadPools.getInstance().getRetryExecutor().scheduleAtFixedRate(r,20,20,TimeUnit.SECONDS);
  isThrottling=true;
}