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

OrphanReporter is blocking a thread on the ThreadPool

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 3.2.2
    • 3.2.3
    • library
    • None
    • 1

    Description

      The current OrphanReporter is using Task.Factory.StartNew with TaskCreationOptions.LongRunning to start the polling loop. This will spin up a dedicated thread for the polling loop, as was clearly desired since it's a long running process.

      However, the method it is calling, DoWork, is also an async method. Once the first "await Task.Delay" is reached, the created thread is done. After the first delay is done, the remaining work will be scheduled back on the ThreadPool. It will then block that thread when it reaches _queue.TryTake (a BlockingCollection call).

      Instead, this method could be constructed using a Channel<T> which allows the use of `await` to get items from the queue. Then it could safely run on the thread pool without blocking, and a plain `Task.Run` without LongRunning could be used to start the process. This is similar to the DataFlow approach used in ConfigHandler, but more modern and efficient, DataFlow is heavier than is required for this purpose.

      Attachments

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

        Activity

          There are no comments yet on this issue.

          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