iT邦幫忙

0

mysql 5.6 query 時 一直卡在sending_data 雙十連假前皆正常 回來後突然異常

  • 分享至 

  • xImage

問題 當 QUERY 使用到 join 時 會一值卡在 sending_data
但是該 QUERY 在連假前 基本上是秒出的 不明原因 連假後 同樣的 query 會卡在 sending_data 基本上主機沒有人動過

以下是 環境參數 以及一些設定 and debug 的資訊
根據資料 sending_data 包含了 實際到 硬碟 拿資料 以及 透過 網路傳輸至客戶端
由於環境是內網 網路問題 可忽略
硬碟部分則是 raid (不清楚模式)
系統 windows server 2016
DB 版本 mysql5.6
table 有分頁處理 每張表 都有數十萬筆資料 有的高達百萬
已關閉快取 (因為 參數很多 基本上不會 重複)
每張表皆有設置 複合index
mysql 可用32G 服務剛開就吃 21G 正常值??
有懷疑過 硬碟故障 但是同一台 sql server other datadase 卻可以正常工作
唯獨這個DB 使用 會有這個狀況 故排除 硬碟問題
更新
我們使用 heidisql GUI 觀察
我在 卡在 處於 sending_data 的process上 右鍵 有個 mariaDB.org EXPLAIN 分析器 當中內容 請看以下圖片
https://ithelp.ithome.com.tw/upload/images/20201014/20131746Bk6J983Eq8.jpg

所以這代表 sql 其實已經執行完成 取得結果 但是卡在網路 無法回傳?
my.cnf 設定擋
default_authentication_plugin=mysql_native_password
default-storage-engine=MYISAM (該服務除了半夜 會寫資料進去之外 正常上班時間都是查詢業務)
sql-mode="STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION"
log-output=FILE
general-log=0
slow-query-log=1
long_query_time=10

thread_stack = 512M

server-id = 2
expire_logs_days = 10
max_binlog_size = 100M
innodb_flush_log_at_trx_commit = 0
sync_binlog = 0
read_only = 1
secure-file-priv=""

max_connections=3000
table_open_cache=2048

tmp_table_size=5G

bulk_insert_buffer_size = 3G

myisam_max_sort_file_size=100G
myisam_sort_buffer_size=256M
key_buffer_size=16G
read_buffer_size=512M
read_rnd_buffer_size=512M

thread_concurrency=0

oringin 4 > 16

thread_cache_size=16

join_buffer_size=3G
max_allowed_packet=16M
max_connect_errors=100
open_files_limit=1024000
table_open_cache=8192
sort_buffer_size=256M
table_definition_cache=1400
binlog_row_event_max_size=8K
sync_master_info=10000
sync_relay_log=10000
sync_relay_log_info=10000
query_cache_type=0
query_cache_size = 0

back_log=80
flush_time=0

insert buffer

innodb_buffer_pool_size=32G
innodb_log_file_size=2G
innodb_log_buffer_size=128M
innodb_log_files_in_group=2
innodb_read_io_threads = 12
innodb_write_io_threads = 12
innodb_thread_concurrency=0
innodb_autoextend_increment=64
innodb_buffer_pool_instances=8
innodb_concurrency_tickets=5000
innodb_old_blocks_time=1000
innodb_open_files=300
innodb_page_size=16K
innodb_strict_mode=0
innodb_stats_on_metadata=0
innodb_lock_wait_timeout=8000
innodb_file_per_table=1
innodb_data_file_path = ibdata1:10M:autoextend
innodb_checksum_algorithm=0

以上 是目前收集到的資料 請版上大大為小弟指點迷津
預祝各位大大 事事順心

那個圖 , 看不清.....
paui2486 iT邦新手 5 級 ‧ 2020-10-14 16:03:12 檢舉
@一級屠豬士
不好意思 剛剛都在忙 補上 高清大圖
https://imgur.com/kcMFTY8
harrytsai iT邦新手 1 級 ‧ 2020-10-14 21:25:12 檢舉
這種可能要檢查一下tmp
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

1
rogeryao
iT邦超人 8 級 ‧ 2020-10-14 11:24:28
SELECT *
FROM information_schema.processlist
ORDER BY TIME DESC

找出最耗時的 sql 在優化試試

paui2486 iT邦新手 5 級 ‧ 2020-10-14 11:36:38 檢舉

你好 這個 sql 原本是可以正常執行的 但是現在不明原因 會卡在 sending_data (然後這個狀態所表示的範圍有點大 包含 實際到硬碟拿資料到 透過網路 回傳客戶端)

目前狀況並非不知道哪隻sql 造成的 謝謝你的建議

rogeryao iT邦超人 8 級 ‧ 2020-10-14 11:46:57 檢舉

我要發表回答

立即登入回答