Uploaded image for project: 'Couchbase C client library libcouchbase'
  1. Couchbase C client library libcouchbase
  2. CCBC-1630

Memory leak when rewriting packet to set collection id

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 3.3.12
    • None
    • None
    • None
    • 1
    • SDK06: FIT, PS, CXX

    Description

      In mixed-version cluster, with 7.2 and 6.6 nodes, it is possible when libcouchbase will decide to rewrite packet to insert ID of the default collection:
      https://github.com/couchbase/libcouchbase/blob/684931e59cd87e0c6292e8142c2b18897be5b10c/src/mc/mcreq.c#L291

      This side effect should be accounted for every time check_collection_id() is invoked, so that the caller will always update local pointers to the packet, and do not try to preserve pointer to the old packet.

      The issue is in
      https://github.com/couchbase/libcouchbase/blob/684931e59cd87e0c6292e8142c2b18897be5b10c/src/mc/mcreq.c#L334C6-L340

      void mcreq_enqueue_packet(mc_PIPELINE *pipeline, mc_PACKET *packet)
      {
          nb_SPAN *vspan = &packet->u_value.single;
          sllist_append(&pipeline->requests, &packet->slnode);
       
          packet = check_collection_id(pipeline, packet);
          netbuf_enqueue_span(&pipeline->nbmgr, &packet->kh_span, packet);
      

      Which preserves old pointer in "pipeline->requests" list, leaving that piece of memory leaking and accumulating over run time. The fix moves the check to the top of the function.

      Attachments

        Issue Links

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

          Activity

            People

              avsej Sergey Avseyev
              avsej Sergey Avseyev
              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