handle mysql errors #3

Open
opened 2021-12-09 16:32:03 +00:00 by ben · 0 comments
Owner

when mysql restarts:

Traceback (most recent call last):
  File "/home/ben/.cache/pypoetry/virtualenvs/sudoisbot-7CbRIzNA-py3.8/lib/pytho
n3.8/site-packages/peewee.py", line 3129, in execute_sql
    cursor.execute(sql, params or ())
  File "/home/ben/.cache/pypoetry/virtualenvs/sudoisbot-7CbRIzNA-py3.8/lib/pytho
n3.8/site-packages/pymysql/cursors.py", line 163, in execute
    result = self._query(query)
  File "/home/ben/.cache/pypoetry/virtualenvs/sudoisbot-7CbRIzNA-py3.8/lib/pytho
n3.8/site-packages/pymysql/cursors.py", line 321, in _query
    conn.query(q)
  File "/home/ben/.cache/pypoetry/virtualenvs/sudoisbot-7CbRIzNA-py3.8/lib/pytho
n3.8/site-packages/pymysql/connections.py", line 505, in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
  File "/home/ben/.cache/pypoetry/virtualenvs/sudoisbot-7CbRIzNA-py3.8/lib/pytho
n3.8/site-packages/pymysql/connections.py", line 724, in _read_query_result
    result.read()
  File "/home/ben/.cache/pypoetry/virtualenvs/sudoisbot-7CbRIzNA-py3.8/lib/pytho
n3.8/site-packages/pymysql/connections.py", line 1069, in read
    first_packet = self.connection._read_packet()
  File "/home/ben/.cache/pypoetry/virtualenvs/sudoisbot-7CbRIzNA-py3.8/lib/pytho
n3.8/site-packages/pymysql/connections.py", line 676, in _read_packet
    packet.raise_for_error()
  File "/home/ben/.cache/pypoetry/virtualenvs/sudoisbot-7CbRIzNA-py3.8/lib/pytho
n3.8/site-packages/pymysql/protocol.py", line 223, in raise_for_error
    err.raise_mysql_exception(self._data)
  File "/home/ben/.cache/pypoetry/virtualenvs/sudoisbot-7CbRIzNA-py3.8/lib/pytho
n3.8/site-packages/pymysql/err.py", line 107, in raise_mysql_exception
    raise errorclass(errno, errval)
pymysql.err.OperationalError: (1927, 'Connection was killed')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/ben/projects/sudoisbot/sudoisbot/__init__.py", line 106, in main
    rc = args.func(args, config)
  File "/home/ben/projects/sudoisbot/sudoisbot/__init__.py", line 32, in run_sin
k
    return sudoisbot.sink.sink.main(args, config)
  File "/home/ben/projects/sudoisbot/sudoisbot/sink/sink.py", line 152, in main
    sink.listen(addr)
  File "/home/ben/projects/sudoisbot/sudoisbot/sink/sink.py", line 96, in listen
    self.handle_msg(topic, msg)
  File "/home/ben/projects/sudoisbot/sudoisbot/sink/sink.py", line 106, in handl
e_msg
    self.update_db(topic, msg)         # todo: keep records in sql
  File "/home/ben/projects/sudoisbot/sudoisbot/sink/sink.py", line 112, in updat
e_db
    Temperatures.insert_msg(msg)
  File "/home/ben/projects/sudoisbot/sudoisbot/sink/models.py", line 60, in inse
