[SERVER-27891] reIndex command ignores writeConcern Created: 01/Feb/17  Updated: 05/Apr/17  Resolved: 03/Mar/17

Status: Closed
Project: Core Server
Component/s: Index Maintenance
Affects Version/s: 3.5.2
Fix Version/s: 3.5.4

Type: Bug Priority: Major - P3
Reporter: Robert Stam Assignee: Maria van Keulen
Resolution: Done Votes: 0
Labels: neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to DRIVERS-359 reIndex does not support writeConcern Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Steps To Reproduce:

Using an older version of the shell (one that doesn't use OP_COMMAND?):

rs:PRIMARY> db.test.find()
{ "_id" : 1 }
rs:PRIMARY> db.test.getIndexes()
[
        {
                "v" : 2,
                "key" : {
                        "_id" : 1
                },
                "name" : "_id_",
                "ns" : "test.test"
        }
]
rs:PRIMARY> db.runCommand({ reIndex : "test", writeConcern : { w : 9 } })
{
        "nIndexesWas" : 1,
        "nIndexes" : 1,
        "indexes" : [
                {
                        "v" : 2,
                        "key" : {
                                "_id" : 1
                        },
                        "name" : "_id_",
                        "ns" : "test.test"
                }
        ],
        "ok" : 1 // <=== the test was expecting an error back from the server
}
rs:PRIMARY>

Sprint: Storage 2017-03-27
Participants:

 Description   

The .NET driver tests send the following command to a replica set primary:

"{ \"reIndex\" : \"ReIndexOperationTests\", \"writeConcern\" : { \"w\" : 9 } }"

It is expecting an error back because { w : 9 } is not valid for a replica set with 3 nodes.

The response back from the server is:

"{ \"nIndexesWas\" : 1, \"nIndexes\" : 1, \"indexes\" : [{ \"v\" : 2, \"key\" : { \"_id\" : 1 }, \"name\" : \"_id_\", \"ns\" : \"Tests02011550.ReIndexOperationTests\" }], \"ok\" : 1.0 }"

This is probably an issue of which code path is being used in the server. If you try to reproduce this using the current shell you get the expected error. If you use an older shell you don't get the expected error.

The .NET driver and older shells don't use OP_COMMAND, so the difference probably lies in that.



 Comments   
Comment by Bernie Hackett [ 02/Mar/17 ]

We're trying to figure out what drivers this change affects. It is a breaking change after all.

Comment by Githook User [ 02/Mar/17 ]

Author:

{u'username': u'mvankeulen94', u'name': u'Maria van Keulen', u'email': u'maria@mongodb.com'}

Message: SERVER-27891 Disable writeConcern support for mongos reIndex
Branch: master
https://github.com/mongodb/mongo/commit/9548d9770792d65ade08dca02254ac620ae3b6b9

Comment by Bernie Hackett [ 02/Mar/17 ]

Following SERVER-20224 and DRIVERS-290 for MongoDB 3.4 all drivers that have a reindex helper started sending writeConcern along with it. This is a breaking change for those drivers:

 [2017/02/28 19:49:52.524] ======================================================================
 [2017/02/28 19:49:52.524] ERROR [0.160s]: test_reindex (test_collection.TestCollection)
 [2017/02/28 19:49:52.524] ----------------------------------------------------------------------
 [2017/02/28 19:49:52.524] Traceback (most recent call last):
 [2017/02/28 19:49:52.524]   File "C:\data\mci\b3a0a6406086a04aca859d78e12a0743\src\test\test_collection.py", line 314, in test_reindex
 [2017/02/28 19:49:52.524]     coll.reindex()
 [2017/02/28 19:49:52.524]   File "C:\data\mci\b3a0a6406086a04aca859d78e12a0743\src\pymongo\collection.py", line 1654, in reindex
 [2017/02/28 19:49:52.524]     parse_write_concern_error=True)
 [2017/02/28 19:49:52.524]   File "C:\data\mci\b3a0a6406086a04aca859d78e12a0743\src\pymongo\collection.py", line 232, in _command
 [2017/02/28 19:49:52.524]     collation=collation)
 [2017/02/28 19:49:52.524]   File "C:\data\mci\b3a0a6406086a04aca859d78e12a0743\src\pymongo\pool.py", line 419, in command
 [2017/02/28 19:49:52.524]     collation=collation)
 [2017/02/28 19:49:52.524]   File "C:\data\mci\b3a0a6406086a04aca859d78e12a0743\src\pymongo\network.py", line 116, in command
 [2017/02/28 19:49:52.524]     parse_write_concern_error=parse_write_concern_error)
 [2017/02/28 19:49:52.524]   File "C:\data\mci\b3a0a6406086a04aca859d78e12a0743\src\pymongo\helpers.py", line 210, in _check_command_response
 [2017/02/28 19:49:52.524]     raise OperationFailure(msg % errmsg, code, response)
 [2017/02/28 19:49:52.524] pymongo.errors.OperationFailure: Command does not support writeConcern

Comment by Githook User [ 27/Feb/17 ]

Author:

{u'username': u'mvankeulen94', u'name': u'Maria van Keulen', u'email': u'maria@mongodb.com'}

Message: SERVER-27891 Disable writeConcern support for reIndex
Branch: master
https://github.com/mongodb/mongo/commit/506571956d4c1cd14db5d04caa6af46284d5c884

Comment by Eric Milkie [ 01/Feb/17 ]

Ah, I see. This is a mistake in the implementation for CmdReIndex.. it has supportsWriteConcern set to "true".

Comment by Robert Stam [ 01/Feb/17 ]

Not always... here's a repro using 3.5.2 for the shell and the server:

rs:PRIMARY> db.runCommand({ reIndex : "test", writeConcern : { w : 9 } })
{
        "nIndexesWas" : 1,
        "nIndexes" : 1,
        "indexes" : [
                {
                        "v" : 2,
                        "key" : {
                                "_id" : 1
                        },
                        "name" : "_id_",
                        "ns" : "test.test"
                }
        ],
        "writeConcernError" : {
                "code" : 100,
                "codeName" : "CannotSatisfyWriteConcern",
                "errmsg" : "Not enough data-bearing nodes"
        },
        "ok" : 1
}
rs:PRIMARY>

Comment by Eric Milkie [ 01/Feb/17 ]

I suspect the reIndex command probably ignores all parameters it doesn't understand?

Generated at Thu Feb 08 04:16:32 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.