-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Add Retry Logic to Airbyte API calls. #19693
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
airbyte-workers/src/main/java/io/airbyte/workers/temporal/TemporalAttemptExecution.java
Outdated
Show resolved
Hide resolved
… all the spots we call the api.
I have confirmed this fix works. See https://github.com/airbytehq/oncall/issues/1079#issuecomment-1324451000 for more info. Going to leave this open when I explore a cleaner fix. |
final JobIdRequestBody id = new JobIdRequestBody(); | ||
id.setId(Long.valueOf(jobRunConfig.getJobId())); | ||
final var jobScope = airbyteApiClient.getJobsApi().getJobInfo(id).getJob().getConfigId(); | ||
final var jobScope = AirbyteApiClient.retryWithJitter( | ||
() -> airbyteApiClient.getJobsApi().getJobInfo(id).getJob().getConfigId(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pmossman I feel like we can switch this to getJobInfoLight?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If so, will do in a follow up PR.
final var jobScope = airbyteApiClient.getJobsApi().getJobInfo(id).getJob().getConfigId(); | ||
|
||
final var jobScope = AirbyteApiClient.retryWithJitter( | ||
() -> airbyteApiClient.getJobsApi().getJobInfo(id).getJob().getConfigId(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here too
PTAL @pmossman @xiaohansong ended up going with the hand-rolled solution for the reasons in the PR description. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor comments, otherwise LGTM
airbyte-api/src/main/java/io/airbyte/api/client/AirbyteApiClient.java
Outdated
Show resolved
Hide resolved
saveWorkflowIdForCancellation(airbyteApiClient); | ||
AirbyteApiClient.retryWithJitter(() -> { | ||
saveWorkflowIdForCancellation(airbyteApiClient); | ||
return null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we remove this return null?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I looked into this and I think the alternatives are messier.
We can turn the interface into a Runnable, which doesn't expect an return value. However Runnables do not support checked exceptions, which means we would have to catch and recast the exception thrown by saveWorkflowIdForCancellation
into a RTE.
Given that, I think it's simpler to keep this as is!
If you have a suggestion, I'm happy to edit this!
What
Today we often see
HTTP/1.1 header parser received no bytes'
during syncs, especially in the Data Plane.This PR attempts to fix this by adding naive retries.
If this works, we will explore using a more fully featured HTTP Client. I will not merge this in.It turns out this is the best way for what we are trying to do. More details in How section.
How
Add a basic retry wrapper with the unique ability to retry for a much longer period on the last retry. This is particularly useful for us as most of our jobs are long running workflows, and the benefit of not having to restart the entire job outweighs the added wait time.
Alternative solutions I explored:
Since the hand-rolled wrapper is simple + gets the job done, my thoughts are to run with this for the time being and revisit this if additional requirements around the clients come up.
Recommended reading order
AirbyteApiClient.java
for implementation andAirbyteApiClientTest.java
for tests.🚨 User Impact 🚨
Are there any breaking changes? What is the end result perceived by the user? If yes, please merge this PR with the 🚨🚨 emoji so changelog authors can further highlight this if needed.
Pre-merge Checklist
Expand the relevant checklist and delete the others.
New Connector
Community member or Airbyter
airbyte_secret
./gradlew :airbyte-integrations:connectors:<name>:integrationTest
.README.md
bootstrap.md
. See description and examplesdocs/integrations/<source or destination>/<name>.md
including changelog. See changelog exampledocs/integrations/README.md
airbyte-integrations/builds.md
Airbyter
If this is a community PR, the Airbyte engineer reviewing this PR is responsible for the below items.
/test connector=connectors/<name>
command is passing/publish
command described hereUpdating a connector
Community member or Airbyter
airbyte_secret
./gradlew :airbyte-integrations:connectors:<name>:integrationTest
.README.md
bootstrap.md
. See description and examplesdocs/integrations/<source or destination>/<name>.md
including changelog. See changelog exampleAirbyter
If this is a community PR, the Airbyte engineer reviewing this PR is responsible for the below items.
/test connector=connectors/<name>
command is passing/publish
command described hereConnector Generator
-scaffold
in their name) have been updated with the latest scaffold by running./gradlew :airbyte-integrations:connector-templates:generator:testScaffoldTemplates
then checking in your changesTests
Unit
Put your unit tests output here.
Integration
Put your integration tests output here.
Acceptance
Put your acceptance tests output here.