I sent this issue to MongoID github repository. Durran told me it is an issue in the Ruby driver, so I post it here.
- - foo
- - bar
foo is the primary, bar is secondary, other nodes are hidden.
When I start the application, writes go to foo, reads go to bar. This is fine.
Then I stop mongodb on bar.
Writes go to foo and reads go to foo. Fine.
Then I start mongodn on bar.
Writes should go to foo and reads should go to bar again.
However reads still go to foo. No matter how long I wait after restarting bar.
I have to restart the whole rails application to make mongoid to query bar again for reads.
Mongoid should check resumed slaves periodically.
Note that if I stop foo at this point then both writes and reads go to bar. That is fine.
Only the resumed slaves are not checked to send them read queries again.