Botocore raising OSError: [errno 14] Bad Address - amazon-dynamodb

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.

Related

python integration with azure gremlin not working

I am trying to mimic as mentioned in GIT.
I almost commented everything, and just trying to run simply
g.V().count()
my connection details are correct, and matched to documentation...
I am getting following error.
Traceback (most recent call last):
File "c:\Users\PrasaRak\OneDrive\gremlin_azure_function\connect.py", line 193, in <module>
count_vertices(client)
File "c:\Users\PrasaRak\OneDrive\gremlin_azure_function\connect.py", line 116, in count_vertices
callback = client.submit(_gremlin_count_vertices)
File "C:\Users\PrasaRak\Miniconda3\envs\learn-gremlin\lib\site-packages\gremlin_python\driver\client.py", line 127, in submit
return self.submitAsync(message, bindings=bindings, request_options=request_options).result()
File "C:\Users\PrasaRak\Miniconda3\envs\learn-gremlin\lib\site-packages\gremlin_python\driver\client.py", line 148, in submitAsync
return conn.write(message)
File "C:\Users\PrasaRak\Miniconda3\envs\learn-gremlin\lib\site-packages\gremlin_python\driver\connection.py", line 55, in write
self.connect()
File "C:\Users\PrasaRak\Miniconda3\envs\learn-gremlin\lib\site-packages\gremlin_python\driver\connection.py", line 45, in connect
self._transport.connect(self._url, self._headers)
File "C:\Users\PrasaRak\Miniconda3\envs\learn-gremlin\lib\site-packages\gremlin_python\driver\tornado\transport.py", line 40, in connect
self._ws = self._loop.run_sync(
File "C:\Users\PrasaRak\Miniconda3\envs\learn-gremlin\lib\site-packages\tornado\ioloop.py", line 576, in run_sync
return future_cell[0].result()
File "C:\Users\PrasaRak\Miniconda3\envs\learn-gremlin\lib\site-packages\tornado\simple_httpclient.py", line 269, in run
stream = yield self.tcp_client.connect(
File "C:\Users\PrasaRak\Miniconda3\envs\learn-gremlin\lib\site-packages\tornado\gen.py", line 1133, in run
value = future.result()
File "C:\Users\PrasaRak\Miniconda3\envs\learn-gremlin\lib\site-packages\tornado\gen.py", line 1147, in run
yielded = self.gen.send(value)
File "C:\Users\PrasaRak\Miniconda3\envs\learn-gremlin\lib\site-packages\tornado\tcpclient.py", line 232, in connect
af, addr, stream = yield connector.start(connect_timeout=timeout)
File "C:\Users\PrasaRak\Miniconda3\envs\learn-gremlin\lib\site-packages\tornado\tcpclient.py", line 87, in start
self.try_connect(iter(self.primary_addrs))
File "C:\Users\PrasaRak\Miniconda3\envs\learn-gremlin\lib\site-packages\tornado\tcpclient.py", line 104, in try_connect
stream, future = self.connect(af, addr)
File "C:\Users\PrasaRak\Miniconda3\envs\learn-gremlin\lib\site-packages\tornado\tcpclient.py", line 276, in _create_stream
return stream, stream.connect(addr)
File "C:\Users\PrasaRak\Miniconda3\envs\learn-gremlin\lib\site-packages\tornado\iostream.py", line 1325, in connect
self._add_io_state(self.io_loop.WRITE)
File "C:\Users\PrasaRak\Miniconda3\envs\learn-gremlin\lib\site-packages\tornado\iostream.py", line 1157, in _add_io_state
self.io_loop.add_handler(
File "C:\Users\PrasaRak\Miniconda3\envs\learn-gremlin\lib\site-packages\tornado\platform\asyncio.py", line 83, in add_handler
self.asyncio_loop.add_writer(
File "C:\Users\PrasaRak\Miniconda3\envs\learn-gremlin\lib\asyncio\events.py", line 507, in add_writer
raise NotImplementedError
NotImplementedError
I think i got the answer.
issue was with python 3.8 & Tornado compatibility, when it comes to asyncio.
more info is at this link
fix was to add following line in tornado/platform/asyncio.py
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) # python-3.8.0a4

table graphite.account_profile does not exist

I have installed Graphite on Ubuntu 18.04 using apt-get
I have also installed MySQL, created a database as well as a user in it
I have run graphite-manage migrate auth to migrate the database models
But I get this error:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/django/core/handlers/exception.py", line 41, in inner
response = get_response(request)
File "/usr/lib/python2.7/dist-packages/django/core/handlers/base.py", line 249, in _legacy_get_response
response = self._get_response(request)
File "/usr/lib/python2.7/dist-packages/django/core/handlers/base.py", line 187, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/usr/lib/python2.7/dist-packages/django/core/handlers/base.py", line 185, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/lib/python2.7/dist-packages/graphite/composer/views.py", line 35, in composer
profile = getProfile(request)
File "/usr/lib/python2.7/dist-packages/graphite/user_util.py", line 25, in getProfile
return default_profile()
File "/usr/lib/python2.7/dist-packages/graphite/user_util.py", line 44, in default_profile
profile, created = Profile.objects.get_or_create(user=user)
File "/usr/lib/python2.7/dist-packages/django/db/models/manager.py", line 85, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/django/db/models/query.py", line 464, in get_or_create
return self.get(**lookup), False
File "/usr/lib/python2.7/dist-packages/django/db/models/query.py", line 374, in get
num = len(clone)
File "/usr/lib/python2.7/dist-packages/django/db/models/query.py", line 232, in len
self._fetch_all()
File "/usr/lib/python2.7/dist-packages/django/db/models/query.py", line 1118, in _fetch_all
self._result_cache = list(self._iterable_class(self))
File "/usr/lib/python2.7/dist-packages/django/db/models/query.py", line 53, in iter
results = compiler.execute_sql(chunked_fetch=self.chunked_fetch)
File "/usr/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 899, in execute_sql
raise original_exception
ProgrammingError: (1146, u"Table 'graphite.account_profile' doesn't exist")
Just execute:
graphite-manage migrate --run-syncdb
And graphite-migrate will create account_profile and other tables for you.

Getting an error while starting airflow worker

I have installed airflow and trying to start the worker on the mac. But I am getting following error. Unable to identify what must be causing this issue.
[2018-05-02 15:37:11,458: CRITICAL/MainProcess] Unrecoverable error: TypeError("Invalid argument(s) 'visibility_timeout' sent to create_engine(), using configuration MySQLDialect_mysqldb/QueuePool/Engine. Please check that the keyword arguments are appropriate for this combination of components.",)
Traceback (most recent call last):
File "/Users/manishz/anaconda2/envs/airflow/lib/python2.7/site-packages/celery/worker/worker.py", line 203, in start
self.blueprint.start(self)
File "/Users/manishz/anaconda2/envs/airflow/lib/python2.7/site-packages/celery/bootsteps.py", line 119, in start
step.start(parent)
File "/Users/manishz/anaconda2/envs/airflow/lib/python2.7/site-packages/celery/bootsteps.py", line 370, in start
return self.obj.start()
File "/Users/manishz/anaconda2/envs/airflow/lib/python2.7/site-packages/celery/worker/consumer/consumer.py", line 320, in start
blueprint.start(self)
File "/Users/manishz/anaconda2/envs/airflow/lib/python2.7/site-packages/celery/bootsteps.py", line 119, in start
step.start(parent)
File "/Users/manishz/anaconda2/envs/airflow/lib/python2.7/site-packages/celery/worker/consumer/tasks.py", line 37, in start
c.connection, on_decode_error=c.on_decode_error,
File "/Users/manishz/anaconda2/envs/airflow/lib/python2.7/site-packages/celery/app/amqp.py", line 302, in TaskConsumer
**kw
File "/Users/manishz/anaconda2/envs/airflow/lib/python2.7/site-packages/kombu/messaging.py", line 386, in __init__
self.revive(self.channel)
File "/Users/manishz/anaconda2/envs/airflow/lib/python2.7/site-packages/kombu/messaging.py", line 408, in revive
self.declare()
File "/Users/manishz/anaconda2/envs/airflow/lib/python2.7/site-packages/kombu/messaging.py", line 421, in declare
queue.declare()
File "/Users/manishz/anaconda2/envs/airflow/lib/python2.7/site-packages/kombu/entity.py", line 605, in declare
self._create_queue(nowait=nowait, channel=channel)
File "/Users/manishz/anaconda2/envs/airflow/lib/python2.7/site-packages/kombu/entity.py", line 614, in _create_queue
self.queue_declare(nowait=nowait, passive=False, channel=channel)
File "/Users/manishz/anaconda2/envs/airflow/lib/python2.7/site-packages/kombu/entity.py", line 649, in queue_declare
nowait=nowait,
File "/Users/manishz/anaconda2/envs/airflow/lib/python2.7/site-packages/kombu/transport/virtual/base.py", line 531, in queue_declare
self._new_queue(queue, **kwargs)
File "/Users/manishz/anaconda2/envs/airflow/lib/python2.7/site-packages/kombu/transport/sqlalchemy/__init__.py", line 82, in _new_queue
self._get_or_create(queue)
File "/Users/manishz/anaconda2/envs/airflow/lib/python2.7/site-packages/kombu/transport/sqlalchemy/__init__.py", line 70, in _get_or_create
obj = self.session.query(self.queue_cls) \
File "/Users/manishz/anaconda2/envs/airflow/lib/python2.7/site-packages/kombu/transport/sqlalchemy/__init__.py", line 65, in session
_, Session = self._open()
File "/Users/manishz/anaconda2/envs/airflow/lib/python2.7/site-packages/kombu/transport/sqlalchemy/__init__.py", line 56, in _open
engine = self._engine_from_config()
File "/Users/manishz/anaconda2/envs/airflow/lib/python2.7/site-packages/kombu/transport/sqlalchemy/__init__.py", line 51, in _engine_from_config
return create_engine(conninfo.hostname, **transport_options)
File "/Users/manishz/anaconda2/envs/airflow/lib/python2.7/site-packages/sqlalchemy/engine/__init__.py", line 424, in create_engine
return strategy.create(*args, **kwargs)
File "/Users/manishz/anaconda2/envs/airflow/lib/python2.7/site-packages/sqlalchemy/engine/strategies.py", line 162, in create
engineclass.__name__))
TypeError: Invalid argument(s) 'visibility_timeout' sent to create_engine(), using configuration MySQLDialect_mysqldb/QueuePool/Engine. Please check that the keyword arguments are appropriate for this combination of components.
Appreciate any help on it.
Thanks in avance
Manish

"Adapter does not support geometry" exception when declaring geometry field

In my application, an "Adapter does not support geometry" exception is being thrown when attempting to create a field of type, "geometry()". For my test application, I'm using an sqlite DB (production will use postgres):
db = DAL('sqlite://storage.sqlite', pool_size = 1, fake_migrate_all= False)
The DB table in question is declared within a class, inside of a module, and contains a several fields, some of which contain location data:
from gluon.dal import Field, geoPoint, geoLine, geoPolygon
class Info(Base_Model):
def __init__(...):
try:
db.define_table('t_info',
...
Field('f_geolocation', type='geometry()',
label = current.T('Geolocation')),
Field('f_city', type='string',
label = current.T('City')),
...
except Exception as e:
...
Edit:
As per Anthony's suggestion, I've modified the DAL constructor call to the following:
db = DAL('spatialite://storage.sqlite', pool_size = 1)
It produces the following error message:
Traceback (most recent call last):
File "C:\...\web2py\gluon\restricted.py", line 227, in restricted
exec ccode in environment
File "C:/My_Stuff/Programs/web2py/applications/Proj/models/db.py", line 38, in <module>
db = DAL('spatialite://storage.sqlite', pool_size = 1)
File "C:\...\web2py\gluon\packages\dal\pydal\base.py", line 171, in __call__
obj = super(MetaDAL, cls).__call__(*args, **kwargs)
File "C:\...\web2py\gluon\packages\dal\pydal\base.py", line 457, in __init__
raise RuntimeError("Failure to connect, tried %d times:\n%s" % (attempts, tb))
RuntimeError: Failure to connect, tried 5 times:
Traceback (most recent call last):
File "C:\...\web2py\gluon\packages\dal\pydal\base.py", line 435, in __init__
self._adapter = ADAPTERS[self._dbname](**kwargs)
File "C:\...\web2py\gluon\packages\dal\pydal\adapters\base.py", line 53, in __call__
obj = super(AdapterMeta, cls).__call__(*args, **kwargs)
File "C:\...\web2py\gluon\packages\dal\pydal\adapters\sqlite.py", line 169, in __init__
if do_connect: self.reconnect()
File "C:\...\web2py\gluon\packages\dal\pydal\connection.py", line 129, in reconnect
self.after_connection_hook()
File "C:\...\web2py\gluon\packages\dal\pydal\connection.py", line 81, in after_connection_hook
self.after_connection()
File "C:\...\web2py\gluon\packages\dal\pydal\adapters\sqlite.py", line 177, in after_connection
self.execute(r'SELECT load_extension("%s");' % libspatialite)
File "C:\...\web2py\gluon\packages\dal\pydal\adapters\base.py", line 1326, in execute
return self.log_execute(*a, **b)
File "C:\...\web2py\gluon\packages\dal\pydal\adapters\base.py", line 1320, in log_execute
ret = self.cursor.execute(command, *a[1:], **b)
OperationalError: The specified module could not be found.
If you want to use geometry fields with SQLite, you must use the spatialite adapter, which makes use of the SpatialLite extension for SQLite:
db = DAL('spatialite://storage.sqlite', pool_size = 1)
Note, you must have spatialite installed for this to work.

Openstack RDO can't connect to MySQL server on '10.0.3.139

Recently my Openstack (use RDO) has an error. Admin user's password is correct. I can use mysql by "keystone", "root". This is detail(/var/log/keystone/keystone.log) :
(OperationalError) (2003, "Can't connect to MySQL server on '10.0.3.139' (111)") None None
Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/keystone/common/wsgi.py", line 238, in __call__
result = method(context, **params)
File "/usr/lib/python2.6/site-packages/keystone/token/controllers.py", line 127, in authenticate
auth_token_data, roles_ref=roles_ref, catalog_ref=catalog_ref)
File "/usr/lib/python2.6/site-packages/keystone/common/manager.py", line 44, in _wrapper
return f(*args, **kw)
File "/usr/lib/python2.6/site-packages/keystone/token/providers/uuid.py", line 386, in issue_v2_token
self.token_api.get_token(token_id)
File "/usr/lib/python2.6/site-packages/keystone/token/core.py", line 128, in get_token
token_ref = self._get_token(unique_id)
File "/usr/lib/python2.6/site-packages/dogpile/cache/region.py", line 936, in decorate
should_cache_fn)
File "/usr/lib/python2.6/site-packages/dogpile/cache/region.py", line 588, in get_or_create
async_creator) as value:
File "/usr/lib/python2.6/site-packages/dogpile/core/dogpile.py", line 158, in __enter__
return self._enter()
File "/usr/lib/python2.6/site-packages/dogpile/core/dogpile.py", line 98, in _enter
generated = self._enter_create(createdtime)
File "/usr/lib/python2.6/site-packages/dogpile/core/dogpile.py", line 149, in _enter_create
created = self.creator()
File "/usr/lib/python2.6/site-packages/dogpile/cache/region.py", line 565, in gen_value
created_value = creator()
File "/usr/lib/python2.6/site-packages/dogpile/cache/region.py", line 932, in creator
return fn(*arg, **kw)
File "/usr/lib/python2.6/site-packages/keystone/token/core.py", line 140, in _get_token
return self.driver.get_token(token_id)
File "/usr/lib/python2.6/site-packages/keystone/token/backends/sql.py", line 46, in get_token
token_ref = session.query(TokenModel).get(token_id)
File "/usr/lib64/python2.6/site-packages/SQLAlchemy-0.7.8-py2.6-linux-x86_64.egg/sqlalchemy/orm/query.py", line 775, in get
return self._load_on_ident(key)
File "/usr/lib64/python2.6/site-packages/SQLAlchemy-0.7.8-py2.6-linux-x86_64.egg/sqlalchemy/orm/query.py", line 2512, in _load_on_ident
return q.one()
File "/usr/lib64/python2.6/site-packages/SQLAlchemy-0.7.8-py2.6-linux-x86_64.egg/sqlalchemy/orm/query.py", line 2184, in one
ret = list(self)
File "/usr/lib64/python2.6/site-packages/SQLAlchemy-0.7.8-py2.6-linux-x86_64.egg/sqlalchemy/orm/query.py", line 2227, in __iter__
return self._execute_and_instances(context)
File "/usr/lib64/python2.6/site-packages/SQLAlchemy-0.7.8-py2.6-linux-x86_64.egg/sqlalchemy/orm/query.py", line 2240, in _execute_and_instances
close_with_result=True)
File "/usr/lib64/python2.6/site-packages/SQLAlchemy-0.7.8-py2.6-linux-x86_64.egg/sqlalchemy/orm/query.py", line 2231, in _connection_from_session
**kw)
File "/usr/lib64/python2.6/site-packages/SQLAlchemy-0.7.8-py2.6-linux-x86_64.egg/sqlalchemy/orm/session.py", line 730, in connection
close_with_result=close_with_result)
File "/usr/lib64/python2.6/site-packages/SQLAlchemy-0.7.8-py2.6-linux-x86_64.egg/sqlalchemy/orm/session.py", line 736, in _connection_for_bind
return engine.contextual_connect(**kwargs)
File "/usr/lib64/python2.6/site-packages/SQLAlchemy-0.7.8-py2.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 2490, in contextual_connect
self.pool.connect(),
File "/usr/lib64/python2.6/site-packages/SQLAlchemy-0.7.8-py2.6-linux-x86_64.egg/sqlalchemy/pool.py", line 224, in connect
return _ConnectionFairy(self).checkout()
File "/usr/lib64/python2.6/site-packages/SQLAlchemy-0.7.8-py2.6-linux-x86_64.egg/sqlalchemy/pool.py", line 387, in __init__
rec = self._connection_record = pool._do_get()
File "/usr/lib64/python2.6/site-packages/SQLAlchemy-0.7.8-py2.6-linux-x86_64.egg/sqlalchemy/pool.py", line 741, in _do_get
con = self._create_connection()
File "/usr/lib64/python2.6/site-packages/SQLAlchemy-0.7.8-py2.6-linux-x86_64.egg/sqlalchemy/pool.py", line 188, in _create_connection
return _ConnectionRecord(self)
File "/usr/lib64/python2.6/site-packages/SQLAlchemy-0.7.8-py2.6-linux-x86_64.egg/sqlalchemy/pool.py", line 270, in __init__
self.connection = self.__connect()
File "/usr/lib64/python2.6/site-packages/SQLAlchemy-0.7.8-py2.6-linux-x86_64.egg/sqlalchemy/pool.py", line 330, in __connect
connection = self.__pool._creator()
File "/usr/lib64/python2.6/site-packages/SQLAlchemy-0.7.8-py2.6-linux-x86_64.egg/sqlalchemy/engine/strategies.py", line 80, in connect
return dialect.connect(*cargs, **cparams)
File "/usr/lib64/python2.6/site-packages/SQLAlchemy-0.7.8-py2.6-linux-x86_64.egg/sqlalchemy/engine/default.py", line 281, in connect
return self.dbapi.connect(*cargs, **cparams)
File "/usr/lib64/python2.6/site-packages/MySQLdb/__init__.py", line 81, in Connect
return Connection(*args, **kwargs)
File "/usr/lib64/python2.6/site-packages/MySQLdb/connections.py", line 187, in __init__
super(Connection, self).__init__(*args, **kwargs2)
OperationalError: (OperationalError) (2003, "Can't connect to MySQL server on '10.0.3.139' (111)") None None
What's wrong with MySQL ? Could someone give me some advice ?
make sure mysql service is running using
service mysql status
next make sure it is listening on "10.0.3.139".
By default mysql listens on localhost.
To change that edit /etc/mysql/my.cnf and set the bind-address to 0.0.0.0 and restart the service. This will make it to listen on all the available interfaces.
Finally you have to make sure the mysql database, user and password are configured properly in /etc/keystone/keystone.conf and also that the user/database are created in mysql.
Use the below link for more details.
http://docs.openstack.org/grizzly/openstack-compute/install/apt/content/install-keystone.html

Resources