summaryrefslogtreecommitdiff
path: root/src/mongo/db/catalog
diff options
context:
space:
mode:
authorYuhong Zhang <yuhong.zhang@mongodb.com>2022-03-21 20:58:12 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-03-21 23:14:21 +0000
commitdf7690deb090eb2533ff86709380ecccfcadff37 (patch)
tree7baa7797920e3d7c7132f7f5490fac1c66aefaf4 /src/mongo/db/catalog
parent823364aca6a005271833384a28bea6a5a920cb6f (diff)
downloadmongo-df7690deb090eb2533ff86709380ecccfcadff37.tar.gz
SERVER-61228 Architecture Guide updates on index data formats
Diffstat (limited to 'src/mongo/db/catalog')
-rw-r--r--src/mongo/db/catalog/README.md18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/mongo/db/catalog/README.md b/src/mongo/db/catalog/README.md
index 7aa3675e4f4..c12a7068355 100644
--- a/src/mongo/db/catalog/README.md
+++ b/src/mongo/db/catalog/README.md
@@ -837,17 +837,23 @@ secondary oplog application and [initial sync][] where the uniqueness constraint
temporarily. Indexes store key value pairs where they key is the `KeyString`. Current WiredTiger
secondary unique indexes may have a mix of the old and new representations described below.
-| Index type | Key | Value |
-| ---------------------------- | ------------------------------ | ------------------------------------ |
-| `_id` index | `KeyString` without `RecordId` | `RecordId` and optionally `TypeBits` |
-| non-unique index | `KeyString` with `RecordId` | optionally `TypeBits` |
-| unique secondary index (new) | `KeyString` with `RecordId` | optionally `TypeBits` |
-| unique secondary index (old) | `KeyString` without `RecordId` | `RecordId` and opt. `TypeBits` |
+| Index type | (Key, Value) | Data Format Version |
+| ---------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------ |
+| `_id` index | (`KeyString` without `RecordId`, `RecordId` and optionally `TypeBits`) | index V1: 6<br />index V2: 8 |
+| non-unique index | (`KeyString` with `RecordId`, optionally `TypeBits`) | index V1: 6<br />index V2: 8 |
+| unique secondary index (new) | (`KeyString` with `RecordId`, optionally `TypeBits`) | index V1: 13<br />index V2: 14 |
+| unique secondary index (old) | (`KeyString` with `RecordId`, optionally `TypeBits`) or<br />(`KeyString` without `RecordId`, `RecordId` and optionally `TypeBits`) | index V1: 11<br />index V2: 12 |
The reason for the change in index format is that the secondary key uniqueness property can be
temporarily violated during oplog application (because operations may be applied out of order).
With prepared transactions, out-of-order commits would conflict with prepared transactions.
+For `_id` indexes and non-unique indexes, the index data formats will be 6 and 8 for index version
+V1 and V2, respectively. For unique secondary indexes, if they are of formats 13 or 14, it is
+guaranteed that the indexes only store keys of `KeyString` with `RecordId`. If they are of formats
+11 or 12, they may have a mix of the keys with and without `RecordId`. Users can run a `full`
+validation to check if there are keys in the old format in unique secondary indexes.
+
## Building KeyString values and passing them around
There are three kinds of builders for constructing `KeyString` values: