Uploaded image for project: 'Drivers'
  1. Drivers
  2. DRIVERS-381

Add support for reading and writing OP_COMPRESSED

    • Type: Icon: New Feature New Feature
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Component/s: None
    • None

      MongoDB 3.4:

      • Enable compression with
        mongod --networkMessageCompressors snappy
        
      • Only supports snappy and noop
      • Compresses all responses if a supported compressor was provided in the initial isMaster (including the initial response to the isMaster!), irregardless if the request was compressed or not
      • It will compress using the first compressor configured in --networkMessageCompressors snappy,noop that was also present in the isMaster response

      MongoDB 3.5-current-RC:

      • Adds support for zlib
      • snappy enabled by default (no need for --networkMessageCompressors)
      • To enable zlib or noop, use --networkMessageCompressors (remember to include snappy in the list if desired)
      • Compresses the response if the request was compressed. uses the first compressor configured in the --networkMessageCompressors (defaults to snappy if none provided) that was also present in the isMaster response

      MongoDB 3.6:


      OP_COMPRESSED

      The new opcode looks like:

      struct OP_COMPRESSED {
          struct MsgHeader {
              int32  messageLength;
              int32  requestID;
              int32  responseTo;
              int32  opCode = 2012;
          };
          int32_t  originalOpcode;
          int32_t  uncompressedSize;
          uint8_t  compressorId;
          char    *compressedMessage;
      };
      


      originalOpcode Contains the value of the wrapped opcode.
      uncompressedSize The size of the deflated compressedMessage, which excludes the MsgHeader
      compressorId The ID of the compressor that compressed the message
      compressedMessage The opcode itself, excluding the MsgHeader


      Currently supported/defined compressorIds are:

      compressorId isMaster value Description
      0 noop The content of the message is uncompressed. Testing Only
      1 snappy The content of the message is compressed using snappy
      2 zlib The content of the message is compressed using zlib
      3-255 reserved Reserved for future used


      Negotiation / handshake

      Compression is negotiated during the MongoDB Handshake:

          {
              isMaster: 1,
              client: {}, /* See MongoDB Handshake */
              compression: ["snappy", "zlib"]
          }
      


      New Connection String Options

      compressors Comma separated values. Must warn when given unsupported compressor
      zlibCompressionLevel Integer values for -1 to 9

      zlibCompressionLevel meaning (informative, this is how zlib defines them)

      -1 Default Compression (usually 6)
      0 No compression
      1 Best Speed
      9 Best Compression


      Blacklisted commands

      The following commands MUST NOT be compressed:

      • isMaster
      • saslStart
      • saslContinue
      • getnonce
      • authenticate
      • createUser
      • updateUser
      • copydbSaslStart
      • copydbgetnonce
      • copydb

            Assignee:
            Unassigned Unassigned
            Reporter:
            bjori Hannes Magnusson
            Votes:
            1 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved: