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

Fix side effects related to singleton CouchbaseHttpClient

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 3.2.4
    • 3.2.3
    • library
    • None
    • 1

    Description

      We currently use a singleton CouchbaseHttpClient which inherits from HttpClient. Using a singleton HttpClient is common practice and known to A) improve performance by allowing HTTP keep-alives and reducing DNS requests and B) avoid problems with TCP port depletion.

      However, the common practice is misunderstood. In fact, it is the HttpClientHandler within the HttpClient that should be reused, more so than the HttpClient itself. Additionally, it should only be reused for a limited period of time. Failure to replace the HttpClientHandler occasionally can cause unexpected network failures if DNS names are changed to refer to new IP addresses.

      More importantly, our current pattern of a singleton CouchbaseHttpClient introduces side effects. There are multiple places in the codebase where we are setting properties on this client as if it was transient when it is in fact a singleton. Setting these properties is affecting other usages of the singleton by other internal services. Examples include setting the Timeout to infinite or setting a per-connection ID on DefaultRequestHeaders.

      Attachments

        Issue Links

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

          Activity

            People

              btburnett3 Brant Burnett
              btburnett3 Brant Burnett
              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