自適應雜湊索引引起的不定時MySQL崩潰重啟

來源:互聯網
上載者:User

我們先看一下這個報錯日誌:

InnoDB: Warning: a long semaphore wait:--Thread 140593224754944 has waited at btr0cur.c line 528 for 241.00 seconds the semaphore:X-lock on RW-latch at 0x7fd9142bfcc8 created in file dict0dict.c line 1838a writer (thread id 140570526021376) has reserved it in mode exclusivenumber of readers 0, waiters flag 1, lock_word: 0Last time read locked in file btr0cur.c line 535Last time write locked in file /pb2/build/sb_0-10180689-1378752874.69/mysql-5.5.34/storage/innobase/btr/btr0cur.c line 528InnoDB: Warning: a long semaphore wait:--Thread 140570431108864 has waited at btr0cur.c line 528 for 241.00 seconds the semaphore:X-lock on RW-latch at 0x7fd9142bfcc8 created in file dict0dict.c line 1838a writer (thread id 140570526021376) has reserved it in mode exclusivenumber of readers 0, waiters flag 1, lock_word: 0Last time read locked in file btr0cur.c line 535Last time write locked in file /pb2/build/sb_0-10180689-1378752874.69/mysql-5.5.34/storage/innobase/btr/btr0cur.c line 528……………………END OF INNODB MONITOR OUTPUT============================InnoDB: ###### Diagnostic info printed to the standard error streamInnoDB: Error: semaphore wait has lasted > 600 secondsInnoDB: We intentionally crash the server, because it appears to be hung.140101 4:32:58 InnoDB: Assertion failure in thread 140570570065664 in file srv0srv.c line 2502InnoDB: We intentionally generate a memory trap.InnoDB: Submit a detailed bug report to http://bugs.mysql.com.InnoDB: If you get repeated assertion failures or crashes, evenInnoDB: immediately after the mysqld startup, there may beInnoDB: corruption in the InnoDB tablespace. Please refer toInnoDB: http://dev.mysql.com/doc/refman/5.5/...-recovery.htmlInnoDB: about forcing recovery.20:32:58 UTC - mysqld got signal 6 ;This could be because you hit a bug. It is also possible that this binaryor one of the libraries it was linked against is corrupt, improperly built,or misconfigured. This error can also be caused by malfunctioning hardware.We will try our best to scrape up some info that will hopefully helpdiagnose the problem, but since we have already crashed,something is definitely wrong and this may fail.key_buffer_size=16777216read_buffer_size=131072max_used_connections=608max_threads=1600thread_count=516connection_count=515It is possible that mysqld could use up tokey_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 444459 K bytes of memoryHope that's ok; if not, decrease some variables in the equation.Thread pointer: 0x0Attempting backtrace. You can use the following information to find outwhere mysqld died. If you see no messages after this, something wentterribly wrong...stack_bottom = 0 thread_stack 0x30000/usr/local/mysql/bin/mysqld(my_print_stacktrace+0x35)[0x7a5f15]/usr/local/mysql/bin/mysqld(handle_fatal_signal+0x403)[0x673a13]/lib/libpthread.so.0(+0xef60)[0x7fde6901cf60]/lib/libc.so.6(gsignal+0x35)[0x7fde68219165]/lib/libc.so.6(abort+0x180)[0x7fde6821bf70]/usr/local/mysql/bin/mysqld[0x7ff2ce]/lib/libpthread.so.0(+0x68ba)[0x7fde690148ba]/lib/libc.so.6(clone+0x6d)[0x7fde682b602d]The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html containsinformation that should help you find out what is causing the crash.131231 04:34:11 mysqld_safe Number of processes running now: 0131231 04:34:11 mysqld_safe mysqld restarted


這台機器淩晨MySQL進程崩潰,錯誤記錄檔裡全都是
InnoDB: Warning: a long semaphore wait
--Thread 140570431108864 has waited at btr0cur.c line 528 for 241.00 seconds the semaphore:
X-lock on RW-latch at 0x7fd9142bfcc8 created in file dict0dict.c line 1838

查看監控圖參考25日至31日)

650) this.width=650;" src="http://www.bkjia.com/uploads/allimg/140103/0031194T3-0.jpg" title="semaphore.jpg" alt="wKioOVLE5fKwEiwxAACONro_77c509.jpg" />

發現spin waits和OS waits等待時間相當高,在手冊裡查到了這一句話:

You can monitor the use of the adaptive hash index and the contention for its use in the SEMAPHORES section of the output of the SHOW ENGINE INNODB STATUS command. If you see many threads waiting on an RW-latch created in btr0sea.c, then it might be useful to disable adaptive hash indexing.


Sometimes, the read/write lock that guards access to the adaptive hash index can become a source of contention under heavy workloads, such as multiple concurrent joins.


由於自適應雜湊索引造成大量的鎖爭用,進而堵塞很多進程,最終導致MySQL崩潰重啟。


找到原因後,關閉了自適應雜湊索引,觀察了一天后參考效能圖1月1日),spin waits和OS waits等待時間逐漸減少。

set global innodb_adaptive_hash_index = 0;


最終病因找到解決之。


參考手冊:

650) this.width=650;" src="http://www.bkjia.com/uploads/allimg/140103/0031191232-1.jpg" title="1.jpg" alt="wKioJlLE6AuS5eIHAAHXwF5m3a4237.jpg" />


本文出自 “賀春暘的技術專欄” 部落格,請務必保留此出處http://hcymysql.blog.51cto.com/5223301/1347504

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.