1. 程式人生 > >Lost connection to MySQL server during query (by quqi99)

Lost connection to MySQL server during query (by quqi99)

問題

neutron designate日誌中發現錯誤"Got lower serial for", 並且建立zone時永遠停留在PENDING狀態.

解決

minidns中看到下列日誌:

var/log/designate/designate-mdns.log.2.gz:2018-10-23 23:27:36.016 94713 INFO designate.mdns.handler [req-26d8910d-61d5-4fd6-bc6b-df7acaf36c12 - - - - -] NotFound, refusing. Question was xxx.openstack-au-east-2.oc.xxx.com. IN SOA 
var/log/designate/designate-mdns.log.2.gz:2018-10-23 23:27:36.024 94713 WARNING designate.mdns.handler [req-fa5518dd-9506-44f8-a2ee-ee7d79ffaa3c - - - - -] ZoneNotFound while handling axfr request. Question was xxx.openstack-au-east-2.oc.xxx.com. IN AXFR: ZoneNotFound: Could not find Zone 

根據程式碼[1], 查詢DB時報ZoneNotFound從而導致無法構建SOA無法構建axfr response, 從而導致minidns master與bind9 slave無法做zone transfer, 這樣導致bind9 slave的serial number也無法更新, 最終在minidns notify時看到"Got lower serial for"

在發生ZoneNotFound的附近有下列日誌:

[req-b48612b0-ed3e-46d9-8510-6634282ef0a2 - - - - -] Database connection was found disconnected; reconnecting: DBConnectionError: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query') [SQL: u'SELECT 1']

於是, 用下列測試程式重現了上述DB error,

import time
from sqlalchemy.engine import create_engine
url = 'mysql+pymysql://[email protected]:3306/mysql'
engine = create_engine(url, pool_recycle=4).connect()
query = 'SELECT NOW();'
while True:
    print('Q1', engine.execute(query).fetchall())
    engine.execute('SET wait_timeout=2')
    time.sleep(3)
    print('Q2', engine.execute(query).fetchall())

或者使用oslo.db測試程式:

mysql -u root -p -e "SET GLOBAL wait_timeout=5, slow_query_log=on, long_query_time=0.0;"

$ cat test.py
import sys
import time
from oslo_config import cfg
from oslo_db import options as db_options
from oslo_db.sqlalchemy import session as db_session
from sqlalchemy.sql.expression import select
_facade = db_session.EngineFacade("mysql://[email protected]/test")
x = _facade.get_session()
print(x.scalar(select([23])))
time.sleep(5)
print(x.scalar(select([23])))

連線線的過期時間(pool_recycle, 連線池裡的連線空閒一段時間後自動釋放, oslo中預設是3600)不能大於伺服器端的wait_timeout時間(這裡是2, 預設是8小時). 所以應該設定wait_timeout大於3600, 或者haproxy中的配置大於3600.
wait_timeout是mysql的一個設定,主要是用來斷開不使用的資料庫連線。當連線空閒的時間達到wait_timeout設定的最大值時,mysql會主動切斷這個連線,以供別的客戶端連線資料庫。這個值一般是28800,也就是8小時。在mysql中可以通過: show variables like “%timeout%”;獲取。
另外,當資料庫主動切斷連線的時候,mysql客戶端並不知道這個連線已經被切斷,所以程式並不知道其已經無效了,如果mysql客戶端再不支援ReConnect,雙重的問題疊加在一起就會導致連線池返回無效連線的可能.

其他

mysqldump --single-transaction -u root -p designate --skip-extended-insert > /tmp/designate-$(date +%s).sql

Reference

相關推薦

Lost connection to MySQL server during query (by quqi99)

問題 neutron designate日誌中發現錯誤"Got lower serial for", 並且建立zone時永遠停留在PENDING狀態. 解決 minidns中看到下列日誌: var/log/designate/designate-mdns.lo

_mysql_exceptions.OperationalError: (2013, 'Lost connection to MySQL server during query')

RR 時間 bsp strong span serve 方式 同事 clas 最近寫了一個定時腳本,每天淩晨跑,每次跑時間很長。 在測試這個腳本的時候,跑了一個小時,發生一個錯誤,腳本中斷,錯誤如下: _mysql_exceptions.OperationalE

MySQL中查詢時"Lost connection to MySQL server during query"報錯的解決方案

解決 lose tool 查詢 不用 resolv 原因 網上 技術 一、問題描述: mysql數據庫查詢時,遇到下面的報錯信息: 二、原因分析: dw_user 表數據量比較大,直接查詢速度慢,容易"卡死",導致數據庫自動連接超時.... 三、解決辦法: 方案1.在my

Mysql max_allowed_packet Lost connection to MySQL server during query [Err] 2013 - Lost connection to MySQL server during query

[Err] 2013 - Lost connection to MySQL server during query 解決方法: [mysqld] max_allowed_packet=20971520 我設的是20M(1024*1024*20) = 20971520

解決workbench MySQL Error Code:2013. Lost connection to MySQL server during query

