Uploaded image for project: 'Couchbase Lite'
  1. Couchbase Lite
  2. CBL-1115

CBL purges accessible documents on filtered replication

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • 2.8.0
    • 2.7.0
    • iOS
    • Security Level: Public
    • None
    • Jay 28
    • 5

    Description

      Scenario

      • Doc test2 is created in channels [ foo , bar ].
      • User replicates channel foo and pulls rev 1 of the document.
      • Doc test2 is updated to remove it from channel foo, leaving just bar. (Edit: previously typo'd now corrected)
      • Doc test2 is updated again, remaining in channel bar only.(Edit: previously typo'd now corrected)
      • Some time passes
      • User replicates channel foo again.

      Expected behaviour

      • User's local DB stays at rev 1 for test2

      Observed behaviour

      *User's local DB purges test2

      Repro

      • Add doc

        $ curl localhost:4985/db/test2 -X PUT -H 'Content-type: application/json' -d '{"channels":["foo", "bar"]}'
         
        {"id":"test2","ok":true,"rev":"1-5467c30804fb9448df4873941c0c8ed8"}
        

      • Replicate channel foo from device and confirm doc is present:

      $ ~/Downloads/cblite ls "`find . -type d -name '*.cblite2'`"; ~/Downloads/cblite cat "`find . -type d -name '*.cblite2'`" test2
      test2
      {
        "_id": "test2",
        "channels": [
          "foo",
          "bar"
        ]
      }
      

      • Update doc to remove channel foo:

      $ curl localhost:4985/db/test2 -X PUT -H 'Content-type: application/json' -d '{"channels":["bar"], "_rev":"1-5467c30804fb9448df4873941c0c8ed8", "extra": "so extra"}'
       
      {"id":"test2","ok":true,"rev":"2-c4d10e1effc2e6bef6ac072e69c9ac59"}
      

      • Update doc again, so the removal rev is not the latest:

      Edit: this was the wrong snippet before - updated

      $ curl localhost:4985/db/test2 -X PUT -H 'Content-type: application/json' -d '{"channels":["bar"], "_rev":"2-c4d10e1effc2e6bef6ac072e69c9ac59", "extra": "so extra"}'
       
      {"id":"test2","ok":true,"rev":"3-989061051071c99469ac36657e86bdf3"}
      

      • Simulate time passing by restarting SG (to clear rev cache) and deleting the old rev backup from the CB bucket.
      • Replicate channel foo again, and check the state of the document in local db:

      $ ~/Downloads/cblite ls "`find . -type d -name '*.cblite2'`"; ~/Downloads/cblite cat "`find . -type d -name '*.cblite2'`" test2
      (No documents)
      Error: Document "test2" not found.
      

      †I'm unsure if we define this behaviour explicitly. In the case of the removal also being the latest, there's an argument for pulling that anyway. In this case however, the revision now in channel bar has no relation to channel foo and should not be pulled.

      Attachments

        Issue Links

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

          Activity

            People

              James Flather James Flather (Inactive)
              James Flather James Flather (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes

                  PagerDuty