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

Save document could be blocked when using database change listener

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Critical
    • 3.1.7
    • 3.1.3
    • C
    • Security Level: Public
    • None
    • C-iOS 129
    • 4

    Description

      Save document could be blocked when using database change listener if there is another thread saves a document on a different database instance at the same time (slightly before but still in progress).

      Root Cause

      1. The default collection of the database instance "A" is holding the database lock for saving a document. While holding the lock in the document save logic, it will need to first open a transaction. However, it needs to wait for its transaction to be opened as there is an opened transaction pending on the other thread for saving a document into the database instance "B".

      2. At the end of the committed transaction for saving a document into the database instance "B", the change notification is notified to the change listener added to the default collection of the database instance "A". To send the change notification, it needs to get the database instance from the default collection. However, to get the database instance, it needs to acquire the database lock which is currently held by The default collection of the database instance "A". Therefore the deadlock happens.

      Solution:

      Restructure the code so that acquiring the database instance of the collection doesn't require the lock. This restructuring has already been done in the master or release/3.2 branch as part of removing collection and scope cache.

      Attachments

        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:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty