[DOCS-15151] [SERVER] Convert a non-unique index to a unique index via the collMod command Created: 07/Mar/22  Updated: 13/Nov/23  Resolved: 21/Jun/22

Status: Closed
Project: Documentation
Component/s: manual, Server
Affects Version/s: 5.3.0, 6.0.0
Fix Version/s: 5.2.0, Server_Docs_20231030, Server_Docs_20231106, Server_Docs_20231105, Server_Docs_20231113

Type: Task Priority: Major - P3
Reporter: Backlog - Core Eng Program Management Team Assignee: Dave Cuthbert (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Documented
documents SERVER-61158 Convert a non-unique index to a uniqu... Closed
Related
Participants:
Days since reply: 1 year, 33 weeks, 1 day ago
Epic Link: DOCSP-17171
Story Points: 3

 Description   
Original Downstream Change Summary

In MongoDB 6.0, we introduce the ability to convert a non-unique index to a unique one via a two phase process with the collMod command.

The first step is as follows given an index of the "a" field:
{collMod: collName, index: {keyPattern:

{a: 1}

, prepareUnique: true}}

The prepareUnique flag puts the regular index into a state where it will start rejecting all new duplicate entries. These new violations will fail with DuplicateKey errors. This behavior is similar to unique indexes, but it will not be marked as "unique" in the durable catalog.

The second (and final) step:
{collMod: collName, index: {keyPattern:

{a: 1}

, unique: true}}

The unique: true (without dryRun: true) flag actually scans through the index to ensure there are no duplicate entries. If duplicates are detected, collMod will return a CannotConvertIndexToUnique error with a list of conflicting documents. The user is expected to fix these errors before continuing with the conversion.

If the user wants to abort the conversion, they may pass in prepareUnique: false.

Description of Linked Ticket

This should include making the necessary catalog changes, but does not encompass checking for duplicates. We should avoid bumping the data format version so that there aren't any upgrade/downgrade implications.



 Comments   
Comment by Githook User [ 21/Jun/22 ]

Author:

{'name': 'Dave Cuthbert', 'email': '69165704+davemungo@users.noreply.github.com', 'username': 'davemungo'}

Message: DOCS-15151 convert non unique index v6.0 (#1224)

  • Needs update on where to find duplicate output
  • Needs update on where to find duplicate output
  • Staging updates
  • Review feedback
  • Switch branch
  • Review feedback
  • Review fixes
Comment by Githook User [ 21/Jun/22 ]

Author:

{'name': 'Dave Cuthbert', 'email': '69165704+davemungo@users.noreply.github.com', 'username': 'davemungo'}

Message: DOCS-15151 convert non unique index v6.0 (#1224)

  • Needs update on where to find duplicate output
  • Needs update on where to find duplicate output
  • Staging updates
  • Review feedback
  • Switch branch
  • Review feedback
  • Review fixes
Comment by Jess Mokrzecki [ 29/Mar/22 ]

Fix Version updated for upstream SERVER-61158:
5.2.0

Comment by Jess Mokrzecki [ 29/Mar/22 ]

Fix Version updated for upstream SERVER-61158:
5.2.0, 4.2.20

Comment by Jess Mokrzecki [ 29/Mar/22 ]

Fix Version updated for upstream SERVER-61158:
5.2.0

Comment by Jess Mokrzecki [ 11/Mar/22 ]

Fix Version updated for upstream SERVER-61158:
5.2.0, 4.2.20

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