Uploaded image for project: 'Python Driver'
  1. Python Driver
  2. PYTHON-830

Database._create_or_update_user does not respect database/client write concern

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.8, 3.0
    • Affects Version/s: 2.7
    • Component/s: None
    • None

      add_user() run against a server that requires commands for managing users ignores the write concern properties on the Database or MongoClient itself (write concern options must be passed as keyword arguments instead). This is probably most reliably seen from a debugger, but Mongo Orchestration is running into trouble with this.

      Reproduction:

      >>> import pymongo
      >>> import pdb
      >>> client = pymongo.MongoClient(w='majority', fsync=True)
      >>> db = client.admin
      >>> pdb.runcall(db.add_user, 'luke', 'ekul')
      ...
      (pdb) b 337  # This is the line that calls self["$cmd"].find in Database._command in the v2.8 branch right now. 
      (pdb) l
      333  	                          (command_name,
      334  	                           modes[extra_opts['read_preference']]),
      335  	                          UserWarning, stacklevel=3)
      336
      337  ->	        cursor = self["$cmd"].find(command, **extra_opts).limit(-1)
      338  	        for doc in cursor:
      339  	            result = doc
      340
      341  	        if check:
      342  	            msg = "command %s on namespace %s failed: %%s" % (
      343  	                repr(command).replace("%", "%%"), self.name + '.$cmd')
      (pdb) p command
      SON([('createUser', 'luke'), ('pwd', u'df09194d5851bba0ba590bba915e6460'), ('digestPassword', False), ('roles', ['root']), ('writeConcern', {})])
      (pdb) p extra_opts
      {'tag_sets': [{}], 'as_class': None, '_uuid_subtype': 3, 'read_preference': 0, 'secondary_acceptable_latency_ms': 15.0, 'compile_re': True, 'slave_okay': False, '_must_use_master': True}
      

            Assignee:
            bernie@mongodb.com Bernie Hackett
            Reporter:
            luke.lovett Luke Lovett
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: