P
P
pcdesign2015-05-03 18:28:46
MySQL
pcdesign, 2015-05-03 18:28:46

How to deal with the error: "sqlalchemy.exc.InterfaceError: (InterfaceError) 2013: Lost connection to MySQL"?

There is a site on flask.
Occasionally, about 1 time in two days, such errors occur.

sqlalchemy.exc.InterfaceError: (InterfaceError) 2013: Lost connection to MySQL server during query 'SELECT


This happens, as I understand it, when MySQL restarts for some reason.

In the mysql log:
150312 14:20:22 [Note] /usr/libexec/mysqld: Normal shutdown

150312 14:20:22 [Note] Event Scheduler: Purging the queue. 0 events
150312 14:20:22  InnoDB: Starting shutdown...
150312 14:20:23  InnoDB: Shutdown completed; log sequence number 13754751080
150312 14:20:23 [Note] /usr/libexec/mysqld: Shutdown complete

150312 14:20:23 mysqld_safe mysqld from pid file /var/run/mariadb/mariadb.pid ended
150312 14:20:41 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
150312 14:20:41 InnoDB: The InnoDB memory heap is disabled
150312 14:20:41 InnoDB: Mutexes and rw_locks use GCC atomic builtins
150312 14:20:41 InnoDB: Compressed tables use zlib 1.2.7
150312 14:20:41 InnoDB: Using Linux native AIO
150312 14:20:41 InnoDB: Initializing buffer pool, size = 128.0M
150312 14:20:41 InnoDB: Completed initialization of buffer pool
150312 14:20:41 InnoDB: highest supported file format is Barracuda.
150312 14:20:42  InnoDB: Waiting for the background threads to start
150312 14:20:43 Percona XtraDB (http://www.percona.com) 5.5.40-MariaDB-36.1 started; log sequence number 13754751080
150312 14:20:43 [Note] Plugin 'FEEDBACK' is disabled.
150312 14:20:43 [Note] Server socket created on IP: '0.0.0.0'.
150312 14:20:43 [Note] Event Scheduler: Loaded 0 events
150312 14:20:43 [Note] /usr/libexec/mysqld: ready for connections.
Version: '5.5.40-MariaDB'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  MariaDB Server
150323 15:14:18 [Note] /usr/libexec/mysqld: Normal shutdown

150323 15:14:18 [Note] Event Scheduler: Purging the queue. 0 events
150323 15:14:18  InnoDB: Starting shutdown...
150323 15:14:18  InnoDB: Waiting for 16 pages to be flushed
150323 15:14:18  InnoDB: Shutdown completed; log sequence number 14011502490
150323 15:14:18 [Note] /usr/libexec/mysqld: Shutdown complete

150323 15:14:18 mysqld_safe mysqld from pid file /var/run/mariadb/mariadb.pid ended
150323 15:14:19 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
150323 15:14:19 InnoDB: The InnoDB memory heap is disabled
150323 15:14:19 InnoDB: Mutexes and rw_locks use GCC atomic builtins
150323 15:14:19 InnoDB: Compressed tables use zlib 1.2.7
150323 15:14:19 InnoDB: Using Linux native AIO
150323 15:14:19 InnoDB: Initializing buffer pool, size = 128.0M
150323 15:14:19 InnoDB: Completed initialization of buffer pool
150323 15:14:19 InnoDB: highest supported file format is Barracuda.
150323 15:14:19  InnoDB: Waiting for the background threads to start
150323 15:14:20 Percona XtraDB (http://www.percona.com) 5.5.40-MariaDB-36.1 started; log sequence number 14011502490
150323 15:14:20 [Note] Plugin 'FEEDBACK' is disabled.
150323 15:14:20 [Note] Server socket created on IP: '0.0.0.0'.
150323 15:14:20 [Note] Event Scheduler: Loaded 0 events
150323 15:14:20 [Note] /usr/libexec/mysqld: ready for connections.
Version: '5.5.40-MariaDB'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  MariaDB Server
150414 15:47:49 [Note] /usr/libexec/mysqld: Normal shutdown

150414 15:47:49 [Note] Event Scheduler: Purging the queue. 0 events
150414 15:47:50  InnoDB: Starting shutdown...
150414 15:47:50  InnoDB: Shutdown completed; log sequence number 14440827849
150414 15:47:50 [Note] /usr/libexec/mysqld: Shutdown complete

150414 15:47:50 mysqld_safe mysqld from pid file /var/run/mariadb/mariadb.pid ended
150414 15:47:51 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
150414 15:47:51 InnoDB: The InnoDB memory heap is disabled
150414 15:47:51 InnoDB: Mutexes and rw_locks use GCC atomic builtins
150414 15:47:51 InnoDB: Compressed tables use zlib 1.2.7
150414 15:47:51 InnoDB: Using Linux native AIO
150414 15:47:51 InnoDB: Initializing buffer pool, size = 128.0M
150414 15:47:51 InnoDB: Completed initialization of buffer pool
150414 15:47:51 InnoDB: highest supported file format is Barracuda.
150414 15:47:51  InnoDB: Waiting for the background threads to start
150414 15:47:52 Percona XtraDB (http://www.percona.com) 5.5.40-MariaDB-36.1 started; log sequence number 14440827849
150414 15:47:52 [Note] Plugin 'FEEDBACK' is disabled.
150414 15:47:52 [Note] Server socket created on IP: '0.0.0.0'.
150414 15:47:52 [Note] Event Scheduler: Loaded 0 events
150414 15:47:52 [Note] /usr/libexec/mysqld: ready for connections.
Version: '5.5.40-MariaDB'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  MariaDB Server


And this is what is in my.cnf

cat /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
net_read_timeout= 180
# Я дописал net_read_timeout= 180
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd

[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid

#
# include all files from the config directory
#
!includedir /etc/my.cnf.d

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
sim3x, 2015-05-03
@pcdesign

The Internet suggests that either someone restarted the server, or someone got privileges and restarted the service, or that max_connections= can help
https://www.google.com/search?q=%2Fusr%2Flibexec%2.. .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question