-
Notifications
You must be signed in to change notification settings - Fork 7
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
Add retry logic for COPY operation in SnowflakeCopyBatchInsert with configurable max retries #83
Conversation
…onfigurable max retries - Introduced a new configuration parameter max_copy_retries to specify the maximum number of retries for the COPY operation in Snowflake. - Updated SnowflakeOutputPlugin to include max_copy_retries configuration. - Modified SnowflakeCopyBatchInsert to handle retries for the COPY operation using the newly added parameter. - Added a method isRetryableForCopyTask to determine whether a COPY error is retryable. - Adjusted constructor and method signatures to include maxCopyRetries where necessary. - Ensured proper resource cleanup and retry handling for the COPY task. - Improved logging for retries to provide more context during errors.
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.
LGTM!
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.
Could you add a description of max_copy_retries in the configuration section of README.md, together with max_upload_retries?
Memo: There is already a class in embulk that handles retries. https://dev.embulk.org/embulk-util-retryhelper/0.8.0/javadoc/org/embulk/util/retryhelper/RetryExecutor.html But in the existing code, they're making changes like this one. embulk-output-snowflake/src/main/java/org/embulk/output/snowflake/SnowflakeCopyBatchInsert.java Lines 367 to 405 in 76dc706
|
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 possible, could you add a description of max_copy_retries in the configuration section of README.md, together with max_upload_retries?
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.
The error occurs because the connection that was closed on the second retry is being accessed again.
- Resolved an issue where SnowflakeOutputConnection was prematurely closed during retries in the COPY operation. - Refactored the code to use try-with-resources for managing SnowflakeOutputConnection, ensuring a new connection is created for each retry. - Removed the explicit con.close() call in the finally block, as connections are now safely managed within the retry loop.
…figuration options - Added descriptions for the max_upload_retries and max_copy_retries configuration options in the README. - max_upload_retries: Specifies the maximum number of retries for file uploads to Snowflake. Default value is 3. - max_copy_retries: Specifies the maximum number of retries for COPY operations in Snowflake. Default value is 3. Retries are triggered for transient errors such as communication failures. - Improved documentation to help users understand the retry configurations and their default behaviors.
6054e17
to
7a3f515
Compare
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.
LGTM
@chikamura The issue where the connection was being closed during retries has been addressed in the following commit: The README update has been handled in the following commit: |
Overview
This pull request introduces retry logic for the COPY operation in the
SnowflakeCopyBatchInsert
class and ensures better handling of transient errors during data load processes.Detailed Description
CopyTask
class.max_copy_retries
to allow users to define the maximum number of retry attempts. The default value is set to3
.isRetryableForCopyTask
to classify errors as retryable based on specific error messages (e.g., "JDBC driver encountered communication error").SnowflakeOutputPlugin
to accept and pass the newmax_copy_retries
parameter.Related Issues
This changes addresses potential failures in the COPY operation caused by transient communication errors. Previously, such errors could lead to incomplete data loads without any retry attempts.
Impact
This update ensures better handling of transient errors and increases the likelihood of successful data loads, even under unstable network conditions.
There are no significant breaking changes, as the default value for
max_copy_retries
ensures backward compatibility.Additional Notes