Uploaded image for project: 'Couchbase Server'
  1. Couchbase Server
  2. MB-62976

[BP 7.2.7] XDCR - Recompression is missed in mobile mode before replicating the mutation

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Major
    • 7.2.7
    • Morpheus, 7.6.2
    • XDCR

    Description

      In the mobile mode, XDCR will need to decompress data to read xattrs section and update HLV etc, if the body received is in a compressed format.

      Right now, to re-compress the decompressed body before replicating, we have the following logic in mobile mode:

      https://github.com/couchbase/goxdcr/blob/master/parts/xmem_nozzle.go#L1476

      The body is recompressed only if:

      maxEncodedLen := snappy.MaxEncodedLen(len(mc_req.Body))
      if maxEncodedLen > 0 && maxEncodedLen < len(mc_req.Body) {
            // compress mc_req.body
      }

      But a positive maxEncodedLen is always: (Refer https://github.com/golang/snappy/blob/v0.0.4/encode.go#L78)

      32 + len(mc_req.Body) + len(mc_req.Body)/6 

      which is always greater than len(mc_req.Body)

      So the decompressed body is never re-compressed.

       

      A potential solution could be:

      1. Keep note of the pre-decompressed body length

      2. Decompress body, keep note of the new body length

      3. Update xattrs (HLV etc), use the same doc body -> updateSystemXattrsForTarget(...)

      3. If length in (1) < length in (2), compress it back [Since we don't modify the doc body and assume xattrs are compressible] 

      A side note: Snappy compression is only supported for *_with_meta, and this should be skipped for subdoc command.

      The change should also be such that it honours the XDCR replication setting for compression - https://docs.couchbase.com/server/current/xdcr-reference/xdcr-advanced-settings.html#xdcr-compression-type-values

      Attachments

        Issue Links

          For Gerrit Dashboard: MB-62976
          # Subject Branch Project Status CR V

          Activity

            People

              aditya.sood Aditya Sood
              aditya.sood Aditya Sood
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There is 1 open Gerrit change

                  PagerDuty