Skip to content

fix(delivery): wait one backoff delay before the first linear retry - #9425

Merged
knative-prow[bot] merged 1 commit into
knative:mainfrom
kahirokunn:fix/linear-backoff-first-retry
Oct 26, 2026
Merged

knative-prow[bot] merged 1 commit into
knative:mainfrom
kahirokunn:fix/linear-backoff-first-retry

Conversation

@kahirokunn

@kahirokunn kahirokunn commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

Fixes #

With backoffPolicy: linear the first retry is sent immediately, without waiting at all.

go-retryablehttp calls Backoff with a zero-based attempt number (0 is the wait before the first retry), but linearBackoff returned delay * attemptNum, so attempt 0 gave 0. Exponential isn't affected, it already waits backoffDelay first. With backoffDelay: PT1S the waits between attempts were 0s, 1s, 2s for linear and are 1s, 2s, 3s now.

The intended behavior from #4232 / #4240 is backoffDelay * <numberOfRetries>. The existing tests didn't catch it because they called Backoff starting from 1, which isn't what retryablehttp does.

Proposed Changes

  • 🐛 Make linearBackoff return delay * (attemptNum + 1) so the first retry waits backoffDelay

This means every retry with the linear policy waits one backoffDelay longer than before. Anything calling RetryConfig.Backoff directly with a one-based number gets a result one step too large for linear.

Pre-review Checklist

  • At least 80% unit test coverage
  • E2E tests for any new behavior
  • Docs PR for any user-facing impact
  • Spec PR for any new API feature
  • Conformance test for any change to the spec

Release Note

The linear backoff policy now waits one `backoffDelay` before the first retry instead of retrying immediately, and each later retry waits one `backoffDelay` longer than before.

Docs

@knative-prow knative-prow Bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Oct 13, 2026
@knative-prow
knative-prow Bot requested review from Cali0707 and pierDipi October 13, 2026 18:04
@codecov

codecov Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 66.66667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 51.33%. Comparing base (ba23316) to head (821361d).
⚠️ Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
pkg/kncloudevents/retries.go 66.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #9425   +/-   ##
=======================================
  Coverage   51.33%   51.33%           
=======================================
  Files         411      411           
  Lines       22187    22187           
=======================================
  Hits        11389    11389           
  Misses       9916     9916           
  Partials      882      882           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

kahirokunn added a commit to kahirokunn/eventing-natss that referenced this pull request Oct 13, 2026
…ring

The JetStream channel CRD describes the exponential policy as
backoffDelay*2^<numberOfRetries>, but since the retry attempt numbering
was aligned with Knative's zero-based callback, the first retry waits
backoffDelay (2^0) rather than 2*backoffDelay. Describe it as
backoffDelay*2^(<numberOfRetries>-1) with <numberOfRetries> being
one-based.

This mirrors the wording change in knative/eventing#9425. The linear
sentence is unchanged: it becomes accurate for the first retry once that
PR is picked up.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: kahirokunn <okinakahiro@gmail.com>
kahirokunn added a commit to kahirokunn/eventing-natss that referenced this pull request Oct 13, 2026
The CRD documents the linear policy as backoffDelay*<numberOfRetries>, so
the first retry should wait one backoffDelay and the second two. The
vendored knative.dev/eventing still returns 0 for the first linear retry
(attemptNum 0), so these two rows fail until knative/eventing#9425 is
picked up. They are added ahead of that dependency update on purpose so
the intended behavior is pinned down; verified that they pass when the
#9425 linearBackoff change is applied to the vendored copy.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: kahirokunn <okinakahiro@gmail.com>
@kahirokunn
kahirokunn force-pushed the fix/linear-backoff-first-retry branch 3 times, most recently from 801e64c to 46778b2 Compare October 14, 2026 13:34
Signed-off-by: kahirokunn <okinakahiro@gmail.com>
@kahirokunn
kahirokunn force-pushed the fix/linear-backoff-first-retry branch from 46778b2 to 821361d Compare October 14, 2026 13:54
@dsimansk

Copy link
Copy Markdown
Contributor

/retest

@kahirokunn

Copy link
Copy Markdown
Member Author

CI is failing due to an issue on the Kafka side. 😢

properties:
backoffDelay:
description: 'BackoffDelay is the delay before retrying. More information on Duration format: - https://www.iso.org/iso-8601-date-and-time-format.html - https://en.wikipedia.org/wiki/ISO_8601 For linear policy, backoff delay is backoffDelay*<numberOfRetries>. For exponential policy, backoff delay is backoffDelay*2^<numberOfRetries>.'
description: 'BackoffDelay is the delay before retrying. More information on Duration format: - https://www.iso.org/iso-8601-date-and-time-format.html - https://en.wikipedia.org/wiki/ISO_8601 For linear policy, backoff delay is backoffDelay*<numberOfRetries>. For exponential policy, backoff delay is backoffDelay*2^(<numberOfRetries>-1).'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kahirokunn iiuc the scope of this PR is mostly fixing the linear retry logic. What is the reason for changing the exponential backoff docs in this PR as well?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Cali0707
Thanks for your review 🙏
I included this to use one-based retry numbering consistently in both formulas. Exponential already starts at backoffDelay , so this only corrects the docs without changing behavior.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Cali0707 we came to the conclusion docs we not accurate based on a parallel review for backoff delay logic.

@dsimansk

Copy link
Copy Markdown
Contributor

/approve
/lgtm

@knative-prow knative-prow Bot added the lgtm Indicates that a PR is ready to be merged. label Oct 26, 2026
@knative-prow

knative-prow Bot commented Oct 26, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dsimansk, kahirokunn

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow knative-prow Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 26, 2026
@knative-prow
knative-prow Bot merged commit 23211b7 into knative:main Oct 26, 2026
52 of 55 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants