Uploaded image for project: 'C++ Couchbase Client'
  1. C++ Couchbase Client
  2. CXXCBC-71

Race condition between bootstrap completion and first operation

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 1.0.0-beta
    • None
    • None
    • None
    • 1

    Description

      There is a race on bootstrapped_ and pending_buffer_ in mcbp_session between bootstrap completing and the scheduling of the first operation.

       

      invoke bootstrap handler callback https://github.com/couchbaselabs/couchbase-cxx-client/blob/597f818b43ce922f68669f7d829efe15005e72a8/couchbase/io/mcbp_session.hxx#L1192

      operation scheduled and bootstrapped_ is false https://github.com/couchbaselabs/couchbase-cxx-client/blob/597f818b43ce922f68669f7d829efe15005e72a8/couchbase/io/mcbp_session.hxx#L842

      bootstrapped_ set to true https://github.com/couchbaselabs/couchbase-cxx-client/blob/597f818b43ce922f68669f7d829efe15005e72a8/couchbase/io/mcbp_session.hxx#L1199

      check pending buffer -> empty https://github.com/couchbaselabs/couchbase-cxx-client/blob/597f818b43ce922f68669f7d829efe15005e72a8/couchbase/io/mcbp_session.hxx#L1202

      add to pending buffer https://github.com/couchbaselabs/couchbase-cxx-client/blob/597f818b43ce922f68669f7d829efe15005e72a8/couchbase/io/mcbp_session.hxx#L846

      Pending buffer is never read from again so the scheduled operation is never written to the socket and eventually times out. The sequence of events with debug statements can be seen here

      https://github.com/couchbaselabs/couchbase-cxx-client/runs/4788322382?check_suite_focus=true

      [2022-01-12 11:22:08.398] [8743,8743] [info] 0ms, check bootstrapped
      [2022-01-12 11:22:08.398] [8743,8746] [info] 0ms, bootstrap set to true
      [2022-01-12 11:22:08.398] [8743,8743] [debug] 0ms, [516c1d6c-41dd-452f-d264-7db527b3e45a/a63965e9-b164-4b17-06f3-a8b4ee26173d/plain/default] <127.0.0.1/127.0.0.1:11210> the stream is not ready yet, put the message into pending buffer, opaque=8
      [2022-01-12 11:22:08.398] [8743,8746] [trace] 0ms, [516c1d6c-41dd-452f-d264-7db527b3e45a/a63965e9-b164-4b17-06f3-a8b4ee26173d/plain/default] <127.0.0.1/127.0.0.1:11210> MCBP send, opaque=9,  80 b5 00 00 00 00 00 00 00 00 00 00 09 00 00 00 00 00 00 00 00 00 00 00
      [2022-01-12 11:22:08.398] [8743,8746] [info] 0ms, flush pending buffer
      [2022-01-12 11:22:08.398] [8743,8743] [info] 0ms, add to pending buffer
      

      Attachments

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

        Activity

          People

            avsej Sergey Avseyev
            jake.rawsthorne Jake Rawsthorne
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes