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

VBucketServerMap.EnsureIPEndPointsAreLoaded Not Thread Safe

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 2.7.19
    • 2.7.18
    • 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

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

        Activity

          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