Skip to content

Conversation

@BenoitHugonnard
Copy link
Contributor

What

Currently, when trying to sync over 100k Organization we encounter a 429 error without retrying (Associated issue).

How

This is happening because over 100k organizations, we are querying pages > 1000 and Zendesk has a different API rates for those pages (10 per minutes instead of 700).
I was able to reproduce the issue locally with my company and by just executing the following script

for i in range(15): resp = requests.get( url="https://*********.zendesk.com/api/v2/organizations?start_time=946684800&page=1011", headers=headers, auth=auth ) status_code = resp.status_code is_response = True if resp else False print(status_code, is_response) >>>200 True 200 True 200 True 200 True 200 True 200 True 200 True 200 True 200 True 200 True 429 False 429 False 429 False 429 False 429 False

Recommended reading order

  1. x.java
  2. y.python

🚨 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

  • Community member? Grant edit access to maintainers (instructions)
  • Secrets in the connector's spec are annotated with airbyte_secret
  • Unit & integration tests added and passing. Community members, please provide proof of success locally e.g: screenshot or copy-paste unit, integration, and acceptance test output. To run acceptance tests for a Python connector, follow instructions in the README. For java connectors run ./gradlew :airbyte-integrations:connectors:<name>:integrationTest.
  • Code reviews completed
  • Documentation updated
    • Connector's README.md
    • Connector's bootstrap.md. See description and examples
    • docs/integrations/<source or destination>/<name>.md including changelog. See changelog example
    • docs/integrations/README.md
    • airbyte-integrations/builds.md
  • PR name follows PR naming conventions

Airbyter

If this is a community PR, the Airbyte engineer reviewing this PR is responsible for the below items.

  • Create a non-forked branch based on this PR and test the below items on it
  • Build is successful
  • If new credentials are required for use in CI, add them to GSM. Instructions.
  • /test connector=connectors/<name> command is passing
  • New Connector version released on Dockerhub by running the /publish command described here
  • After the connector is published, connector added to connector index as described here
  • Seed specs have been re-generated by building the platform and committing the changes to the seed spec files, as described here
Updating a connector

Community member or Airbyter

  • Grant edit access to maintainers (instructions)
  • Secrets in the connector's spec are annotated with airbyte_secret
  • Unit & integration tests added and passing. Community members, please provide proof of success locally e.g: screenshot or copy-paste unit, integration, and acceptance test output. To run acceptance tests for a Python connector, follow instructions in the README. For java connectors run ./gradlew :airbyte-integrations:connectors:<name>:integrationTest.
  • Code reviews completed
  • Documentation updated
    • Connector's README.md
    • Connector's bootstrap.md. See description and examples
    • Changelog updated in docs/integrations/<source or destination>/<name>.md including changelog. See changelog example
  • PR name follows PR naming conventions

Airbyter

If this is a community PR, the Airbyte engineer reviewing this PR is responsible for the below items.

  • Create a non-forked branch based on this PR and test the below items on it
  • Build is successful
  • If new credentials are required for use in CI, add them to GSM. Instructions.
  • /test connector=connectors/<name> command is passing
  • New Connector version released on Dockerhub and connector version bumped by running the /publish command described here
Connector Generator
  • Issue acceptance criteria met
  • PR name follows PR naming conventions
  • If adding a new generator, add it to the list of scaffold modules being tested
  • The generator test modules (all connectors with -scaffold in their name) have been updated with the latest scaffold by running ./gradlew :airbyte-integrations:connector-templates:generator:testScaffoldTemplates then checking in your changes
  • Documentation which references the generator is updated as needed

Tests

Unit

Put your unit tests output here.

Integration

Put your integration tests output here.

Acceptance

Put your acceptance tests output here.

@CLAassistant
Copy link

CLAassistant commented Dec 1, 2022

CLA assistant check
All committers have signed the CLA.

@BenoitHugonnard BenoitHugonnard changed the title 🐛 Handle 429 response behavior when trying to retry 🐛 Handle 429 response behavior when retrying Dec 1, 2022
raise original_exception
raise DefaultBackoffException(request=request, response=response)
if response:
if response is not None:
Copy link
Contributor

Choose a reason for hiding this comment

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

@BenoitHugonnard can you explain how this will solve the problem with 429? The change you made doesn't affect any logic.
if response is equal to if response is not None
If I'm not wrong :p

Copy link
Contributor Author

@BenoitHugonnard BenoitHugonnard Dec 7, 2022

Choose a reason for hiding this comment

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

Actually it is the key !

The issue we currently have, is when Zendesk responds with a 429 for organizations, the retry that can only happen if response is never called so Airbyte doesn't wait x seconds before retrying so Uncaught Error (see the associated issue).

The issue is that when we bool check the 429 response we get false but the content is not empty (we still get the headers having the info for the x-retry-after).

If we do this check you'll see :

for i in range(15): resp = requests.get( url="https://*****.zendesk.com/api/v2/organizations?start_time=946684800&page=1011", headers=headers, auth=auth ) status_code = resp.status_code is_response = True if resp is not None else False print(status_code, is_response) >>>200 True 200 True 200 True 200 True 200 True 200 True 200 True 200 True 200 True 200 True 429 True 429 True 429 True 429 True 429 True

Between this and the initial description of the PR, I only changed what I changed in the PR if response turns into if response is not None

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the info @BenoitHugonnard

