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

Sync Gateway Syncs Empty Documents created by ACID transaction

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 6.5.0
    • None
    • cbl, sgw
    • CB 6.5.0 on RHEL 7.7
    • Untriaged
    • Centos 64-bit
    • 1
    • Unknown

    Description

      Empty docs are created on the server before ACID Transactions are committed. See MB-39941 for details. 

      If a Sync Gateway is syncing documents from the bucket, these empty documents are immediately synced to the CBLite devices. After commit, mobile will get another doc with the full contents. The revision number of the doc increments after commit. Also, the contents of the doc are stored in the xattrs. Which means the empty docs are not really empty. For large docs, this means that the same doc will sync twice! 

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          graham.pople Graham Pople added a comment -

          Amrish Raje this should be partially resolved by the work being done in TXNJ-125 and MB-37374.  I've already explained that on other tickets you've created so I won't belabour it here.  The initial staged insert will be ignored by Sync Gateway so it won't double sync.

          graham.pople Graham Pople added a comment - Amrish Raje  this should be partially resolved by the work being done in TXNJ-125 and  MB-37374 .  I've already explained that on other tickets you've created so I won't belabour it here.  The initial staged insert will be ignored by Sync Gateway so it won't double sync.
          adamf Adam Fraser added a comment -

          Hi Graham Pople - we should probably have a meeting to discuss, as I'd like to understand how best to avoid Sync Gateway attempting to process non-committed transactions. Here's a background on the triggers for Sync Gateway import, though.

          Sync Gateway runs an import process to generate mobile metadata for documents that are mutated by someone other than Sync Gateway.  This metadata is stored in a system xattr.  Import is only triggered when the document cas and a crc32c hash of the document body (not including user xattrs) are different than that used for the previous import. 

          I think that means that for transactions updating existing documents should be fine - until the transaction is committed and the document body updated, Sync Gateway's import won't be triggered.

          For inserts, import ignores documents with null bodies, so I wouldn't have expected import to be triggered until the transaction commits if you're leaving the body null until that point.  If it's doing something else (e.g. empty body of the form {}), that would result in an unwanted import.  

          adamf Adam Fraser added a comment - Hi Graham Pople  - we should probably have a meeting to discuss, as I'd like to understand how best to avoid Sync Gateway attempting to process non-committed transactions. Here's a background on the triggers for Sync Gateway import, though. Sync Gateway runs an import process to generate mobile metadata for documents that are mutated by someone other than Sync Gateway.  This metadata is stored in a system xattr.  Import is only triggered when the document cas and a crc32c hash of the document body (not including user xattrs) are different than that used for the previous import.  I think that means that for transactions updating existing documents should be fine - until the transaction is committed and the document body updated, Sync Gateway's import won't be triggered. For inserts, import ignores documents with null bodies, so I wouldn't have expected import to be triggered until the transaction commits if you're leaving the body null until that point.  If it's doing something else (e.g. empty body of the form {}), that would result in an unwanted import.  
          graham.pople Graham Pople added a comment -

          Hi Adam Fraser, thanks for the explanation and I'll message you about a meeting.

          graham.pople Graham Pople added a comment - Hi Adam Fraser , thanks for the explanation and I'll message you about a meeting.

          Thanks for the update Graham Pople

          priya.rajagopal Priya Rajagopal added a comment - Thanks for the update Graham Pople
          graham.pople Graham Pople added a comment -

          I'm going to close this out, as this is going to be resolved once Couchbase Server 6.6 is released.

          In 6.6 staged inserts will no longer create an empty document, so they will no longer be synced.  And the other types of staged mutations (replaces and removes) are already not synced, as they do not change the body (only the xattrs).

          graham.pople Graham Pople added a comment - I'm going to close this out, as this is going to be resolved once Couchbase Server 6.6 is released. In 6.6 staged inserts will no longer create an empty document, so they will no longer be synced.  And the other types of staged mutations (replaces and removes) are already not synced, as they do not change the body (only the xattrs).

          People

            graham.pople Graham Pople
            amrish_raje@infosys.com Amrish Raje
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty