Skip to content
This repository was archived by the owner on Dec 22, 2021. It is now read-only.
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/MongoDB/_Topology.pm
Original file line number Diff line number Diff line change
Expand Up @@ -829,6 +829,8 @@ sub _get_server_in_latency_window {
return $in_window[ int( rand(@in_window) ) ]->{server};
}

my $PRIMARY = MongoDB::ReadPreference->new(mode => 'primaryPreferred' );

sub _ping_server {
my ($self, $link) = @_;
return eval {
Expand All @@ -837,7 +839,7 @@ sub _ping_server {
query => [ping => 1],
query_flags => {},
bson_codec => $self->bson_codec,
read_preference => 'primaryPreferred',
read_preference => $PRIMARY,
monitoring_callback => $self->monitoring_callback,
);
$op->execute( $link )->output;
Expand Down Expand Up @@ -1037,8 +1039,6 @@ sub _selection_timeout {
}
}

my $PRIMARY = MongoDB::ReadPreference->new;

sub _generate_ismaster_request {
my ( $self, $link, $should_perform_handshake ) = @_;
my @opts;
Expand Down