在MySQL中新建表格時出現了lost connection to MySQL的問題,在網上查了許多的方法修改timeout,max_allowed_packet。 一種方法是在cmd中修改value,但是我重啟mysql以後值就會恢復預設值,下面是修改的方法; 可以用show g

MySQL查詢錯誤程式碼: 2013 Lost connection to MySQL server during query

問題 遇到錯誤程式碼: 2013 Lost connection to MySQL server during query 分析 有許多原因,主要可能是wait_timeout,於是查詢各超時變數 SHOW VARIABLES LIKE "%timeout%"

ERROR 2013 at line 38: Lost connection to MySQL server during query

我的資料庫是mysql4.0 1、首先進入mysql。進入資料庫(use databases), 2、輸入: source scansealdb.sql (前提是必須把sql指令碼放到mysql\bin\目錄下) 3、在次輸入cmd.輸入命令:net start mysql。(

解決Lost connection to MySQL server during query錯誤方法

昨天使用Navicat for MySQL匯入MySQL資料庫的時候,出現了一個嚴重的錯誤,Lost connection to MySQL server during query,字面意思就是在查詢過程中丟失連線到MySQL伺服器。 [Msg] Decompressing

Lost connection to MySQL server during query 的解決

原語句如下: update qrcode_single set time_lose = now(),operator_id = '209150004'  where (qrcode_id in (select small_id from qrcode_related_box

Lost connection to MySQL server during query錯誤

 關於 Lost connection to MySQL server during query 錯誤2007年04月11日 星期三 00:56晚上在虛擬機器上繼續玩 Delphi for PHP,想試試其強大的資料庫控制元件。首先在 ubuntu 的 MySQL 上建立一個

使用navicat連接mysql連接錯誤:Lost connection to Mysql server at 'waiting for initial communication packet'

-a 無法連接 through cal .com 圖片 查找 解決 host 使用navicat時,報錯截圖如下: 原因分析: mysql開啟了DNS的反向解析功能,這樣mysql對連接的客戶端會進行DNS主機名查找。 mysql處理客戶端解析過程: 當

mysql鏈接錯誤:Lost connection to MySQL server at 'reading authorization packet', system error: 0

綁定 ati hostname .cn 進行 通過 bin 主機名 反向 在遠程連接mysql的時候,連接不上,出現如下報錯:Lost connection to MySQL server at ‘reading authorization packet‘, system

Mysql連接錯誤:Lost connection to Mysql server at 'waiting for initial communication packet'

註釋 機器 錯誤 命令 添加 tab localhost grant my.cnf配置 原因分析: mysql開啟了DNS的反向解析功能,這樣mysql對連接的客戶端會進行DNS主機名查找。 mysql處理客戶端解析過程: 1)當mysql的client連過來的時候,服

連線Mysql報錯lost connection to MySQL server at "waiting for initial communication packet

打開了3306埠,設定了user表host為'%',依然無法連線,telnet 3306埠不同,原因是配置檔案中設定了 bind-address: 127.0.0.1,(/etc/mysql/mysql.conf.d/sqld.cnf )把他註釋掉,埠能連上,但是又報下面的錯誤 lost conn

MySQL報錯解決方案:2013-Lost connection to MySQL server

安裝 今天 線下 ice 開啟 網絡 重新 round 報名 今天上課的時候,在搭建完MySQL測試環境中出現的問題,整理如下: 問題描述:搭建完MySQL,用遠程連接工具(Navicat)連接時報錯: 2013-Lost connection to MySQL serve

Lost connection to MySQL server at 'reading authorization packet', system error: 0_Mysql

timeout error: 配置 err system 設置 cti nec 域名解析 1.大多數時候設置"set global connect_timeout=60;"是可以解決問題的。 我們可以通過執行“SHOWSTATUS LIKE ‘aborted%‘”,可以觀察

mysql無法連線遠端資料庫(ERROR 2013:Lost connection to MySQL server

ERROR 2013 (HY000) Lost connection to MySQL server at ‘reading authorization packet’ 重啟mysql不行就重啟Windows伺服器!!!!!! 重啟mysql不行就重啟Windows伺服器!!!!

Lost connection to MySQL server at reading initial communic

Debian下Mysql伺服器遠端連線時會出現:Lost connection to MySQL server at 'reading initial communication packet'的錯誤,使用者許可權已設定為允許任意主機連線。其實問題出在Mysql的配置上,在my.cnf裡,有一條是bin

解決1129 host is blocked和MySQL Error (2013): Lost connection to MySQL server

首先說一下我這個問題產生的原因: 由於我的mysql連線的是公司的一臺主機上的服務,下班回家時更新了程式碼,重啟專案到一半的時候由於比較急就直接帶著電腦回家了(公司的主機外網不能訪問),所以資料庫連線就產生了錯誤,然而一直連線重試再連線導致了錯誤次數超過了max_conne

Lost connection to MySQL server at 'reading initial communication packet', system error: 104

報錯 SQLSTATE[HY000] [2013] Lost connection to MySQL server at 'reading initial communication packet', system error: 104 "Connection reset by pe