Skip to content

[BUG] EventHub's retry method always adds 4 seconds to a configured delay #38596

Open
@adriannowak

Description

@adriannowak

Describe the bug
EventHub SDK fails to deliver retry messages at configured rate. Seems it just ignores the delay which is set in AmqpRetryOptions.getDelay() and by some reason adds extra time SERVER_BUSY_WAIT_TIME. This property is not configurable, and is always 4 seconds. In a consequence SDK delivers messages slower than it is expected.

Exception or Stack Trace
Add the exception log and stack trace if available
N/A

To Reproduce
Steps to reproduce the behavior:

The following unit test should pass after at most 5 seconds (1 failure + 2 retries + timeout 3x500).
With the latest version of SDK following code takes 16 seconds.

    @Test
    @Timeout(value = 5)
    void withRetryMono() {
        // Arrange
        final String timeoutMessage = "Operation timed out.";
        final AmqpRetryOptions options = new AmqpRetryOptions()
            .setMaxRetries(2)
            .setTryTimeout(Duration.ofMillis(500))
            .setMode(AmqpRetryMode.FIXED);

        final AtomicInteger resubscribe = new AtomicInteger();
        final Mono<AmqpTransportType> neverFlux = TestPublisher.<AmqpTransportType>create().mono()
            .doOnSubscribe(s -> resubscribe.incrementAndGet());

        StepVerifier.create(RetryUtil.withRetry(neverFlux, options, timeoutMessage))
            .expectSubscription()
            .expectErrorSatisfies(error -> assertTrue(error.getCause() instanceof TimeoutException))
            .verify();

        assertEquals(options.getMaxRetries() + 1, resubscribe.get());
    }

Code Snippet
Add the code snippet that causes the issue.

This breaking change was introduced in this PR

https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/core/azure-core-amqp/src/main/java/com/azure/core/amqp/implementation/RetryUtil.java#L109

        final Duration delay = options.getDelay().plus(SERVER_BUSY_WAIT_TIME);

Expected behavior
A clear and concise description of what you expected to happen.

SDK retries the delivery at a configured pace.

        final Duration delay = options.getDelay();

Information Checklist
Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report

  • Bug Description Added
  • Repro Steps Added
  • Setup information Added

Metadata

Metadata

Assignees

Labels

ClientThis issue points to a problem in the data-plane of the library.Event HubsbugThis issue requires a change to an existing behavior in the product in order to be resolved.customer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions