This repository has been archived by the owner on Jan 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 151
2.0.0 fix retries operations #315
Closed
wandenberg
wants to merge
9
commits into
mongoid:master
from
wandenberg:2.0.0-fix_retries_operations
Closed
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
2addb92
add support to operation timeout, stopping long queries
wandenberg 9447805
move with_retry method to a different module
wandenberg d6ea5f6
retry the operation if the failure was due to a cluster reconfigurati…
wandenberg bff8f65
retry operation and refresh authentication if the failure was related…
wandenberg 0d3d0ed
remove popen4 gem
wandenberg d5ce741
improve replicaset environment checks
wandenberg 7db9e70
try to do tests more stable
wandenberg 7942b91
change the command to make mongod sleep
wandenberg 1dc8ca5
refactor to operation timeout work with SSL connections
wandenberg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# encoding: utf-8 | ||
module Moped | ||
# Provides the shared behaviour for retry failed operations. | ||
# | ||
# @since 2.0.0 | ||
module Retryable | ||
|
||
private | ||
|
||
# Execute the provided block on the cluster and retry if the execution | ||
# fails. | ||
# | ||
# @api private | ||
# | ||
# @example Execute with retry. | ||
# preference.with_retry(cluster) do | ||
# cluster.with_primary do |node| | ||
# node.refresh | ||
# end | ||
# end | ||
# | ||
# @param [ Cluster ] cluster The cluster. | ||
# @param [ Integer ] retries The number of times to retry. | ||
# | ||
# @return [ Object ] The result of the block. | ||
# | ||
# @since 2.0.0 | ||
def with_retry(cluster, retries = cluster.max_retries, &block) | ||
begin | ||
block.call | ||
rescue Errors::ConnectionFailure, Errors::PotentialReconfiguration => e | ||
raise e if e.is_a?(Errors::PotentialReconfiguration) && | ||
!(e.message.include?("not master") || e.message.include?("not authorized") || e.message.include?("unauthorized")) | ||
|
||
if retries > 0 | ||
Loggable.warn(" MOPED:", "Retrying connection attempt #{retries} more time(s).", "n/a") | ||
sleep(cluster.retry_interval) | ||
cluster.refresh | ||
cluster.refresh_authentication if e.message.include?("not authorized") || e.message.include?("unauthorized") | ||
with_retry(cluster, retries - 1, &block) | ||
else | ||
raise e | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I've run load tests against application backed by local replica-set. During those tests I was killing or steppingDown nodes multiple times. It all worked fine except one exception:
Sometimes when killing node it replies with error: 11600 interrupted at shutdown. I think in case of this error we should retry as well.
As a side note it would be nice to have error recognition in one place, but this probably isn't a concern for this pull-request.