rt_msg
    return cls.create(
  File "/home/ben/.cache/pypoetry/virtualenvs/sudoisbot-7CbRIzNA-py3.8/lib/pytho
n3.8/site-packages/peewee.py", line 6338, in create
    inst.save(force_insert=True)
  File "/home/ben/.cache/pypoetry/virtualenvs/sudoisbot-7CbRIzNA-py3.8/lib/pytho
n3.8/site-packages/peewee.py", line 6548, in save
    pk = self.insert(**field_dict).execute()
  File "/home/ben/.cache/pypoetry/virtualenvs/sudoisbot-7CbRIzNA-py3.8/lib/pytho
n3.8/site-packages/peewee.py", line 1898, in inner
    return method(self, database, *args, **kwargs)
  File "/home/ben/.cache/pypoetry/virtualenvs/sudoisbot-7CbRIzNA-py3.8/lib/pytho
n3.8/site-packages/peewee.py", line 1969, in execute
    return self._execute(database)
  File "/home/ben/.cache/pypoetry/virtualenvs/sudoisbot-7CbRIzNA-py3.8/lib/pytho
n3.8/site-packages/peewee.py", line 2730, in _execute
    return super(Insert, self)._execute(database)
  File "/home/ben/.cache/pypoetry/virtualenvs/sudoisbot-7CbRIzNA-py3.8/lib/pytho
n3.8/site-packages/peewee.py", line 2465, in _execute
    cursor = database.execute(self)
  File "/home/ben/.cache/pypoetry/virtualenvs/sudoisbot-7CbRIzNA-py3.8/lib/pytho
n3.8/site-packages/peewee.py", line 3142, in execute
    return self.execute_sql(sql, params, commit=commit)
  File "/home/ben/.cache/pypoetry/virtualenvs/sudoisbot-7CbRIzNA-py3.8/lib/pytho
n3.8/site-packages/peewee.py", line 3136, in execute_sql
    self.commit()
  File "/home/ben/.cache/pypoetry/virtualenvs/sudoisbot-7CbRIzNA-py3.8/lib/pytho
n3.8/site-packages/peewee.py", line 2902, in __exit__
    reraise(new_type, new_type(exc_value, *exc_args), traceback)
  File "/home/ben/.cache/pypoetry/virtualenvs/sudoisbot-7CbRIzNA-py3.8/lib/pytho
n3.8/site-packages/peewee.py", line 185, in reraise
    raise value.with_traceback(tb)
  File "/home/ben/.cache/pypoetry/virtualenvs/sudoisbot-7CbRIzNA-py3.8/lib/pytho
n3.8/site-packages/peewee.py", line 3129, in execute_sql
    cursor.execute(sql, params or ())
  File "/home/ben/.cache/pypoetry/virtualenvs/sudoisbot-7CbRIzNA-py3.8/lib/pytho
n3.8/site-packages/pymysql/cursors.py", line 163, in execute
    result = self._query(query)
  File "/home/ben/.cache/pypoetry/virtualenvs/sudoisbot-7CbRIzNA-py3.8/lib/pytho
n3.8/site-packages/pymysql/cursors.py", line 321, in _query
    conn.query(q)
  File "/home/ben/.cache/pypoetry/virtualenvs/sudoisbot-7CbRIzNA-py3.8/lib/pytho
n3.8/site-packages/pymysql/connections.py", line 505, in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
  File "/home/ben/.cache/pypoetry/virtualenvs/sudoisbot-7CbRIzNA-py3.8/lib/pytho
n3.8/site-packages/pymysql/connections.py", line 724, in _read_query_result
    result.read()
  File "/home/ben/.cache/pypoetry/virtualenvs/sudoisbot-7CbRIzNA-py3.8/lib/pytho
n3.8/site-packages/pymysql/connections.py", line 1069, in read
    first_packet = self.connection._read_packet()
  File "/home/ben/.cache/pypoetry/virtualenvs/sudoisbot-7CbRIzNA-py3.8/lib/pytho
n3.8/site-packages/pymysql/connections.py", line 676, in _read_packet
    packet.raise_for_error()
  File "/home/ben/.cache/pypoetry/virtualenvs/sudoisbot-7CbRIzNA-py3.8/lib/pytho
n3.8/site-packages/pymysql/protocol.py", line 223, in raise_for_error
    err.raise_mysql_exception(self._data)
  File "/home/ben/.cache/pypoetry/virtualenvs/sudoisbot-7CbRIzNA-py3.8/lib/pytho
n3.8/site-packages/pymysql/err.py", line 107, in raise_mysql_exception
    raise errorclass(errno, errval)
peewee.OperationalError: (1927, 'Connection was killed')

so the actual errors are

pymysql.err.OperationalError: (1927, 'Connection was killed')

and

peewee.OperationalError: (1927, 'Connection was killed')

thees need to be handled. the first one seems to be an "inner" exception or something.

the proxy survives this just fine and starts caching values (it doesnt use mysql so it wouldnt fail).

the error happens in sink and screen_pub.

when mysql restarts: ``` Traceback (most recent call last): File "/home/ben/.cache/pypoetry/virtualenvs/sudoisbot-7CbRIzNA-py3.8/lib/pytho n3.8/site-packages/peewee.py", line 3129, in execute_sql cursor.execute(sql, params or ()) File "/home/ben/.cache/pypoetry/virtualenvs/sudoisbot-7CbRIzNA-py3.8/lib/pytho n3.8/site-packages/pymysql/cursors.py", line 163, in execute result = self._query(query) File "/home/ben/.cache/pypoetry/virtualenvs/sudoisbot-7CbRIzNA-py3.8/lib/pytho n3.8/site-packages/pymysql/cursors.py", line 321, in _query conn.query(q) File "/home/ben/.cache/pypoetry/virtualenvs/sudoisbot-7CbRIzNA-py3.8/lib/pytho n3.8/site-packages/pymysql/connections.py", line 505, in query self._affected_rows = self._read_query_result(unbuffered=unbuffered) File "/home/ben/.cache/pypoetry/virtualenvs/sudoisbot-7CbRIzNA-py3.8/lib/pytho n3.8/site-packages/pymysql/connections.py", line 724, in _read_query_result result.read() File "/home/ben/.cache/pypoetry/virtualenvs/sudoisbot-7CbRIzNA-py3.8/lib/pytho n3.8/site-packages/pymysql/connections.py", line 1069, in read first_packet = self.connection._read_packet() File "/home/ben/.cache/pypoetry/virtualenvs/sudoisbot-7CbRIzNA-py3.8/lib/pytho n3.8/site-packages/pymysql/connections.py", line 676, in _read_packet packet.raise_for_error() File "/home/ben/.cache/pypoetry/virtualenvs/sudoisbot-7CbRIzNA-py3.8/lib/pytho n3.8/site-packages/pymysql/protocol.py", line 223, in raise_for_error err.raise_mysql_exception(self._data) File "/home/ben/.cache/pypoetry/virtualenvs/sudoisbot-7CbRIzNA-py3.8/lib/pytho n3.8/site-packages/pymysql/err.py", line 107, in raise_mysql_exception raise errorclass(errno, errval) pymysql.err.OperationalError: (1927, 'Connection was killed') During handling of the above exception, another exception occurred: Traceback (most recent call last): File "<string>", line 1, in <module> File "/home/ben/projects/sudoisbot/sudoisbot/__init__.py", line 106, in main rc = args.func(args, config) File "/home/ben/projects/sudoisbot/sudoisbot/__init__.py", line 32, in run_sin k return sudoisbot.sink.sink.main(args, config) File "/home/ben/projects/sudoisbot/sudoisbot/sink/sink.py", line 152, in main sink.listen(addr) File "/home/ben/projects/sudoisbot/sudoisbot/sink/sink.py", line 96, in listen self.handle_msg(topic, msg) File "/home/ben/projects/sudoisbot/sudoisbot/sink/sink.py", line 106, in handl e_msg self.update_db(topic, msg) # todo: keep records in sql File "/home/ben/projects/sudoisbot/sudoisbot/sink/sink.py", line 112, in updat e_db Temperatures.insert_msg(msg) File "/home/ben/projects/sudoisbot/sudoisbot/sink/models.py", line 60, in inse rt_msg return cls.create( File "/home/ben/.cache/pypoetry/virtualenvs/sudoisbot-7CbRIzNA-py3.8/lib/pytho n3.8/site-packages/peewee.py", line 6338, in create inst.save(force_insert=True) File "/home/ben/.cache/pypoetry/virtualenvs/sudoisbot-7CbRIzNA-py3.8/lib/pytho n3.8/site-packages/peewee.py", line 6548, in save pk = self.insert(**field_dict).execute() File "/home/ben/.cache/pypoetry/virtualenvs/sudoisbot-7CbRIzNA-py3.8/lib/pytho n3.8/site-packages/peewee.py", line 1898, in inner return method(self, database, *args, **kwargs) File "/home/ben/.cache/pypoetry/virtualenvs/sudoisbot-7CbRIzNA-py3.8/lib/pytho n3.8/site-packages/peewee.py", line 1969, in execute return self._execute(database) File "/home/ben/.cache/pypoetry/virtualenvs/sudoisbot-7CbRIzNA-py3.8/lib/pytho n3.8/site-packages/peewee.py", line 2730, in _execute return super(Insert, self)._execute(database) File "/home/ben/.cache/pypoetry/virtualenvs/sudoisbot-7CbRIzNA-py3.8/lib/pytho n3.8/site-packages/peewee.py", line 2465, in _execute cursor = database.execute(self) File "/home/ben/.cache/pypoetry/virtualenvs/sudoisbot-7CbRIzNA-py3.8/lib/pytho n3.8/site-packages/peewee.py", line 3142, in execute return self.execute_sql(sql, params, commit=commit) File "/home/ben/.cache/pypoetry/virtualenvs/sudoisbot-7CbRIzNA-py3.8/lib/pytho n3.8/site-packages/peewee.py", line 3136, in execute_sql self.commit() File "/home/ben/.cache/pypoetry/virtualenvs/sudoisbot-7CbRIzNA-py3.8/lib/pytho n3.8/site-packages/peewee.py", line 2902, in __exit__ reraise(new_type, new_type(exc_value, *exc_args), traceback) File "/home/ben/.cache/pypoetry/virtualenvs/sudoisbot-7CbRIzNA-py3.8/lib/pytho n3.8/site-packages/peewee.py", line 185, in reraise raise value.with_traceback(tb) File "/home/ben/.cache/pypoetry/virtualenvs/sudoisbot-7CbRIzNA-py3.8/lib/pytho n3.8/site-packages/peewee.py", line 3129, in execute_sql cursor.execute(sql, params or ()) File "/home/ben/.cache/pypoetry/virtualenvs/sudoisbot-7CbRIzNA-py3.8/lib/pytho n3.8/site-packages/pymysql/cursors.py", line 163, in execute result = self._query(query) File "/home/ben/.cache/pypoetry/virtualenvs/sudoisbot-7CbRIzNA-py3.8/lib/pytho n3.8/site-packages/pymysql/cursors.py", line 321, in _query conn.query(q) File "/home/ben/.cache/pypoetry/virtualenvs/sudoisbot-7CbRIzNA-py3.8/lib/pytho n3.8/site-packages/pymysql/connections.py", line 505, in query self._affected_rows = self._read_query_result(unbuffered=unbuffered) File "/home/ben/.cache/pypoetry/virtualenvs/sudoisbot-7CbRIzNA-py3.8/lib/pytho n3.8/site-packages/pymysql/connections.py", line 724, in _read_query_result result.read() File "/home/ben/.cache/pypoetry/virtualenvs/sudoisbot-7CbRIzNA-py3.8/lib/pytho n3.8/site-packages/pymysql/connections.py", line 1069, in read first_packet = self.connection._read_packet() File "/home/ben/.cache/pypoetry/virtualenvs/sudoisbot-7CbRIzNA-py3.8/lib/pytho n3.8/site-packages/pymysql/connections.py", line 676, in _read_packet packet.raise_for_error() File "/home/ben/.cache/pypoetry/virtualenvs/sudoisbot-7CbRIzNA-py3.8/lib/pytho n3.8/site-packages/pymysql/protocol.py", line 223, in raise_for_error err.raise_mysql_exception(self._data) File "/home/ben/.cache/pypoetry/virtualenvs/sudoisbot-7CbRIzNA-py3.8/lib/pytho n3.8/site-packages/pymysql/err.py", line 107, in raise_mysql_exception raise errorclass(errno, errval) peewee.OperationalError: (1927, 'Connection was killed') ``` so the actual errors are ``` pymysql.err.OperationalError: (1927, 'Connection was killed') ``` and ``` peewee.OperationalError: (1927, 'Connection was killed') ``` thees need to be handled. the first one seems to be an "inner" exception or something. the proxy survives this just fine and starts caching values (it doesnt use mysql so it wouldnt fail). the error happens in sink and screen_pub.
Sign in to join this conversation.
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: ben/sudoisbot#3
No description provided.