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

Keys in SharedKeys were reverted and released while they are still in used

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Critical
    • 3.0
    • 3.0
    • LiteCore
    • Security Level: Public
    • None
    • Jianmin 45
    • 5

    Description

      I have updated LiteCore (3dc6336cf452ecb985e49764dbe20016cbcf028d) to uptake the version-vector update for iOS. A unit test that tests a conflict handler to be called twice due to a conflict when saving a merged doc; the test passed before updating the lite-core.

      Failed Test:

      https://github.com/couchbase/couchbase-lite-ios/blob/feature/vv-lite-core/Objective-C/Tests/DatabaseTest.m#L774

      How to reproduce:

      1. Get couchbase-lite-ios, checkout feature/vv-lite-core branch, and update submodules.
      2. Enable DatabaseTest.m's _testConflictHandlerCalledTwice by removing the underscore and run the test

      Log: 

      https://gist.github.com/pasin/268c3e0566f7a3e0e5ffc278bec004dc

      Analysis:

      1. When the conflict handler is called the first time, the call to set the merged dictionary in this line probably causes the shared key to be updated (I'm not 100% sure as I couldn't see the code that updates the SharedKeys), but without this update, the problem will not occur.
      2. The merged doc from the first time of conflict handler call is failed to save to due to another conflict. This causes a transaction that saved the merged doc to be aborted. Based on the log, some keys in the SharedKeys table will be reverted as well. However, those reverted keys are still in use by the document being saved in the database.
      3. When the conflict handler is called the second time, calling toDictionary() on the doc being saved in this line has an error as it tries to access the keys in the SharedKeys that were reverted and released.

       

       

       

       

       

      Attachments

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

        Activity

          People

            Jayahari.Vavachan Jay Vavachan
            pasin Pasin Suriyentrakorn
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty