summaryrefslogtreecommitdiff
path: root/src/mongo/s/resharding/common_types.idl
blob: b28385881d2d9d80377c5ffb741824fb4d19757d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
# Copyright (C) 2020-present MongoDB, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the Server Side Public License, version 1,
# as published by MongoDB, Inc.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# Server Side Public License for more details.
#
# You should have received a copy of the Server Side Public License
# along with this program. If not, see
# <http://www.mongodb.com/licensing/server-side-public-license>.
#
# As a special exception, the copyright holders give permission to link the
# code of portions of this program with the OpenSSL library under certain
# conditions as described in each individual source file and distribute
# linked combinations including the program with the OpenSSL library. You
# must comply with the Server Side Public License in all respects for
# all of the code used other than as permitted herein. If you modify file(s)
# with this exception, you may extend this exception to your version of the
# file(s), but you are not obligated to do so. If you do not wish to do so,
# delete this exception statement from your version. If you delete this
# exception statement from all source files in the program, then also delete
# it in the license file.
#

# This file defines types used among various resharding-related IDL structs.

global:
    cpp_namespace: "mongo"

imports:
    - "mongo/db/keypattern.idl"
    - "mongo/db/basic_types.idl"
    - "mongo/s/sharding_types.idl"

enums:
    CoordinatorState:
        description: "The current state of a resharding operation on the coordinator."
        type: string
        values:
            kUnused: "unused"
            kInitializing: "initializing"
            kPreparingToDonate: "preparing-to-donate"
            kCloning: "cloning"
            kApplying: "applying"
            kBlockingWrites: "blocking-writes"
            kAborting: "aborting"
            kCommitting: "committing"
            kDone: "done"

    DonorState:
        description: "The current state of a donor shard for a resharding operation."
        type: string
        values:
            kUnused: "unused"
            kPreparingToDonate: "preparing-to-donate"
            kDonatingInitialData: "donating-initial-data"
            kDonatingOplogEntries: "donating-oplog-entries"
            kPreparingToBlockWrites: "preparing-to-block-writes"
            kError: "error"
            kBlockingWrites: "blocking-writes"
            kDone: "done"

    RecipientState:
        description: "The current state of a recipient shard for a resharding operation."
        type: string
        values:
            kUnused: "unused"
            kAwaitingFetchTimestamp: "awaiting-fetch-timestamp"
            kCreatingCollection: "creating-collection"
            kCloning: "cloning"
            kApplying: "applying"
            kError: "error"
            kStrictConsistency: "strict-consistency"
            kDone: "done"

    ReshardingOperationStatus:
        description: "The status of the current or most recent resharding operation."
        type: string
        values:
            kSuccess: "success"
            kFailure: "failure"
            kCanceled: "canceled"
            kRunning: "running"
            kInactive: "inactive"

