Uploaded image for project: 'Ruby Driver'
  1. Ruby Driver
  2. RUBY-827

standalone client should not reroute

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.0.0
    • Affects Version/s: 2.0.0
    • Component/s: None
    • Labels:
      None

      With a standalone client, execution of a command gets rerouted incorrectly. The following patch shows uses a hack to bypass this for test code. This is obviously not a possible solution, just illustration of the problem that cannot be solved easily as the data to fix this is not available.

        module Operation
          class Command
      
            # global $reroute is just a hack to bypass rerouting for a client with mode standalone
            def execute(context)
              # @todo: Should we respect tag sets and options here?
              if $reroute
                if context.server.secondary? && !secondary_ok?
                  warn "Database command '#{selector.keys.first}' rerouted to primary server"
                  context = Mongo::ServerPreference.get(:mode => :primary).server.context
                end
              end
              execute_message(context)
            end
          end
      end
      

            Assignee:
            durran.jordan@mongodb.com Durran Jordan
            Reporter:
            gjmurakami Gary Murakami
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: