Uploaded image for project: 'Couchbase Server'
  1. Couchbase Server
  2. MB-11203

SSL-enabled memcached will hang when given a large buffer containing many pipelined requests

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Blocker
    • 3.0
    • 3.0-Beta
    • couchbase-bucket
    • Security Level: Public

    Description

      Sample code which shows filling in a large number of pipelined requests being flushed over a single buffer.

      #include <libcouchbase/couchbase.h>
      #include <stdio.h>
      #include <stdlib.h>
      #include <string.h>
      static int remaining = 0;

      static void
      get_callback(lcb_t instance, const void *cookie, lcb_error_t err,
      const lcb_get_resp_t *resp)
      {
      printf("Remaining: %d \r", remaining);
      fflush(stdout);
      if (err != LCB_SUCCESS && err != LCB_KEY_ENOENT) {
      }
      remaining--;
      }

      static void
      stats_callback(lcb_t instance, const void *cookie, lcb_error_t err,
      const lcb_server_stat_resp_t *resp)
      {
      printf("Remaining: %d \r", remaining);
      fflush(stdout);
      if (err != LCB_SUCCESS && err != LCB_KEY_ENOENT) {
      }

      if (resp->v.v0.server_endpoint == NULL)

      { fflush(stdout); --remaining; }

      }

      #define ITERCOUNT 5000
      static int use_stats = 1;

      static void
      do_stat(lcb_t instance)

      { lcb_CMDSTATS cmd; memset(&cmd, 0, sizeof(cmd)); lcb_error_t err = lcb_stats3(instance, NULL, &cmd); assert(err==LCB_SUCCESS); }

      static void
      do_get(lcb_t instance)

      { lcb_error_t err; lcb_CMDGET cmd; memset(&cmd, 0, sizeof cmd); LCB_KREQ_SIMPLE(&cmd.key, "foo", 3); err = lcb_get3(instance, NULL, &cmd); assert(err==LCB_SUCCESS); }

      int main(void)
      {
      lcb_t instance;
      lcb_error_t err;
      struct lcb_create_st cropt =

      { 0 }

      ;
      cropt.version = 2;
      char *mode = getenv("LCB_SSL_MODE");
      if (mode && *mode == '3')

      { cropt.v.v2.mchosts = "localhost:11996"; }

      else

      { cropt.v.v2.mchosts = "localhost:12000"; }

      mode = getenv("USE_STATS");
      if (mode && *mode != '\0')

      { use_stats = 1; }

      else

      { use_stats = 0; }

      err = lcb_create(&instance, &cropt);
      assert(err == LCB_SUCCESS);

      err = lcb_connect(instance);
      assert(err == LCB_SUCCESS);
      lcb_wait(instance);
      assert(err == LCB_SUCCESS);
      lcb_set_get_callback(instance, get_callback);
      lcb_set_stat_callback(instance, stats_callback);
      lcb_cntl_setu32(instance, LCB_CNTL_OP_TIMEOUT, 20000000);
      int nloops = 0;

      while (1) {
      unsigned ii;
      lcb_sched_enter(instance);
      for (ii = 0; ii < ITERCOUNT; ++ii) {
      if (use_stats)

      { do_stat(instance); }

      else

      { do_get(instance); }

      remaining++;
      }
      printf("Done Scheduling.. L=%d\n", nloops++);
      lcb_sched_leave(instance);
      lcb_wait(instance);
      assert(!remaining);
      }
      return 0;
      }

      Attachments

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

        Activity

          People

            mnunberg Mark Nunberg (Inactive)
            mnunberg Mark Nunberg (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              PagerDuty