Uploaded image for project: 'Couchbase .NET client library'
  1. Couchbase .NET client library
  2. NCBC-2607

VBucketServerMap.EnsureIPEndPointsAreLoaded Not Thread Safe

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.7.18
    • 2.7.19
    • library
    • None
    • 1

    Description

      The current implementation has changes to reduce lock contention. However, the tests outside of the lock statement can throw exceptions if they execute while the work inside the lock statement is processing on a separate thread.

      This bug was introduced by https://github.com/couchbase/couchbase-net-client/commit/0b7d32205d5ff45eef42bf46318e67489324eee0 in 2.7.12

      • Should use .Count instead of .Any(), which is thread-safe. Any enumerates the collection, which will cause an exception if the collection is mutated
      • Within the lock, the field shouldn't be assigned until after the collection is fully built

      https://forums.couchbase.com/t/ensureipendpointsareloaded-is-not-thread-safe/26857/2

      Side note: Using "list.Count != 0" is actually more performant than "list.Any()" prior to .NET 5 because it avoids building an enumerator (https://github.com/dotnet/corefx/pull/40377)

      Attachments

        For Gerrit Dashboard: NCBC-2607
        # Subject Branch Project Status CR V

        Activity

          There are no comments yet on this issue.

          People

            jmorris Jeff Morris
            btburnett3 Brant Burnett
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty