首页 > 解决方案 > Botocore 引发 OSError: [errno 14] 错误地址

问题描述

OSError: [errno 14] Bad Address当我使用 pynamodb 模型时,我的 Python 服务器正在随机提升。这个问题发生在我的任何 pynamodb 模型中,并且很少发生。大多数调用都会成功。

当 botocore 从 file 读取时引发错误/usr/local/lib/python3.7/site-packages/botocore/data/dynamodb/2012-08-10/service-2.json。我不知道为什么会发生这种情况以及为什么它是随机的。

我正在使用Python 3.7.3Django 2.2.2Pynamodb 3.3.3Gunicorn 19.9.0。我在python:3.7-slimKubernetes 管理的 Docker 基础上运行服务器。

例子:

  >>> 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

更新:

此特定问题是由于 pod 内存不足。当我将我的服务器与Scout集成时会发生这种情况。除此问题外,该应用程序的其余部分工作正常,并且该错误并未表明内存问题。在我提高吊舱中的内存后,它被修复了。

标签: amazon-dynamodbpython-3.7botocore

解决方案


推荐阅读