Uploaded image for project: 'MongoDB Database Tools'
  1. MongoDB Database Tools
  2. TOOLS-1507

Mongorestore does not preserve order of partial indexes. Conflicting index configurations

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.7.1, 3.6.0-rc5
    • Affects Version/s: 3.2.6
    • Component/s: mongorestore
    • Labels:
      None

      Mongorestore version 3.2.6 seems to not preserve an order of fields in partialFilterExpression. This issue is reproducible and causing conflicting index configurations.

      When dumped using mongodump(3.2.6) the users.metadata.json has correct order of indexes.

      Example: users.metadata.json has following index configurations when dumped using mongodump

      {
      		"v": 1,
      		"unique": true,
      		"key": {
      			"region_id": 1,
      			"zone_id": 1
      		},
      		"name": "region",
      		"ns": "mydb.users",
      		"background": true,
      		"partialFilterExpression": {
      			"dateCreated": {
      				"$eq": null
      			},
      			"bill_id": {
      				"$exists": true
      			}
      		}
      	}
      

      But, when restored, the index region was restored as following:

      {
      		"v": 1,
      		"unique": true,
      		"key": {
      			"region_id": 1,
      			"zone_id": 1
      		},
      		"name": "region",
      		"ns": "mydb.users",
      		"background": true,
      		"partialFilterExpression": {
      			"bill_id": {
      				"$exists": true
      			},			
      			"dateCreated": {
      				"$eq": null
      			}
      		}
      	}
      

      This leads to a conflicting index configuration when the index with the same name is created from application code.

      Any help will be appreciated.

      Thanks,

            Assignee:
            gabriel.russell@mongodb.com Gabriel Russell (Inactive)
            Reporter:
            andhareatish@gmail.com Ati And
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: