You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by "1991santhu (via GitHub)" <gi...@apache.org> on 2026/08/04 19:10:32 UTC
[PR] [Improve][Connector-V2][Airtable] Add jitter to rate-limit backoff [seatunnel]
1991santhu opened a new pull request, #11654:
URL: https://github.com/apache/seatunnel/pull/11654
### Purpose of this pull request
`calculateBackoffMillis` returns a pure function of the retry count:
```java
long exponential = 1L << Math.min(20, Math.max(0, retryCount - 1));
long waitMillis = rateLimitBackoffMs * exponential;
return Math.min(waitMillis, MAX_BACKOFF_MILLIS);
```
so every reader and writer waits for exactly the same durations.
That matters more here than for a generic retry, because this backoff fires specifically on **HTTP 429**:
```java
if (response.getCode() == STATUS_TOO_MANY_REQUESTS && retryCount < rateLimitMaxRetries) {
```
Airtable rate-limits per base, so 429 is a *shared* condition rather than a per-client accident. Parallel readers or writers against the same base cross the limit together, then retry at identical instants — so the burst that caused the rate limiting reassembles on each attempt, and the retries arrive when the API has just asked the client to slow down.
### Changes
Equal jitter: retain half the computed delay as a floor, randomise the remainder.
```java
long half = waitMillis / 2;
return half + ThreadLocalRandom.current().nextLong(waitMillis - half + 1);
```
Half is kept rather than using full jitter so a retry is never issued immediately after a 429. The result never exceeds the previous value or `MAX_BACKOFF_MILLIS`, so no caller waits longer than it does today — the change only removes the alignment.
The disabled case is untouched: `rateLimitBackoffMs <= 0` still returns `0L`.
Applied to both `AirtableSourceReader` and `AirtableSinkWriter`, which carry identical copies of the method.
### Does this PR introduce _any_ user-facing change?
No configuration or API change. Retry delays now vary within `[wait/2, wait]` instead of being exactly `wait`.
### How was this patch tested?
`mvn test -pl seatunnel-connectors-v2/connector-http/connector-http-airtable` — **9 tests pass**, including the existing `testRetryOn429ThenSuccess` and `testStopRetryAfterMaxRetries`, which are unmodified.
Four new tests cover: backoff stays `0` when disabled; every result falls within `[expected/2, expected]` across retries 1–5 sampled 200 times each; successive calls vary, which fails if the implementation regresses to deterministic; and the result never exceeds `MAX_BACKOFF_MILLIS`.
### Check list
* [x] Code changed are covered with tests
* [x] If any new Jar binary package adding in your PR, please add License Notice according [New License Guide](https://github.com/apache/seatunnel/blob/dev/docs/en/contribution/new-license.md) — no new dependencies added
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Improve][Connector-V2][Airtable] Add jitter to rate-limit backoff [seatunnel]
Posted by "1991santhu (via GitHub)" <gi...@apache.org>.
1991santhu commented on PR #11654:
URL: https://github.com/apache/seatunnel/pull/11654#issuecomment-5184517576
Adding a measurement rather than leaving this as an argument.
I simulated the arrival times this backoff produces for 100 parallel readers and writers that hit the Airtable rate limit together — which is the normal case, since a parallel job's subtasks share one quota and so cross it at the same moment. The metric is the peak number of requests landing inside any 1s window.
Parameters are the connector's defaults: `rate_limit_backoff_ms=30000`, `rate_limit_max_retries=3`, `MAX_BACKOFF_MILLIS=300000`, giving 30s, 60s, 120s.
```
attempt none equal added
1 100.0 13.2 8.4
2 100.0 8.7 6.1
3 100.0 5.8 4.3
```
Without jitter all 100 subtasks retry in the same second at every attempt, and the peak never decays — a deterministic delay preserves the correlation that caused the 429 in the first place, so each retry round re-forms the burst. With the jitter in this PR the first retry peaks at ~8 and falls to ~4, a **12x reduction rising to 23x**.
The `equal` column is equal jitter. It decorrelates less, and it would retry sooner than `rate_limit_backoff_ms` was set to — which is the substantive problem when the delay exists to respect a rate limiter, so the jitter is added rather than centred.
Being straight about what this is: a simulation of the arrival process, not a production incident report. I have not observed this against Airtable and am not claiming anyone has — it quantifies the mechanism the code implies. Dependency-free Go, happy to attach.
```
go run . -clients=100 -schedule=30s,60s,120s -cap=300s -floor=30s -window=1s
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Improve][Connector-V2][Airtable] Add jitter to rate-limit backoff [seatunnel]
Posted by "davidzollo (via GitHub)" <gi...@apache.org>.
davidzollo commented on PR #11654:
URL: https://github.com/apache/seatunnel/pull/11654#issuecomment-5192160763
Thanks for your contribution! This is a solid addition to the project, and your attention to detail really shows. Contributors like you are what keep this community moving forward. Feel free to keep the PRs coming — we're always glad to have you here!
Please ignore the following message if you have joined in the Slack~
```
To facilitate focused communication among contributors, we’ve created a brand-new dedicated #contributors channel in official Slack workspace.
Slack workspace link: https://s.apache.org/seatunnel-slack
This channel is designed for technical discussions, feature design brainstorming, roadmap sync and direct communication with project core Contributors. Everyone who contributes code, docs, test cases or community ideas is warmly invited to join, share thoughts and collaborate together under The Apache Way. Welcome to join 😄
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Improve][Connector-V2][Airtable] Add jitter to rate-limit backoff [seatunnel]
Posted by "1991santhu (via GitHub)" <gi...@apache.org>.
1991santhu commented on PR #11654:
URL: https://github.com/apache/seatunnel/pull/11654#issuecomment-5203222809
Good catch, and you are right that it predates the last commit.
Fixed by flooring at the last scheduled wait that still fitted under the cap, rather than half the cap. With a 100000ms base that is 200000, so the capped retries now draw [200000, 300000] instead of [150000, 300000] and the minimum stops dipping.
It also made the method simpler. The rate_limit_backoff_ms special case is gone, since the last uncapped wait is never smaller than the configured backoff, so that guarantee falls out for free now.
I went with option A rather than documenting it. The previous scheduled wait is derivable from the retry count, so it stays a pure function with no state to carry.
Test added in both classes. I checked it fails on the old code first, where retry 3 drew 193352 against retry 2's guaranteed 200000.
20 tests pass on JDK 11.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Improve][Connector-V2][Airtable] Add jitter to rate-limit backoff [seatunnel]
Posted by "1991santhu (via GitHub)" <gi...@apache.org>.
1991santhu commented on PR #11654:
URL: https://github.com/apache/seatunnel/pull/11654#issuecomment-5183575495
Correcting my own patch before review time goes into it.
The first revision used equal jitter, returning a value in `[wait/2, wait]`. Since this backoff fires specifically on HTTP 429, halving it means retrying a rate-limited API **sooner** than `rateLimitBackoffMs` was configured for — which works against the purpose of the setting.
The jitter is now added rather than centred:
```java
long extra = Math.min(waitMillis, MAX_BACKOFF_MILLIS - waitMillis);
if (extra <= 0) {
return waitMillis;
}
return waitMillis + ThreadLocalRandom.current().nextLong(extra + 1);
```
so the result is in `[wait, min(2*wait, MAX_BACKOFF_MILLIS)]` — never shorter than configured, still capped.
Decorrelation is unaffected: what matters is that clients differ from one another, not which direction they differ in.
Tests updated to assert the new bounds. `mvn test -pl seatunnel-connectors-v2/connector-http/connector-http-airtable` still passes 9/9, with the pre-existing 429 tests unmodified.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Improve][Connector-V2][Airtable] Add jitter to rate-limit backoff [seatunnel]
Posted by "davidzollo (via GitHub)" <gi...@apache.org>.
davidzollo merged PR #11654:
URL: https://github.com/apache/seatunnel/pull/11654
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Improve][Connector-V2][Airtable] Add jitter to rate-limit backoff [seatunnel]
Posted by "1991santhu (via GitHub)" <gi...@apache.org>.
1991santhu commented on PR #11654:
URL: https://github.com/apache/seatunnel/pull/11654#issuecomment-5183753678
Pushed a correction to my own patch — the first revision missed the case where the backoff matters most.
I bounded the added jitter by the headroom to `MAX_BACKOFF_MILLIS`. At the maximum that headroom is zero, so the wait came back unjittered, and every retry past the point where the sequence tops out put concurrent readers and writers back into lockstep — precisely when the rate limit is at its most persistent. The original patch spread the early retries and left the late ones exactly as they were.
The wait is now spread downwards once there is nothing left to add into:
```java
long floor = Math.max(waitMillis / 2, rateLimitBackoffMs);
if (floor >= waitMillis) {
return waitMillis;
}
return waitMillis - ThreadLocalRandom.current().nextLong(waitMillis - floor + 1);
```
On the direction: `MAX_BACKOFF_MILLIS` is an upper bound rather than a target, so drawing below it breaks nothing. `rate_limit_backoff_ms` is the opposite — it is the wait Airtable's 429 handling is configured around, and the comment above this method promises the wait is never shorter than it asked for. So the downward spread is floored there rather than at half the interval. That floor binds whenever `rate_limit_backoff_ms` is above half the maximum, and there is a test for it.
Reachability at the defaults: `rate_limit_backoff_ms=30000` and `rate_limit_max_retries=3` top out at 120s, below the 300s maximum, so the default configuration never reaches the saturated case. It needs `rate_limit_max_retries >= 5`. Configurable, so worth fixing, but I want to be straight that this is not a default-path bug.
Applied to both `AirtableSourceReader` and `AirtableSinkWriter`, which carry the same method.
Verified with JDK 11:
```
./mvnw -o test -pl seatunnel-connectors-v2/connector-http/connector-http-airtable \
-Dtest='AirtableSourceReaderTest,AirtableSinkWriterTest'
Tests run: 8, Failures: 0, Errors: 0, Skipped: 0 - AirtableSourceReaderTest
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0 - AirtableSinkWriterTest
BUILD SUCCESS
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Improve][Connector-V2][Airtable] Add jitter to rate-limit backoff [seatunnel]
Posted by "1991santhu (via GitHub)" <gi...@apache.org>.
1991santhu commented on PR #11654:
URL: https://github.com/apache/seatunnel/pull/11654#issuecomment-5192840167
Thanks, this is a genuinely good catch and all five are addressed.
**Issue 1, the dead zone.** You're right, and it's the worst case to get wrong. With `rate_limit_backoff_ms >= MAX_BACKOFF_MILLIS`, `waitMillis` is pinned to the cap from the first retry, `floor` becomes `>= waitMillis`, and the method returned the cap with no jitter. So the operators running the most conservative backoff, the ones most likely to be sitting in sustained rate limiting, got the old lockstep behaviour back.
Took your Option A. The floor is half the wait, raised to `rate_limit_backoff_ms` only when that is below the wait:
```java
long floor = waitMillis / 2;
if (rateLimitBackoffMs > floor && rateLimitBackoffMs < waitMillis) {
floor = rateLimitBackoffMs;
}
```
Once the cap has pushed the wait under the configured backoff, that guarantee cannot be honoured anyway, so flooring there only removed the jitter.
There's a regression test for it. I checked it fails on the old code first, with `observed only [300000]`.
**Issue 2, the description.** Also right, and I should have caught that when the approach changed. The description still described the equal-jitter version that got replaced. Rewritten to state the shipped behaviour and the actual worst case: with the defaults, 210000ms across three retries becomes 420000ms until the cap absorbs it. I've called that out explicitly for anyone tuning against checkpoint timeouts.
**Issue 4, sink coverage.** Mirrored all seven jitter tests into `AirtableSinkWriterTest`, which had none despite carrying a byte-for-byte copy of the method. Agreed that extracting the duplicate into one shared helper is the better long-term answer; I've left that out of this PR to keep the diff focused, happy to follow up.
**Issues 3 and 5.** Blank line removed from the `java.*` import group and `spotless:apply` run. Comment corrected, the range at retry 3 with a 1000ms base is `[4000, 8000]`, not 2000ms wide.
18 tests pass across both classes on JDK 11.
On CI: Actions are not enabled on my fork, which is why there's no Build signal. I'll get that sorted so there's a real run against this branch.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Improve][Connector-V2][Airtable] Add jitter to rate-limit backoff [seatunnel]
Posted by "davidzollo (via GitHub)" <gi...@apache.org>.
davidzollo commented on PR #11654:
URL: https://github.com/apache/seatunnel/pull/11654#issuecomment-5191940621
Good job.
Thanks a lot for your valuable contribution to Apache SeaTunnel!
To pass the automated CI checks for this PR, could you please enable CI workflows in your forked repository first? You can refer to the check run link below as a reference for the required CI configuration https://github.com/apache/seatunnel/pull/11654/checks?check_run_id=92112091125
If you run into any trouble enabling CI or encounter related errors during the process, feel free to leave a comment here. Contributors are always ready to offer help~
<img width="2412" height="1472" alt="image" src="https://github.com/user-attachments/assets/6abd2ea1-da45-4d78-a81c-0158f2d7a851" />
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org