diff options
| author | Yuhong Zhang <yuhong.zhang@mongodb.com> | 2022-04-26 03:30:11 +0000 |
|---|---|---|
| committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-04-26 22:49:28 +0000 |
| commit | b61476a952e1297436c8d9dbd72fc8d4f8b10da4 (patch) | |
| tree | 2778fa3c003b2af04d0004c024dfd735c4ea42e2 /src/mongo/db/index | |
| parent | fcb9d766b6f66e6a9cfabe1795c1e9d43465b151 (diff) | |
| download | mongo-b61476a952e1297436c8d9dbd72fc8d4f8b10da4.tar.gz | |
SERVER-65922 Allow duplicate keys to be inserted before the index build with the `prepareUnique` option commits
Diffstat (limited to 'src/mongo/db/index')
| -rw-r--r-- | src/mongo/db/index/index_access_method.cpp | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/mongo/db/index/index_access_method.cpp b/src/mongo/db/index/index_access_method.cpp index dba2fb07af5..6de2aea381a 100644 --- a/src/mongo/db/index/index_access_method.cpp +++ b/src/mongo/db/index/index_access_method.cpp @@ -281,10 +281,9 @@ Status SortedDataIndexAccessMethod::insertKeys(OperationContext* opCtx, // wiredtiger. See SERVER-59831. dupsAllowed = true; } else if (prepareUnique) { - // This currently is only used by collMod command when converting a regular index to a - // unique index. The regular index will start rejecting duplicates even before the - // conversion finishes. - dupsAllowed = false; + // Before the index build commits, duplicate keys are allowed to exist with the + // 'prepareUnique' option. After that, duplicates are not allowed. + dupsAllowed = !coll->isIndexReady(_descriptor->indexName()); } else { dupsAllowed = !unique; } |
