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

ns memcached socket pool larger than what memcached allows

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • backlog
    • 6.6.3, 7.0.3, 7.1.0
    • ns_server
    • None
    • Untriaged
    • 1
    • Unknown

    Description

      While looking at a customer issue where the number of ns_server to memcached "system" connections is exceeding the 5000 limit in memcached it was noticed the socket pool created by ns_server is larger than 5000. In ns_memcached_sockets_pool

      start_link() ->
          Options = [{name, ?MODULE},
                     {connection_timeout, 30000},
                     {pool_size_per_dest, 10000}],
          ns_connection_pool:start_link(Options).
      

      which calls

      init(Options) ->
          process_flag(priority, high),
          case lists:member({seed,1}, ssl:module_info(exports)) of
              true ->
                  %% Make sure that the ssl random number generator is seeded
                  %% This was new in R13 (ssl-3.10.1 in R13B vs. ssl-3.10.0 in R12B-5)
                  apply(ssl, seed, [crypto:strong_rand_bytes(255)]);
              false ->
                  ok
          end,
          Timeout = proplists:get_value(connection_timeout, Options),
          Size = proplists:get_value(pool_size_per_dest, Options),
          {ok, #ns_connection_pool{timeout = Timeout, pool_size_per_dest = Size}}.
      

      And so ns_server allows 10,000 connections before it starts queuing them

      handle_call({socket, Pid, Dest}, {Pid, _Ref} = From,
                  #ns_connection_pool{pool_size_per_dest = MaxSize} = State) ->
          {Reply0, State2} = find_socket(Dest, Pid, State),
          case Reply0 of
              {ok, _Socket} ->
                  State3 = monitor_client(Dest, From, State2),
                  {reply, Reply0, State3};
              no_socket ->
                  case dest_clients_count(Dest, State2) >= MaxSize of
                      true ->
                          {noreply, add_to_queue(Dest, From, State2)};   <<<<<<<<<<<<<<<<<<<
                      false ->
                          {reply, no_socket, monitor_client(Dest, From, State2)}
                  end
          end;
      

      The initial 10000 should be changed to 5000.

      Attachments

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

        Activity

          People

            steve.watanabe Steve Watanabe
            steve.watanabe Steve Watanabe
            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