Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-29263

Shell bulk api hides write concern errors when there is a write error and the bulk write is 'ordered'

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major - P3
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: Backlog
    • Component/s: Shell
    • Labels:
    • Operating System:
      ALL

      Description

      It's possible for a write to fail both with a write error and a write concern error - for example if there is a duplicate key violation during an insert, we will still need to wait for write concern to ensure that the state that triggered the dup key error is visible across the majority of nodes. The shell bulk api, however, swallows write concern errors when doing an ordered bulk write if it encounters a write error. Unordered bulk writes correctly report both the write concern error and the write error.

      replset:PRIMARY> db.test1.bulkWrite([{insertOne:{document:{_id:1}}}],{ordered:true,writeConcern:{w:2,wtimeout:1000}})
      2017-04-27T16:38:39.568-0400 E QUERY    [thread1] BulkWriteError: write error at item 0 in bulk operation :
      BulkWriteError({
      	"writeErrors" : [
      		{
      			"index" : 0,
      			"code" : 11000,
      			"errmsg" : "E11000 duplicate key error collection: test.test1 index: _id_ dup key: { : 1.0 }",
      			"op" : {
      				"_id" : 1
      			}
      		}
      	],
      	"writeConcernErrors" : [ ],
      	"nInserted" : 0,
      	"nUpserted" : 0,
      	"nMatched" : 0,
      	"nModified" : 0,
      	"nRemoved" : 0,
      	"upserted" : [ ]
      })
       
      replset:PRIMARY> db.test1.bulkWrite([{insertOne:{document:{_id:1}}}],{ordered:false,writeConcern:{w:2,wtimeout:1000}})
      2017-04-27T16:38:17.558-0400 E QUERY    [thread1] BulkWriteError: write error at item 0 and problem enforcing write concern in bulk operation :
      BulkWriteError({
      	"writeErrors" : [
      		{
      			"index" : 0,
      			"code" : 11000,
      			"errmsg" : "E11000 duplicate key error collection: test.test1 index: _id_ dup key: { : 1.0 }",
      			"op" : {
      				"_id" : 1
      			}
      		}
      	],
      	"writeConcernErrors" : [
      		{
      			"code" : 64,
      			"codeName" : "WriteConcernFailed",
      			"errInfo" : {
      				"wtimeout" : true
      			},
      			"errmsg" : "waiting for replication timed out"
      		}
      	],
      	"nInserted" : 0,
      	"nUpserted" : 0,
      	"nMatched" : 0,
      	"nModified" : 0,
      	"nRemoved" : 0,
      	"upserted" : [ ]
      })
      BulkWriteError@src/mongo/shell/bulk_api.js:372:48
      BulkWriteResult/this.toError@src/mongo/shell/bulk_api.js:336:24
      Bulk/this.execute@src/mongo/shell/bulk_api.js:1173:1
      DBCollection.prototype.bulkWrite@src/mongo/shell/crud_api.js:191:20
      @(shell):1:1
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              backlog-server-stm Backlog - Server Tooling and Methods (STM)
              Reporter:
              spencer Spencer Brody (Inactive)
              Participants:
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated: