Botocore raising OSError: [errno 14] Bad Address

Viewed 5845

My Python server is raising random OSError: [errno 14] Bad Address when I use pynamodb Model. This issue is happening in any of my pynamodb Models and is very rare to occur. Most of the calls will be successful.

The error is raised when botocore reads from file /usr/local/lib/python3.7/site-packages/botocore/data/dynamodb/2012-08-10/service-2.json. I have no idea why this happens and why it is random.

I'm using Python 3.7.3, Django 2.2.2, Pynamodb 3.3.3 and Gunicorn 19.9.0. I'm running the server on Docker base python:3.7-slim managed by Kubernetes.

Example:

  >>> from pynamodb.models import Model
  >>> class User(Model):
  ...     hash = UnicodeAttribute(hash_key=True)
  ...     username = UnicodeAttribute(null=True)
  ...     class Meta:
  ...         table_name = "user"
  ...         read_capacity_units = 10
  ...         write_capacity_units = 10
  ...         region = "us-west-2"
  ... 
  >>> user = User.get("valid-user-id")
  Traceback (most recent call last):
  File "<input>", line 11, in <module>
      user = User.get("valid-user-id")
  File "pynamodb/models.py", line 485, in get
    hash_key, range_key = cls._serialize_keys(hash_key, range_key)
  File "pynamodb/models.py", line 1372, in _serialize_keys
    hash_key = cls._hash_key_attribute().serialize(hash_key)
  File "pynamodb/models.py", line 1219, in _hash_key_attribute
    hash_keyname = cls._get_meta_data().hash_keyname
  File "pynamodb/models.py", line 1262, in _get_meta_data
    cls._meta_table = MetaTable(cls._get_connection().describe_table())
  File "pynamodb/connection/table.py", line 263, in describe_table
    return self.connection.describe_table(self.table_name)
  File "pynamodb/connection/base.py", line 659, in describe_table
    tbl = self.get_meta_table(table_name, refresh=True)
  File "pynamodb/connection/base.py", line 504, in get_meta_table
    data = self.dispatch(DESCRIBE_TABLE, operation_kwargs)
  File "pynamodb/connection/base.py", line 313, in dispatch
    data = self._make_api_call(operation_name, operation_kwargs)
  File "pynamodb/connection/base.py", line 341, in _make_api_call
    operation_model = self.client._service_model.operation_model(operation_name)
  File "pynamodb/connection/base.py", line 492, in client
    self._client = self.session.create_client(SERVICE_NAME, self.region, endpoint_url=self.host)
  File "botocore/session.py", line 838, in create_client
    client_config=config, api_version=api_version)
  File "botocore/client.py", line 79, in create_client
    service_model = self._load_service_model(service_name, api_version)
  File "botocore/client.py", line 117, in _load_service_model
    api_version=api_version)
  File "botocore/loaders.py", line 132, in _wrapper
    data = func(self, *args, **kwargs)
  File "botocore/loaders.py", line 383, in load_service_model
    model = self.load_data(full_path)
  File "botocore/loaders.py", line 132, in _wrapper
    data = func(self, *args, **kwargs)
  File "botocore/loaders.py", line 420, in load_data
    found = self.file_loader.load_file(possible_path)
  File "botocore/loaders.py", line 173, in load_file
    payload = fp.read().decode('utf-8')
  OSError: [Errno 14] Bad address

UPDATE:

This specific issue was due to a lack of memory in the pods. It happens when I integrate my server with Scout. Other than this issue the rest of the app worked fine, and the error didn't suggest a memory issue. It was fixed after I raise the memory in the pod.

0 Answers
Related