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

Create a hook to capture copy batch errors and retries #1507

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

Conversation

grodowski
Copy link

@grodowski grodowski commented Mar 11, 2025

Related issue: #1499

Description

Adds gh-ost-on-batch-copy-retry to hooks.go, which enables dynamic reconfiguration on errors in applyCopyRowsFunc. The use case my team needs is to allow changing the chunk-size in case of binlog cache size limit errors (see issue example), however this hook can be useful in other scenarios too.

In case this PR introduced Go code changes:

  • contributed code is using same conventions as original code
  • script/cibuild returns with no formatting errors, build errors or unit test errors.

grodowski and others added 5 commits March 11, 2025 16:02
CalculateNextIterationRangeEndValues needs to be recomputed on every retry in case of configuration (e.g. chunk-size)
changes were made by onBatchCopyRetry hooks.
@grodowski grodowski marked this pull request as ready for review March 11, 2025 15:40
@Copilot Copilot bot review requested due to automatic review settings March 11, 2025 15:40
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a new hook, gh-ost-on-batch-copy-retry, to allow dynamic reconfiguration on errors during the batch copy phase, enabling retries with adjustments (e.g. changing the chunk size).

  • Adds a new hook constant and a corresponding function in hooks.go
  • Integrates hook execution within the migrator's retry workflow via retryBatchCopyWithHooks
  • Updates documentation and CI configuration to support the new functionality

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
dev.yml Added environment variables and commands for CI configuration
doc/hooks.md Updated hook list and documentation with the new batch copy retry hook
go/logic/hooks.go Added hook constant and implementation for gh-ost-on-batch-copy-retry
go/logic/migrator.go Added retryBatchCopyWithHooks and modified usage in iterateChunks

@@ -77,6 +78,7 @@ func (this *HooksExecutor) applyEnvironmentVariables(extraVariables ...string) [
// executeHook executes a command, and sets relevant environment variables
// combined output & error are printed to the configured writer.
func (this *HooksExecutor) executeHook(hook string, extraVariables ...string) error {
this.migrationContext.Log.Infof("executing hook: %+v", hook)
Copy link
Preview

Copilot AI Mar 11, 2025

Choose a reason for hiding this comment

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

[nitpick] The added logging statement in executeHook duplicates the logging in executeHooks and may lead to redundant log entries. Consider removing one of these log statements to avoid unnecessary duplication.

Suggested change
this.migrationContext.Log.Infof("executing hook: %+v", hook)

Copilot is powered by AI, so mistakes are possible. Review output carefully before use.

Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
desc: Run all the tests.
run: |
export DOCKER_HOST=unix://$(podman machine inspect --format '{{.ConnectionInfo.PodmanSocket.Path}}')
script/test
Copy link
Author

Choose a reason for hiding this comment

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

Specific to Shopify tooling and will be removed.

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.

1 participant