88
99This specification describes how to implement Wire Protocol Compression between MongoDB drivers and mongo[ d|s] .
1010
11- Compression is achieved through a new bi-directional wire protocol opcode, referred to as OP_COMPRESSED.
11+ Compression is achieved through a new bi-directional wire protocol opcode, referred to as ` OP_COMPRESSED ` .
1212
1313Server side compressor support is checked during the initial MongoDB Handshake, and is compatible with all historical
1414versions of MongoDB. If a client detects a compatible compressor it will use the compressor for all valid requests.
@@ -79,9 +79,9 @@ If the server has no compression algorithms in common with the client, it sends
7979compression field. Clients MAY issue a log level event to inform the user, but MUST NOT error.
8080
8181When MongoDB server receives a compressor it can support it MAY reply to any and all requests using the selected
82- compressor, including the reply of the initial MongoDB Handshake. As each OP_COMPRESSED message contains the compressor
83- ID, clients MUST NOT assume which compressor each message uses, but MUST decompress the message using the compressor
84- identified in the OP_COMPRESSED opcode header.
82+ compressor, including the reply of the initial MongoDB Handshake. As each ` OP_COMPRESSED ` message contains the
83+ compressor ID, clients MUST NOT assume which compressor each message uses, but MUST decompress the message using the
84+ compressor identified in the ` OP_COMPRESSED ` opcode header.
8585
8686When compressing, clients MUST use the first compressor in the client's configured compressors list that is also in the
8787servers list.
@@ -121,7 +121,7 @@ Note that this value only applies to the client side compression level, not the
121121
122122### OP_COMPRESSED
123123
124- The new opcode, called OP_COMPRESSED, has the following structure:
124+ The new opcode, called ` OP_COMPRESSED ` , has the following structure:
125125
126126``` c
127127struct OP_COMPRESSED {
@@ -134,7 +134,7 @@ struct OP_COMPRESSED {
134134 int32_t originalOpcode;
135135 int32_t uncompressedSize;
136136 uint8_t compressorId;
137- char *compressedMessage;
137+ char *compressedMessage;
138138};
139139```
140140
@@ -183,17 +183,17 @@ authentication requests.
183183
184184Messages using the following commands MUST NOT be compressed:
185185
186- - hello
186+ - ` hello `
187187- legacy hello (see [ MongoDB Handshake Protocol] ( ../mongodb-handshake/handshake.md ) for details)
188- - saslStart
189- - saslContinue
190- - getnonce
191- - authenticate
192- - createUser
193- - updateUser
194- - copydbSaslStart
195- - copydbgetnonce
196- - copydb
188+ - ` saslStart `
189+ - ` saslContinue `
190+ - ` getnonce `
191+ - ` authenticate `
192+ - ` createUser `
193+ - ` updateUser `
194+ - ` copydbSaslStart `
195+ - ` copydbgetnonce `
196+ - ` copydb `
197197
198198## Test Plan
199199
@@ -316,11 +316,11 @@ normally.
316316 ` ` `
317317
318318- Create example program that authenticates to the server using SCRAM - SHA - 1 , then creates another user (MONGODB - CR ),
319- then runs hello followed with serverStatus.
319+ then runs ` hello` followed with ` serverStatus` .
320320
321321- Reconnect to the same server using the created MONGODB - CR credentials . Observe that the only command that was
322- decompressed on the server was ` serverStatus` , while the server replied with OP_COMPRESSED for at least the
323- serverStatus command.
322+ decompressed on the server was ` serverStatus` , while the server replied with ` OP_COMPRESSED` for at least the
323+ ` serverStatus` command.
324324
325325## Motivation For Change
326326
@@ -347,7 +347,7 @@ More recently, the MongoDB server added Zstandard (zstd) support for another mod
347347
348348The new argument provided to the MongoDB Handshake has no backwards compatible implications as servers that do not
349349expect it will simply ignore it . This means a server will therefore never reply with a list of acceptable compressors
350- which in turns means a client CANNOT use the OP_COMPRESSED opcode.
350+ which in turns means a client CANNOT use the ` OP_COMPRESSED` opcode.
351351
352352## Reference Implementation
353353
@@ -377,13 +377,13 @@ needing to (not) compress very few operations.
377377
378378 - No.
379379
380- - Can the server reply to the MongoDB Handshake/ hello compressed?
380+ - Can the server reply to the MongoDB Handshake/ hello be compressed?
381381
382382 - Yes, yes it can . Be aware it is completely acceptable for the server to use compression for any and all replies,
383383 using any supported compressor, when the client announced support for compression - this includes the reply to the
384- actual MongoDB Handshake/ hello where the support was announced.
384+ actual MongoDB Handshake/ ` hello` where the support was announced.
385385
386- - This is billed a MongoDB 3.6 feature -- but I hear it works with MongoDB3 .4 ?
386+ - This is billed a MongoDB 3.6 feature -- but I hear it works with MongoDB 3 .4?
387387
388388 - Yes, it does . All MongoDB versions support the ` compression` argument to the initial handshake and all MongoDB
389389 versions will reply with an intersection of compressors it supports . This works even with MongoDB 3.0 , as it will
@@ -398,7 +398,7 @@ needing to (not) compress very few operations.
398398
399399- My language supports xyz compressor, should I announce them all in the handshake?
400400
401- - No. But you are allowed to if you really want to make sure you can use that compressor with MongoDB 42 and your
401+ - No. But you are allowed to if you really want to make sure you can use that compressor with MongoDB 4.2 and your
402402 current driver versions.
403403
404404- My language does not support xzy compressor. What do I do?
0 commit comments