Skip to content

Commit 33462bf

Browse files
nlarewkay-kim
authored andcommitted
DOCS-10668: Change stream invalidate events
1 parent 34004b8 commit 33462bf

File tree

4 files changed

+63
-32
lines changed

4 files changed

+63
-32
lines changed

source/administration/change-streams-production-recommendations.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ Change Streams Production Recommendations
1212
:depth: 1
1313
:class: singlecol
1414

15-
If you drop a collection with change streams opened against it, the change
16-
stream cursors close when they advance to that point in the oplog. Change
17-
stream cursors with the ``fullDocument : updateLookup`` option may return
18-
``null`` for the lookup document.
15+
If you drop or rename a collection or database with change streams
16+
opened against it, the change stream cursors close when they advance to
17+
that point in the oplog. Change stream cursors with the ``fullDocument :
18+
updateLookup`` option may return ``null`` for the lookup document.
1919

2020
Attempting to resume a change stream against a dropped collection results in
2121
an error. Any data changes that occurred on the collection between the last
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.. note::
2+
:ref:`Invalidated <change-event-invalidate>` change streams cannot be
3+
resumed. Attempting to resume a change stream against a dropped or
4+
renamed collection results in an error.

source/reference/change-events.txt

Lines changed: 53 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -132,19 +132,19 @@ The following example illustrates an ``insert`` event:
132132

133133
{
134134
_id: { < Resume Token > },
135-
operationType: insert,
135+
operationType: 'insert',
136136
ns: {
137-
db: engineering,
138-
coll: users
137+
db: 'engineering',
138+
coll: 'users'
139139
},
140140
documentKey: {
141-
userName: alice123,
141+
userName: 'alice123',
142142
_id: ObjectId("599af247bb69cd89961c986d")
143143
},
144144
fullDocument: {
145145
_id: ObjectId("599af247bb69cd89961c986d"),
146-
userName: alice123,
147-
name: Alice
146+
userName: 'alice123',
147+
name: 'Alice'
148148
}
149149
}
150150

@@ -164,19 +164,19 @@ The following example illustrates an ``update`` event:
164164

165165
{
166166
_id: { < Resume Token > },
167-
operationType: update,
167+
operationType: 'update',
168168
ns: {
169-
db: engineering,
170-
coll: users
169+
db: 'engineering',
170+
coll: 'users'
171171
},
172172
documentKey: {
173173
_id: ObjectId("58a4eb4a30c75625e00d2820")
174174
},
175175
updateDescription: {
176176
updatedFields: {
177-
email: [email protected]
177+
178178
},
179-
removedFields: [phoneNumber]
179+
removedFields: ['phoneNumber']
180180
}
181181
}
182182

@@ -187,26 +187,26 @@ opened with the ``fullDocument : updateLookup`` option:
187187

188188
{
189189
_id: { < Resume Token > },
190-
operationType: update,
190+
operationType: 'update',
191191
ns: {
192-
db: engineering,
193-
coll: users
192+
db: 'engineering',
193+
coll: 'users'
194194
},
195195
documentKey: {
196196
_id: ObjectId("58a4eb4a30c75625e00d2820")
197197
},
198198
updateDescription: {
199199
updatedFields: {
200-
email: [email protected]
200+
201201
},
202-
removedFields: [phoneNumber]
202+
removedFields: ['phoneNumber']
203203
},
204204
fullDocument: {
205205
_id: ObjectId("58a4eb4a30c75625e00d2820"),
206-
name: Alice,
207-
userName: alice123,
208-
email: [email protected],
209-
team: replication
206+
name: 'Alice',
207+
userName: 'alice123',
208+
209+
team: 'replication'
210210
}
211211
}
212212

@@ -225,18 +225,18 @@ The following example illustrates a ``replace`` event:
225225

226226
{
227227
_id: { < Resume Token > },
228-
operationType: replace,
228+
operationType: 'replace',
229229
ns: {
230-
db: engineering,
231-
coll: users
230+
db: 'engineering',
231+
coll: 'users'
232232
},
233233
documentKey: {
234234
_id: ObjectId("599af247bb69cd89961c986d")
235235
},
236236
fullDocument: {
237237
_id: ObjectId("599af247bb69cd89961c986d"),
238-
userName: alice123,
239-
name: Alice
238+
userName: 'alice123',
239+
name: 'Alice'
240240
}
241241
}
242242

@@ -263,10 +263,10 @@ The following example illustrates a ``delete`` event:
263263
"$oid":"599af247bb69cd89961c986d"
264264
}
265265
},
266-
operationType: delete,
266+
operationType: 'delete',
267267
ns: {
268-
db: engineers’,
269-
coll: users
268+
db: 'engineers',
269+
coll: 'users'
270270
},
271271
documentKey: {
272272
_id: ObjectId("599af247bb69cd89961c986d")
@@ -275,3 +275,28 @@ The following example illustrates a ``delete`` event:
275275

276276
The ``fullDocument`` document is omitted as the document no longer exists at the
277277
time the change stream cursor sends the ``delete`` event to the client.
278+
279+
280+
.. _change-event-invalidate:
281+
282+
``invalidate`` Event
283+
--------------------
284+
285+
The following example illustrates an ``invalidate`` event:
286+
287+
.. code-block:: none
288+
289+
{
290+
_id: { < Resume Token > },
291+
operationType: 'invalidate'
292+
}
293+
294+
All fields except for ``_id`` and ``operationType`` are omitted.
295+
296+
``invalidate`` events occur after a :dbcommand:`dropDatabase`,
297+
:dbcommand:`drop`, or :dbcommand:`renameCollection` command that
298+
affects the watched collection. ``invalidate`` events close the change
299+
stream cursor and signal that any locally cached data is out
300+
of sync with the server.
301+
302+
.. include:: /includes/fact-cannot-resume-invalidated-change-stream.rst

source/tutorial/change-streams-example.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,8 @@ notification after a specific notification.
350350
As long as that operation has not rolled off the :term:`oplog`, the
351351
change stream can successfully resume notifications.
352352

353+
.. include:: /includes/fact-cannot-resume-invalidated-change-stream.rst
354+
353355
See :ref:`change-stream-output` for more information on the change stream
354356
response document format.
355357

0 commit comments

Comments
 (0)