-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: 5.2.0, 5.2.1
-
Component/s: None
-
None
In the example below, we can see that `col1.first` reads from port 20001 (secondary) and that's considered correct. After we clone col1, pretty print shows same options (notice `:mode` becoming `"mode"`), but `col1.clone.first` reads from port 20000, which is assigned to the primary. The same thing happens if we do `col1.where(anything)` since `.where` internally clones the selection.
```ruby
[152] app(PROD)> col1
=> #<Mongoid::Criteria
selector:
options: {:read=>{:mode=>:secondary}}
class: External::User
embedded: false>
[153] app(PROD)> col1.first;
MONGODB | 127.0.0.1:20001 | production_users_2.find | STARTED | {"find"=>"users", "filter"=>{"app_id"=>6}
, "limit"=>1, "singleBatch"=>true}
MONGODB | 127.0.0.1:20001 | production_users_2.find | SUCCEEDED | 0.0020012600000000004s
[155] app(PROD)> col1.clone
=> #<Mongoid::Criteria
selector:
options: {:read=>{"mode"=>:secondary}}
class: External::User
embedded: false>
[156] app(PROD)> col1.clone.first
MONGODB | 127.0.0.1:20000 | production_users_2.find | STARTED | {"find"=>"users", "filter"=>{"app_id"=>6}
, "limit"=>1, "singleBatch"=>true}
MONGODB | 127.0.0.1:20000 | production_users_2.find | SUCCEEDED | 0.002215638s
```