Skip to content

Conversation

zolstein
Copy link
Contributor

@zolstein zolstein commented Sep 3, 2025

Check explicitly for context completion in State.Continue to prevent unnecessary work that will inevitably fail.

This also fixes a bug where ExecuteQuery will loop without sleeping until a condition is hit (like MaxTransactionRetryTime or MaxDeadConnections) because the error handling sets skipSleep = true.

Check explicitly for context completion in State.Continue to prevent
unnecessary work that will inevitably fail.

This also fixes a bug where ExecuteQuery will loop without sleeping
until a condition is hit (like MaxTransactionRetryTime or
MaxDeadConnections) because the error handling sets skipSleep = true.
Comment on lines +189 to +192
ctx := context.Background()
ctx, cancel := context.WithTimeout(ctx, 0)
defer cancel()
<-ctx.Done()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This unusual method of cancelling the context causes it ctx.Err() to return "deadline exceeded", which represents a worst-case scenario - without the change to Continue, it will process the error as retryable and loop until it hits the MaxDeadConnections limit. By comparison, just cancelling the context the usual way will fail after one attempt, because the "context cancelled" error isn't retryable.

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