You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 15, 2024. It is now read-only.
When master and secondary has been switched (not down), Moped throw the error for 5 minutes (default refresh time) and failover does not work properly.
Throw Moped::Error::QueryFailure not master
This situation happens:
each replicaset node has priority.
the master went down so secondary became the new primary.
when old master is live again, then old master become master again (mongo switches master and secondary automatically).
I think we can fix this by adding Errors::QueryFailure, reconfiguring_replica_set hook in with_retry (in read_preference/selectable.rb)
def with_retry(cluster, retries = cluster.max_retries, &block)
begin
return block.call
rescue Errors::ConnectionFailure => e
raise e unless retries > 0
rescue Errors::QueryFailure => e
raise e unless retries > 0 && e.reconfiguring_replica_set?
end
Loggable.warn(" MOPED:", "Retrying connection attempt #{retries} more time(s).", "n/a")
sleep(cluster.retry_interval)
cluster.refresh
with_retry(cluster, retries - 1, &block)
end