Skip to content

pymemcache.exceptions.MemcacheUnknownCommandError: b'get' when hitting maximum number of connections #550

Description

@cbowal

Hello!

I'm using:

  • django v4.2
  • memcache v1.6.22
  • pymemcache v4.0.0

I started seeing errors like this pop up:

  File "django/core/cache/backends/memcached.py", line 96, in get_many
          ret = self._cache.get_multi(key_map.keys())
  File "pymemcache/client/hash.py", line 398, in get_many
              result = self._safely_run_func(client, get_func, {}, *new_args, **kwargs)
  File "pymemcache/client/hash.py", line 211, in _safely_run_func
              result = func(*args, **kwargs)
  File "pymemcache/client/base.py", line 706, in get_many
          return self._fetch_cmd(b"get", keys, False, key_prefix=self.key_prefix)
  File "pymemcache/client/base.py", line 1149, in _fetch_cmd
                  self._raise_errors(line, name)
  File "pymemcache/client/base.py", line 1034, in _raise_errors
              raise MemcacheUnknownCommandError(name)
pymemcache.exceptions.MemcacheUnknownCommandError: b'get'

This was weird since 'get' is obviously a valid command.

Looking at the logs of the memcache instance I noticed that this is happening when I've hit the maximum number of connections. I'm seeing these memcache error logs:
ts=2023-11-16T19:27:25.256Z caller=exporter.go:771 level=error msg="Could not query stats settings" err="memcache: unexpected stats line format \"ERROR Too many open connections\\r\\n\""

I'm not too familiar with the pymemcache internals but it seems to be incorrectly raising MemcacheUnknownCommandError. I'm not sure what the expected error is when there's no available connection, perhaps MemcacheServerError or MemcacheUnexpectedCloseError.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions