-
Notifications
You must be signed in to change notification settings - Fork 533
RUBY-1174 RUBY-1178 Update Max Staleness implementation #836
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
RUBY-1174 RUBY-1178 Update Max Staleness implementation #836
Conversation
| unless @max_staleness > 0 && | ||
| @max_staleness >= [ SMALLEST_MAX_STALENESS_SECONDS, | ||
| (heartbeat_frequency + Cluster::IDLE_WRITE_PERIOD_SECONDS) ].max | ||
| raise Error::InvalidServerPreference.new(Error::InvalidServerPreference::INVALID_MAX_STALENESS) |
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.
Consider giving more detail in this error. See https://github.com/mongodb/mongo-java-driver/blob/master/driver-core/src/main/com/mongodb/TaggableReadPreference.java#L196-L203 for example
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.
done
| raise Error::InvalidServerPreference.new(Error::InvalidServerPreference::INVALID_MAX_STALENESS) | ||
| if @max_staleness | ||
| heartbeat_frequency = cluster.options[:heartbeat_frequency] || Server::Monitor::HEARTBEAT_FREQUENCY | ||
| unless @max_staleness > 0 && |
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 @max_staleness > 0 check is redundant, since the next check is checking that it's at least >= 90
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.
done
| if @max_staleness < heartbeat_frequency * 2 | ||
| raise Error::InvalidServerPreference.new(Error::InvalidServerPreference::INVALID_MAX_STALENESS) | ||
| if @max_staleness | ||
| heartbeat_frequency = cluster.options[:heartbeat_frequency] || Server::Monitor::HEARTBEAT_FREQUENCY |
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.
Rename to heartbeat_frequency_seconds to clarify that it's the right time unit.
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.
done
| validate_max_staleness_value!(cluster) | ||
| select(cluster.servers) | ||
| servers = cluster.servers | ||
| validate_max_staleness_value!(cluster) unless servers.empty? |
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.
Does cluster.servers include only the connected servers? If so, I'm not clear how ReplicaSetNoPrimary/NoKnownServers.yml is passing.
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.
ReplicaSetNoPrimary/NoKnownServers.yml was added after my day ended yesterday so was not in this PR.
I've just updated them to the latest, was failing ReplicaSetNoPrimary/NoKnownServers.yml but then changed the code to do the check unless Topology type is Unknown.
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.
done
…ogy type is Unknown
|
@jyemin, I've addressed all comments. If you could review one more time, that'd be great. |
|
LGTM |
|
@jarthod Do you want to take a look at this as well to verify unit conversions? |
|
Looks good to me too ;) |
|
thanks @jarthod = ) |
No description provided.