@marcosmarxm marcosmarxm changed the title 🐛 Handle 429 response behavior when retrying 🐛 Source Zendesk Support: handle 429 response behavior when retrying Dec 7, 2022
@marcosmarxm marcosmarxm requested a review from bazarnov December 8, 2022 19:42
@marcosmarxm
Copy link
Contributor

@bazarnov can you do the final review for this change in Support Zendesk GA connector?

@marcosmarxm marcosmarxm self-assigned this Dec 8, 2022
Copy link
Contributor

@bazarnov bazarnov left a comment

Choose a reason for hiding this comment

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

Make sense, actually! Nice catch!
We didn't face this before, since we don't have lots of data in our sandbox @marcosmarxm

But, still, the version should be bumped and change log should be updated, as well as acceptance tests should pass.

@marcosmarxm will you assist with this?

@marcosmarxm
Copy link
Contributor

marcosmarxm commented Dec 8, 2022

/test connector=connectors/source-zendesk-support

🕑 connectors/source-zendesk-support https://github.com/airbytehq/airbyte/actions/runs/3651988590
❌ connectors/source-zendesk-support https://github.com/airbytehq/airbyte/actions/runs/3651988590
🐛

@marcosmarxm
Copy link
Contributor

marcosmarxm commented Dec 8, 2022

/test connector=connectors/source-zendesk-support

🕑 connectors/source-zendesk-support https://github.com/airbytehq/airbyte/actions/runs/3652034017
✅ connectors/source-zendesk-support https://github.com/airbytehq/airbyte/actions/runs/3652034017
Python tests coverage:

Name Stmts Miss Cover -------------------------------------------------------- source_zendesk_support/__init__.py 2 0 100% source_zendesk_support/streams.py 338 29 91% source_zendesk_support/source.py 56 6 89% -------------------------------------------------------- TOTAL 396 35 91% Name Stmts Miss Cover Missing ---------------------------------------------------------------------------------- source_acceptance_test/base.py 12 4 67% 16-19 source_acceptance_test/config.py 140 5 96% 87, 93, 238, 242-243 source_acceptance_test/conftest.py 208 92 56% 36, 42-44, 49, 54, 77, 83, 89-91, 110, 115-117, 123-125, 131-132, 137-138, 143, 149, 158-167, 173-178, 193, 217, 248, 254, 262-267, 275-280, 288-301, 306-312, 319-330, 337-353 source_acceptance_test/plugin.py 69 25 64% 22-23, 31, 36, 120-140, 144-148 source_acceptance_test/tests/test_core.py 398 111 72% 53, 58, 87-95, 100-107, 111-112, 116-117, 299, 337-354, 363-371, 375-380, 386, 419-424, 462-469, 512-514, 517, 582-590, 602-605, 610, 666-667, 673, 676, 712-722, 735-760 source_acceptance_test/tests/test_incremental.py 158 14 91% 52-59, 64-77, 240 source_acceptance_test/utils/asserts.py 39 2 95% 62-63 source_acceptance_test/utils/common.py 94 10 89% 16-17, 32-38, 72, 75 source_acceptance_test/utils/compare.py 62 23 63% 21-51, 68, 97-99 source_acceptance_test/utils/connector_runner.py 133 33 75% 24-27, 46-47, 50-54, 57-58, 73-75, 78-80, 83-85, 88-90, 93-95, 124-125, 159-161, 208 source_acceptance_test/utils/json_schema_helper.py 107 13 88% 30-31, 38, 41, 65-68, 96, 120, 192-194 ---------------------------------------------------------------------------------- TOTAL 1599 332 79% 

Build Passed

Test summary info:

All Passed 
@BenoitHugonnard
Copy link
Contributor Author

So as this is my first PR, not really sure if I need to do stuff. I don't mind, I'm just not aware of what's expected.

@octavia-squidington-iv octavia-squidington-iv added the area/documentation Improvements or additions to documentation label Dec 9, 2022
@marcosmarxm
Copy link
Contributor

marcosmarxm commented Dec 9, 2022

/publish connector=connectors/source-zendesk-support

🕑 Publishing the following connectors:
connectors/source-zendesk-support
https://github.com/airbytehq/airbyte/actions/runs/3659619110


Connector Did it publish? Were definitions generated?
connectors/source-zendesk-support

if you have connectors that successfully published but failed definition generation, follow step 4 here ▶️

@emilmar
Copy link

emilmar commented Dec 14, 2022

Is there more left to do @marcosmarxm?

Man it made me happy to see this PR. Excited for this to be released! 🙌 I attempted to develop it myself but I could not even get the dev environment to work locally #noob

@marcosmarxm marcosmarxm merged commit c8b48b4 into airbytehq:master Dec 14, 2022
@BenoitHugonnard BenoitHugonnard deleted the fix/zendesk-support-inc-100k-organizations branch December 14, 2022 13:06
@validumitru
Copy link

hey @BenoitHugonnard and @marcosmarxm , we were affected by this issue with the Zendesk connector failing randomly with 429. However after updating to the latest version the sync just hangs. It probably keeps retrying in the background ?

@emilmar
Copy link

emilmar commented Dec 21, 2022

@validumitru Hi, have a look at the latest posts in this thread #14253
You are correct, it keeps retrying in the background but the logs should still update but they're not. I closed that issue because the original issue has been "fixed" and a new one is out, feel free to create a new issue and @me !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/connectors Connector related issues area/documentation Improvements or additions to documentation bounty community connectors/source/zendesk-support

8 participants