structs:
    CommonReshardingMetadata:
        description: "Immutable metadata shared across all node types for a resharding operation."
        generate_comparison_operators: false
        # Use strict:false to avoid complications around upgrade/downgrade. This isn't technically
        # required for resharding because durable state from all resharding operations is cleaned up
        # before the upgrade or downgrade can complete.
        strict: false
        fields:
            _id:
                cpp_name: reshardingUUID
                type: uuid
                description: "A unique identifier for the resharding operation."
            ns:
                cpp_name: sourceNss
                type: namespacestring
                description: "The namespace of the collection being resharded."
            ui:
                cpp_name: sourceUUID
                type: uuid
                description: "The UUID of the original collection being resharded."
            tempNs:
                cpp_name: tempReshardingNss
                type: namespacestring
                description: "The namespace of the temporary resharding collection that exists on
                              recipient shards."
            reshardingKey:
                type: KeyPattern
                description: "The index specification document to use as the new shard key."
            startTime:
                type: date
                description: "Operation start time."
                optional: true

    AbortReason:
        description: "Not meant to be used directly. Only use internal fields."
        # Use strict:false to avoid complications around upgrade/downgrade. This setting has no
        # practical effect because this type is only meant to be used as a chained struct with
        # inline_chained_structs:true and only the strictness setting of the wrapping struct type
        # applies.
        strict: false
        fields:
            abortReason:
                type: object_owned
                description: "The error that caused the node to abort the resharding operation. In
                              this case, the node may be a donor shard, recipient shard, or the
                              coordinator itself."
                optional: true

    DonorShardContext:
        description: "Mutable state for a donor shard tracked both locally by a donor shard and
                      remotely by the resharding coordinator."
        inline_chained_structs: true
        chained_structs:
            AbortReason: AbortReasonStruct
        generate_comparison_operators: false
        # Use strict:false to avoid complications around upgrade/downgrade. This isn't technically
        # required for resharding because durable state from all resharding operations is cleaned up
        # before the upgrade or downgrade can complete.
        strict: false
        fields:
            state:
                type: DonorState
                default: kUnused
            minFetchTimestamp:
                type: timestamp
                description: "Timestamp after which this donor shard has guaranteed that oplog
                              entries contain recipient shard information."
                optional: true
            bytesToClone:
                type: long
                description: "Number of bytes on this donor shard in the collection being
                              resharded."
                optional: true
            documentsToClone:
                type: long
                description: "Number of documents on this donor shard in the collection being
                              resharded."
                optional: true
                
    DonorShardFetchTimestamp:
        description: "Used for tracking donor min fetch timestamp"
        strict: false
        generate_comparison_operators: false
        fields:
            shardId:
                type: shard_id
                description: "A shard identifier."
            minFetchTimestamp:
                type: timestamp
                optional: true
                description: "Timestamp after which this donor shard has guaranteed that oplog
                                entries contain recipient shard information."

    RecipientShardContext:
        description: "Mutable state for a recipient shard tracked both locally by a recipient shard
                      and remotely by the resharding coordinator."
        inline_chained_structs: true
        chained_structs:
            AbortReason: AbortReasonStruct
        generate_comparison_operators: false
        # Use strict:false to avoid complications around upgrade/downgrade. This isn't technically
        # required for resharding because durable state from all resharding operations is cleaned up
        # before the upgrade or downgrade can complete.
        strict: false
        fields:
            state:
                type: RecipientState
                default: kUnused

    ReshardingApproxCopySize:
        description: "Not meant to be used directly. Only use internal fields."
        # Use strict:false to avoid complications around upgrade/downgrade. This setting has no
        # practical effect because this type is only meant to be used as a chained struct with
        # inline_chained_structs:true and only the strictness setting of the wrapping struct type
        # applies.
        strict: false
        fields:
            approxDocumentsToCopy:
                type: long
                optional: true
            approxBytesToCopy:
                type: long
                optional: true

    ReshardingSourceId:
        description: "Identifier for a shard involved in a particular resharding operation."
        # Use strict:true because this type is used as the structure for the _id value in documents
        # and requires being an exact match.
        strict: true
        fields:
            reshardingUUID:
                type: uuid
                description: "Identifier for a resharding operation."
            shardId:
                type: shard_id
                description: "A shard identifier."

    ReshardingZoneType:
        description: >-
            Object describing a zone for the collection being resharded using the new shard key.
        # Use strict:false to avoid complications around upgrade/downgrade.
        strict: false
        fields:
            zone:
                type: string
                description: "The zone name."
            min:
                type: object_owned 
                description: "The min key of the chunk range assigned to the zone."
            max:
                type: object_owned
                description: "The max key of the chunk range assigned to the zone."

    ReshardedChunk:
        description: "ReshardedChunk"
        fields:
            recipientShardId:
                type: shard_id
                description: "The id of the recipient shard."
            min:
                type: object_owned
                description: "The min key of the chunk range."
            max:
                type: object_owned
                description: "The max key of the chunk range."

    ReshardingMetricsTimeInterval:
        description: "Contains the start and stop time of a resharding operation phase."
        strict: false
        fields:
            start:
                type: date
                description: "The start timestamp."
                optional: true
            stop:
                type: date
                description: "The stop timestamp."
                optional: true

    DocumentSourceReshardingOwnershipMatchSpec:
        description: "A struct representing the information needed for a resharding pipeline to
                      determine which documents belong to a particular shard."
        strict: true
        fields:
            recipientShardId:
                type: shard_id
                description: "The id of the recipient shard."
            reshardingKey:
                type: KeyPattern
                description: "The index specification document to use as the new shard key."