Skip to content

Commit e878ef1

Browse files
committed
(DOCSP-10812): Review
1 parent e90bde6 commit e878ef1

File tree

4 files changed

+71
-54
lines changed

4 files changed

+71
-54
lines changed

source/get-started/glossary.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ Glossary
411411
called by the shorthand "App ID". The App ID is used to connect
412412
to your MongoDB Realm application via the client SDKs.
413413

414-
Client Reset
414+
client reset
415415
When using :doc:`{+sync+} </sync>`, a **client reset** is a serious error
416416
recovery task that your client app must perform if the server is restored
417417
to an older schema version than the version on the client.

source/includes/steps-sync-protocol.yaml

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@ ref: realm-sdk-connects-to-the-app-server
33
content: |
44
The sync protocol is primarily handled over a WebSocket connection between the
55
SDK and the server. To establish a connection, the SDK sends a handshake HTTP
6-
request that specifies a protocol version and a WebSocket key. The request
7-
must include a valid access token for an authenticated Realm application user.
6+
request that includes the following:
87
9-
The server sends an :mdn`HTTP 101 Switching Protocols <Web/HTTP/Status/101>`
8+
- a protocol version
9+
- a WebSocket key
10+
- a valid access token for an authenticated Realm application user
11+
12+
The server sends an :mdn:`HTTP 101 Switching Protocols <Web/HTTP/Status/101>`
1013
response that specifies a WebSocket connection for the SDK. The rest of the
1114
sync protocol occurs over this connection.
1215
---
@@ -28,9 +31,9 @@ ref: realm-allocates-a-new-client-file-identifier
2831
content: |
2932
If a :sync-client-message:`BIND` request indicates that the SDK needs a client
3033
file identifier, the Realm server generates a unique value for the specified
31-
Realm file and sends it to the SDK in an :sync-server-message:`IDENT` message.
32-
When the SDK receives the :sync-client-message:`IDENT`, it stores the new
33-
client identifier persistently in the local Realm file.
34+
Realm file and sends it to the SDK in an :sync-server-message:`IDENT`
35+
response. When the SDK receives the :sync-client-message:`IDENT`, it stores
36+
the new client identifier persistently in the local Realm file.
3437
3538
An SDK only needs to request a client file identifier the first time it syncs
3639
each Realm file. For subsequent sync sessions, the SDK can use the persisted
@@ -42,32 +45,34 @@ content: |
4245
Once an SDK has initiated a sync session with a :sync-client-message:`BIND`
4346
request, it must identify the local Realm file that it wants to sync. To do
4447
this, the SDK sends the application server an :sync-client-message:`IDENT`
45-
message that contains the client file identifier. If the identifier is valid,
46-
then the server establishes the session and begins to send and receieve sync
47-
changesets to and from the SDK.
48+
message that contains the client file identifier. If the SDK has previously
49+
synced the {+realm+} with the server, it can specify the most recently synced
50+
server version to optimize the sync process.
51+
52+
When it receives the :sync-client-message:`IDENT` message, the server
53+
establishes the session. The SDK and server can can now freely send upload and
54+
download sync changesets at any time.
4855
---
4956
title: Realm SDK Uploads & Downloads Sync Changesets
5057
ref: realm-sdk-uploads-downloads-sync-changesets
5158
content: |
52-
Once a sync session is established, the SDK can send and recieve
53-
:sync-client-message:`UPLOAD` and :sync-client-message:`DOWNLOAD` messages to
54-
and from the Realm server.
59+
Once a sync session is established, the SDK and server can freely send and
60+
receive :sync-client-message:`UPLOAD` and :sync-client-message:`DOWNLOAD`
61+
messages to sync changes whenever they occur.
5562
5663
The SDK sends an :sync-client-message:`UPLOAD` message for every changeset it
57-
applies except for those that were specified in a
58-
:sync-client-message:`DOWNLOAD` message. When the server receives an
59-
:sync-client-message:`UPLOAD` message, it applies operational transforms to
60-
resolve any conflicts with other changesets and then applies the transformed
61-
changeset to the server version of the realm. This persists the changeset to
62-
the synced Atlas cluster and triggers the Realm server to send
63-
:sync-client-message:`DOWNLOAD` messages to any other clients that are syncing
64-
the same partition.
65-
66-
The server groups one or more transformed changesets that originated from
67-
other clients into a :sync-client-message:`DOWNLOAD` message that it sends to
68-
a synced SDK. The :sync-client-message:`DOWNLOAD` message specifies the
64+
applies except for those that it received in a :sync-client-message:`DOWNLOAD`
65+
message from the server.
66+
67+
When the server receives an :sync-client-message:`UPLOAD` message, it applies
68+
:ref:`operational transformations <operational-transformations>` to resolve
69+
any conflicts with other changesets and then applies the transformed changeset
70+
to the server version of the realm. This triggers the server to send
71+
:sync-client-message:`DOWNLOAD` messages to other connected clients, including
72+
the synced Atlas cluster which mirrors the server realm. A
73+
:sync-client-message:`DOWNLOAD` message groups one or more transformed
6974
changesets in chronological order from oldest to most recent according to the
70-
server's history and the SDK applies the changesets in the same order.
75+
server's history. The SDK applies the changesets in the same order.
7176
---
7277
title: Realm SDK Terminates the Sync Session
7378
ref: realm-sdk-terminates-the-sync-session

