Skip to content

Random jitter is taken for next retry backoff - should be +- 0.2 according to specΒ #2959

@ekscentrysytet

Description

@ekscentrysytet

According to grpc client retries spec - a jitter of +- 0.2 should be taken when calculating next retry delay.

During my tests I've noticed current lib generates random jitters, and after observing source code I can see it's caused by using Math.random() here:

private getNextRetryBackoffMs() {
    const retryPolicy = this.callConfig?.methodConfig.retryPolicy;
    if (!retryPolicy) {
      return 0;
    }
    const nextBackoffMs = Math.random() * this.nextRetryBackoffSec * 1000;
    const maxBackoffSec = Number(
      retryPolicy.maxBackoff.substring(0, retryPolicy.maxBackoff.length - 1)
    );
    this.nextRetryBackoffSec = Math.min(
      this.nextRetryBackoffSec * retryPolicy.backoffMultiplier,
      maxBackoffSec
    );
    return nextBackoffMs;
  }

According to spec following should be used:

const nextBackoffMs = random(0.8, 1.2) * this.nextRetryBackoffSec * 1000;

Please confirm is this is expected

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions