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

Crash when starting multiple live queries concurrently

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 3.1.4
    • 3.0.2
    • iOS
    • Security Level: Public
    • None
    • 4

    Description

      Based on https://github.com/couchbase/couchbase-lite-core/wiki/Thread-Safety, c4queryobs_* (except c4queryobs_create which is thread-safe) is under database-exclusive section. 

      Without doing that, when creating and starting multiple live queries concurrently, there could be a race condition as each live queries try to get the background database at the same time. The result of the race is that multiple background databases could be created but only the last one stays and the rest will be freed. Therefore, some live queries will hold on to the bad background database which will cause the crash when the database is used.

      LiteCore Code Reference: 
      https://github.com/couchbase/couchbase-lite-core/blob/release/3.1/LiteCore/Database/LiveQuerier.cc#L43
      https://github.com/couchbase/couchbase-lite-core/blob/release/3.1/LiteCore/Database/DatabaseImpl.cc#L410-L412

      To fix this issue, the platform code needs to follow the thread safety instruction when using c4queryobs_* functions by making sure to call them under database-execlusive lock.

      Attachments

        Issue Links

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

          Activity

            People

              pasin Pasin Suriyentrakorn
              pasin Pasin Suriyentrakorn
              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