source/sync/partitioning.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ Partition keys and values are subject to certain limitations:
207207
.. warning::
208208

209209
Disabling and re-enabling {+sync-short+} will trigger a :term:`client reset
210-
<Client Reset>` on all clients.
210+
<client reset>` on all clients.
211211

212212
- Once you have chosen a partition key and enabled {+sync-short+}, you
213213
cannot change the name of the field you selected as your partition
@@ -223,7 +223,7 @@ Partition keys and values are subject to certain limitations:
223223
.. warning::
224224

225225
Disabling and re-enabling {+sync+} will trigger a :term:`client reset
226-
<Client Reset>` on all clients.
226+
<client reset>` on all clients.
227227

228228
- If you change a partition value in {+atlas-short+}, {+backend+} interprets
229229
the change as a delete, then an insert. First, {+backend+} deletes
@@ -238,7 +238,7 @@ Partition keys and values are subject to certain limitations:
238238

239239
- Avoid changing a partition value in a {+service-short+} object using
240240
the {+service-short+} SDK because it triggers a
241-
:ref:`client reset <client-reset>`.
241+
:term:`client reset <client reset>`.
242242

243243
- Documents linked to each other using a relationship produce
244244
"dangling links" with a null value if the documents do not

source/sync/protocol.txt

Lines changed: 37 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,24 @@ by which a client, like a {+service-short+} SDK, can connect to a
3232
Key Concepts
3333
------------
3434

35-
.. _changeset:
35+
.. _changesets:
3636

3737
Changeset
3838
~~~~~~~~~
3939

4040
A **changeset** is a list of instructions that describe granular modifications
4141
made to a known object state or version by one or more write operations.
4242
Changesets are the base unit of the sync protocol. Synced {+realm+} clients send
43-
changesets to the {+service-short+} server whenever they perfrom a write
44-
operation and the server sends each client changesets for operations executed by
45-
other clients. The {+service-short+} sync server accepts changesets from any
46-
connected sync client (including changes in a synced MongoDB cluster) at any
47-
time and uses an operational transformation algorithm to serialize changes and
48-
resolve conflicting changesets.
43+
changesets to the {+service-short+} server whenever they perform a write
44+
operation. The server sends each connected client the changesets for write
45+
operations executed by other clients.
4946

50-
.. _operational-transformation:
47+
The {+service-short+} sync server accepts changesets from any connected sync
48+
client (including changes in a synced MongoDB cluster) at any time and uses an
49+
operational transformation algorithm to serialize changes into a linear order
50+
and resolve conflicting changesets before sending them to connected clients.
51+
52+
.. _operational-transformations:
5153

5254
Operational Transformation
5355
~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -68,7 +70,7 @@ changed object.
6870

6971
.. tip::
7072

71-
An operational transformation on {+service-short+} changesets is analagous to
73+
An operational transformation on {+service-short+} changesets is analogous to
7274
a :git-scm:`rebase operation <docs/git-rebase>` in Git.
7375

7476
.. _client-file-identifier:
@@ -79,7 +81,7 @@ Client File Identifier
7981
A **client file identifier** is a value that uniquely identifies a synced client
8082
{+service-short+} file and its corresponding server file. The server generates a
8183
client file identifier whenever an SDK requests one during its initial sync of a
82-
{+service-short+} file. Each identifier is a 64-bit, non-zero, positive signed
84+
{+service-short+} file. Each identifier is a 64-bit, non-zero, positive signed
8385
integer strictly less than 2^63.
8486

8587
.. note::
@@ -102,7 +104,7 @@ The SDK negotiates a WebSocket connection over HTTP and then establishes a sync
102104
session by sending :sync-client-message:`BIND` and :sync-client-message:`IDENT`
103105
requests to the server over the WebSocket connections. Once the session is
104106
established, the SDK and server send synced changesets for a given
105-
{+service-short+} file to eachother via :sync-client-message:`UPLOAD` and
107+
{+service-short+} file to each other via :sync-client-message:`UPLOAD` and
106108
:sync-client-message:`DOWNLOAD` messages. To end the session, the SDK sends an
107109
:sync-client-message:`UNBIND` request.
108110

@@ -115,7 +117,7 @@ established, the SDK and server send synced changesets for a given
115117
| |
116118
| --------- 2. BIND -----------> |
117119
| |
118-
| <-------- 3. IDENT* ---------- |
120+
| <-- 3. IDENT (first time) ---- |
119121
| |
120122
| --------- 4. IDENT ----------> |
121123
| |
@@ -156,17 +158,24 @@ The following table describes the request types that a sync client can send to a
156158

157159
* - .. sync-client-message:: IDENT
158160
- Provides the :ref:`client file identifier <client-file-identifier>` that
159-
indicates which {+service-short+} file will be synced and specifies the
160-
client {+realm+}'s current version.
161+
indicates the following:
162+
163+
- the {+service-short+} file to sync
164+
- the client {+realm+}'s current version
165+
- the client {+realm+}'s most recently synced server version
166+
167+
This request is related to but distinct from the
168+
:sync-server-message:`IDENT` message sent by the server when a client
169+
requests a client file identifier.
161170

162171
* - .. sync-client-message:: UPLOAD
163-
- Specifies one or more :ref:`changesets <changeset>` for operations that
164-
occured on the client. The changesets are listed by client version in
172+
- Specifies one or more :ref:`changesets <changesets>` for operations that
173+
occurred on the client. The changesets are listed by client version in
165174
increasing order.
166175

167176
* - .. sync-client-message:: TRANSACT
168-
- Specifies a :ref:`changeset <changeset>` that describes a serialized
169-
transaction that occured on the client. The client may not upload any
177+
- Specifies a :ref:`changeset <changesets>` that describes a serialized
178+
transaction that occurred on the client. The client may not upload any
170179
other changesets until the server confirms or rejects the transaction.
171180

172181
* - .. sync-client-message:: UNBIND
@@ -177,7 +186,7 @@ The following table describes the request types that a sync client can send to a
177186

178187
* - .. sync-client-message:: MARK
179188
- Requests that the server notify the client when it has synced the latest
180-
:ref:`changeset <changeset>` in the server history (at the time of the
189+
:ref:`changeset <changesets>` in the server history (at the time of the
181190
request).
182191

183192
* - .. sync-client-message:: REFRESH
@@ -192,7 +201,7 @@ The following table describes the request types that a sync client can send to a
192201
* - .. sync-client-message:: CLIENT_VERSION_REQUEST
193202
- Requests that the server send the client version of the latest changeset
194203
that was sent by the client and processed by the server. This is most
195-
commonly used to execute a client reset.
204+
commonly used when an SDK executes a :term:`client reset`.
196205

197206
* - .. sync-client-message:: PING
198207
- Indicates that the client is still connected and that the server should
@@ -225,14 +234,14 @@ server can send to a sync client:
225234
requested the identifier.
226235

227236
* - .. sync-server-message:: DOWNLOAD
228-
- Specifies one or more :ref:`changesets <changeset>` (up to 16MB total)
229-
for operations that occured on other clients. The changesets are listed
237+
- Specifies one or more :ref:`changesets <changesets>` (up to 16MB total)
238+
for operations that occurred on other clients. The changesets are listed
230239
by server version in increasing order.
231240

232241
The changesets in a DOWNLOAD may not be the exact changesets uploaded by
233242
other clients. Instead, they may be equivalent changesets output by
234243
{+service-short+}'s :ref:`operational transformation
235-
<operational-transformation>` algorithm.
244+
<operational-transformations>` algorithm.
236245

237246
* - .. sync-server-message:: UNBOUND
238247
- Specifies that the server ended a sync session in response to an
@@ -244,7 +253,7 @@ server can send to a sync client:
244253

245254
* - .. sync-server-message:: MARK
246255
- Indicates that the server has sent the client the latest
247-
:ref:`changeset <changeset>` that was in the server history when the
256+
:ref:`changeset <changesets>` that was in the server history when the
248257
server received a :sync-client-message:`MARK` from the client.
249258

250259
* - .. sync-server-message:: STATE
@@ -262,4 +271,7 @@ server can send to a sync client:
262271
caused by the connected client.
263272

264273
* - .. sync-server-message:: PONG
265-
- Acknowledges a :sync-client-message:`PING`.
274+
- Acknowledges a :sync-client-message:`PING`. If a client does not receive
275+
a PONG acknowledgement, it indicates that the client cannot currently
276+
communicate with the server over the network and that the server may not
277+
have received the corresponding :sync-client-message:`PING`.

0 commit comments

Comments
 (0)