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

Race condition on SharedKeys causes silent error

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Blocker
    • Resolution: Fixed
    • 2.6.0
    • 2.6.0
    • LiteCore
    • Security Level: Public

    Description

      This is quite hard to figure out, but about 6-7% of the time on .NET tests a race condition in LiteCore is triggered in the way that shared keys are persisted to the database. Without adding additional logging this was causing weird behavior due to silent errors and failure but what is happening is the following.

      1. Race on shared keys causes the keyString() method to mistakenly return null due to "unknown key"
      2. The JSON Encoder is fine with encoding a number as a key into a JSON document
      3. This gets transmitted to the other side via passive pusher to active puller
      4. The Fleece encode fails due to invalid keys (integers) being present
      5. The document is skipped due to this error and an innocuous document ended callback with a 0 error code is sent

      This took a long time to diagnose since it manifested as failure to call conflict resolvers (which makes sense since the document never gets properly saved). This most likely happened during the DBWorker refactor.

      Attachments

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

        Activity

          Build couchbase-lite-android-2.6.0-120 contains couchbase-lite-core commit 0dc30cf with commit message:
          Update Fleece to get bug fix for race in CBL-86

          build-team Couchbase Build Team added a comment - Build couchbase-lite-android-2.6.0-120 contains couchbase-lite-core commit 0dc30cf with commit message: Update Fleece to get bug fix for race in CBL-86

          Build couchbase-lite-log-2.7.0-79 contains couchbase-lite-core commit 0dc30cf with commit message:
          Update Fleece to get bug fix for race in CBL-86

          build-team Couchbase Build Team added a comment - Build couchbase-lite-log-2.7.0-79 contains couchbase-lite-core commit 0dc30cf with commit message: Update Fleece to get bug fix for race in CBL-86

          Build couchbase-lite-log-2.7.0-79 contains fleece commit a48cd9c with commit message:
          CBL-86 Plug a race inside of SharedKeys

          build-team Couchbase Build Team added a comment - Build couchbase-lite-log-2.7.0-79 contains fleece commit a48cd9c with commit message: CBL-86 Plug a race inside of SharedKeys

          Build couchbase-lite-cblite-2.7.0-5 contains couchbase-lite-core commit 0dc30cf with commit message:
          Update Fleece to get bug fix for race in CBL-86

          build-team Couchbase Build Team added a comment - Build couchbase-lite-cblite-2.7.0-5 contains couchbase-lite-core commit 0dc30cf with commit message: Update Fleece to get bug fix for race in CBL-86

          Build couchbase-lite-cblite-2.7.0-5 contains fleece commit a48cd9c with commit message:
          CBL-86 Plug a race inside of SharedKeys

          build-team Couchbase Build Team added a comment - Build couchbase-lite-cblite-2.7.0-5 contains fleece commit a48cd9c with commit message: CBL-86 Plug a race inside of SharedKeys

          People

            jimb Jim Borden
            jimb Jim Borden
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty