Uploaded image for project: 'Drivers'
  1. Drivers
  2. DRIVERS-187

Handle empty "raw" errors from mongos

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Component/s: None
    • Labels:
      None
    • $i18n.getText("admin.common.words.hide")
      Key Status/Resolution FixVersion
      PYTHON-766 Done 2.8, 3.0
      $i18n.getText("admin.common.words.show")
      #scriptField, #scriptField *{ border: 1px solid black; } #scriptField{ border-collapse: collapse; } #scriptField td { text-align: center; /* Center-align text in table cells */ } #scriptField td.key { text-align: left; /* Left-align text in the Key column */ } #scriptField a { text-decoration: none; /* Remove underlines from links */ border: none; /* Remove border from links */ } /* Add green background color to cells with FixVersion */ #scriptField td.hasFixVersion { background-color: #00FF00; /* Green color code */ } /* Center-align the first row headers */ #scriptField th { text-align: center; } Key Status/Resolution FixVersion PYTHON-766 Done 2.8, 3.0

      When a command fails, mongos sometimes returns a subdocument called "raw", with errors from each shard:

      mongos> db.stats('foo')
      {
      	"ok" : 0,
              "errmsg" : "{ shard0/localhost:4000,localhost:4001: \"scale has to be a number > 0\", shard1/localhost:4002,localhost:4003: \"scale has to be a number > 0\" }",
      	"raw" : {
      		"shard0/localhost:4000,localhost:4001" : {
      			"ok" : 0,
      			"errmsg" : "scale has to be a number > 0"
      		},
      		"shard1/localhost:4002,localhost:4003" : {
      			"ok" : 0,
      			"errmsg" : "scale has to be a number > 0"
      		}
      	}
      }
      

      As you can see, the raw error messages are often more legible than the top-level message, so PyMongo tries to be clever and use one of the shards' error messages if it can find one.

      But here's the rub: if a shard is down, mongos can return an empty error document in "raw" (SERVER-15428). After I take down the primary of shard0:

      mongos> db.stats('foo')
      {
      	"ok" : 0,
      	"errmsg" : "{ shard0/localhost:4000,localhost:4001: \"result without error message returned : {}\", shard1/localhost:4002,localhost:4003: \"scale has to be a number > 0\" }",
      	"raw" : {
      		"shard0/localhost:4000,localhost:4001" : {
      
      		},
      		"shard1/localhost:4002,localhost:4003" : {
      			"ok" : 0,
      			"errmsg" : "scale has to be a number > 0"
      		}
      	}
      }
      

      PyMongo throws an exception trying to parse this (PYTHON-766).

      *Questions:* Does your driver try to parse the "raw" subdocument from mongos? If so, does your driver handle an empty raw error reasonably well? Do you test it?

      Validate this ticket if your driver does *not* try to parse raw errors from mongos at all, or validate it if you have a test that demonstrates your driver can parse empty raw errors.

            Assignee:
            Unassigned Unassigned
            Reporter:
            jesse@mongodb.com A. Jesse Jiryu Davis
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: