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

feat: implement backoff for snowpipe streaming authorization errors #5399

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

shekhar-rudder
Copy link
Member

@shekhar-rudder shekhar-rudder commented Dec 27, 2024

Description

This PR introduces a backoff mechanism when creating channels in the Snowpipe streaming destination. If an authorization error is encountered at the schema, table, or column level, the backoff ensures that we avoid repeatedly attempting to connect to Snowflake unnecessarily.

  • Added a new struct authzBackoff in manager to store backoff related state
  • Refactoring: Added managerCreator as a field in the manager for making the code testable.
  • Until now, any error encountered while creating the channel for the discards table resulted in the job being marked as aborted. In this PR, the behavior has been updated to mark the job as failed, allowing it to be retried.
  • Backoff is applied whenever an authorization error is encountered.
  • Backoff is being cleared whenver channels for all the tables are being created without any authz error

Security

  • The code changed/added as part of this pull request won't create any security issues with how the software is being used.

Copy link

codecov bot commented Dec 27, 2024

Codecov Report

Attention: Patch coverage is 89.02439% with 9 lines in your changes missing coverage. Please review.

Project coverage is 74.80%. Comparing base (8a186e5) to head (b5a1417).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...tionmanager/snowpipestreaming/snowpipestreaming.go 86.36% 4 Missing and 2 partials ⚠️
...yncdestinationmanager/snowpipestreaming/channel.go 80.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5399      +/-   ##
==========================================
- Coverage   74.82%   74.80%   -0.03%     
==========================================
  Files         438      438              
  Lines       61331    61404      +73     
==========================================
+ Hits        45893    45935      +42     
- Misses      12895    12931      +36     
+ Partials     2543     2538       -5     

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

Comment on lines 174 to 175
backoff.WithMaxElapsedTime(0),
backoff.WithMaxInterval(0),
Copy link

@RanjeetMishra RanjeetMishra Jan 2, 2025

Choose a reason for hiding this comment

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

  1. Should we set MaxInterval as say 1 hr? This would mean once issue is resolved around snowflake permissions it will resume working by next 1 hour? Also from correctness perspective, overflow in backoff package is handled as maxInterval.
  2. Are we using cenkalti/backoff/v4 elsewhere as well. I see in v5 pattern of initializing has been changed.

CC: @achettyiitr

Copy link
Member

Choose a reason for hiding this comment

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

Are we using cenkalti/backoff/v4 elsewhere as well. I see in v5 pattern of initializing has been changed.

In rudder-server, we are still using v4. We haven't upgraded to v5 yet.

Copy link
Member Author

Choose a reason for hiding this comment

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

  1. Made MaxInterval as 1hr

Comment on lines 223 to 225
if sfConnectionErr.code == errAuthz {
m.authzBackoff.set()
}

Choose a reason for hiding this comment

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

Would this mean we end up invoking .NextBackoff as many times as size of uploadInfos?

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated the code to set backoff only once

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.

3 participants