Skip to content
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

Source Instagram: fix bug with transient failures #2666

Conversation

yevhenii-ldv
Copy link
Contributor

What

  • Update backoff function for working with transient failures
  • Add clear pagination for media resources to be sure that the backoff will always take place

Pre-merge Checklist

  • Run integration tests
  • Publish Docker images

Recommended reading order

  1. test.java
  2. component.ts
  3. the rest

…ures, added clear pagination for media resources to be sure that the backoff will always take place.
@yevhenii-ldv yevhenii-ldv linked an issue Mar 30, 2021 that may be closed by this pull request
@yevhenii-ldv yevhenii-ldv requested review from keu and vitaliizazmic and removed request for sherifnada and davinchia March 30, 2021 12:21
return getattr(ig_user, attribute)(params=params, fields=fields)

def pagination(self, instance: Cursor) -> Iterator[Any]:
yield from instance._queue
Copy link

Choose a reason for hiding this comment

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

It looks like we can't decorate pagination with backoff without accessing private attributes of the Cursor.
Let's document this approach via comment and insert TODO warning about possible breaking changes in Facebook API implementation.
We can consider creating an issue for facebook_business client.

return instagram_user.get_media(params=params, fields=fields)
media = self.get_instance_cursor(instagram_user, "get_media", params=params, fields=fields)
for media_obj in self.pagination(media):
yield media_obj
Copy link

Choose a reason for hiding this comment

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

_get_media and _get_stories looks identical except "get_*" attribute name string.
We can consider moving get_instance_cursor into pagination and extend pagination parameters, e. g.:

for media_obj in self.pagination("get_media"):
    yield media_obj

Or we can consider having wrapper function for the 3 lines above.

return instagram_user.get_stories(params=params, fields=fields)
stories = self.get_instance_cursor(instagram_user, "get_stories", params=params, fields=fields)
for story_obj in self.pagination(stories):
yield story_obj
Copy link

Choose a reason for hiding this comment

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

Please, see comment regarding _get_media.

Copy link
Contributor

@sherifnada sherifnada left a comment

Choose a reason for hiding this comment

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

Request changes because of worry about a regression

):
return True
return False
return exc.api_transient_error()
Copy link
Contributor

Choose a reason for hiding this comment

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

are you sure that this also applies to rate limiting? I don't see it in docs anywhere. Why not just add this as an OR clause?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I found information that this value also applies to Rate Limiting, but now I could not find it.
To be more safely, I added this check to the general list of errors to be handled using backoff.

Copy link
Contributor

Choose a reason for hiding this comment

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

SGTM

@yevhenii-ldv
Copy link
Contributor Author

yevhenii-ldv commented Mar 31, 2021

/test connector=source-instagram

🕑 source-instagram https://github.com/airbytehq/airbyte/actions/runs/705027840
✅ source-instagram https://github.com/airbytehq/airbyte/actions/runs/705027840

@yevhenii-ldv
Copy link
Contributor Author

yevhenii-ldv commented Mar 31, 2021

/publish connector=connectors/source-instagram

🕑 connectors/source-instagram https://github.com/airbytehq/airbyte/actions/runs/705069883
✅ connectors/source-instagram https://github.com/airbytehq/airbyte/actions/runs/705069883

@yevhenii-ldv
Copy link
Contributor Author

yevhenii-ldv commented Mar 31, 2021

/test connector=source-instagram

🕑 source-instagram https://github.com/airbytehq/airbyte/actions/runs/705112955
✅ source-instagram https://github.com/airbytehq/airbyte/actions/runs/705112955

@yevhenii-ldv yevhenii-ldv merged commit 473034d into master Mar 31, 2021
@yevhenii-ldv yevhenii-ldv deleted the ykurochkin/source-instagram-retry-transient-server-failures branch March 31, 2021 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Source instagram: retry transient server failures
3 participants