web-dev-qa-db-ja.com

同時切り捨てコマンド中にサーバーがクラッシュした後のMySQL INNODBの破損

今日、サーバーがクラッシュしました。これは、INNODBテーブルの1つでテーブルの同時切り捨てコマンドが原因で発生したと思います。サーバーを再起動できますが、起動後、SQLコマンドを発行しようとするたびに、次のエラーが発生します。

ERROR 2006 (HY000): MySQL server has gone away

これはログで起こったことです:

121206 01:11:12  mysqld restarted
121206  1:11:13  InnoDB: Started; log sequence number 275 559321759
InnoDB: !!! innodb_force_recovery is set to 1 !!!
121206  1:11:13 [Note] /usr/libexec/mysqld: ready for connections.
Version: '5.0.95-log'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  Source distribution
InnoDB: Error: trying to load index PRIMARY for table 
InnoDB: but the index tree has been freed!
121206  1:11:37 - mysqld got signal 11 ;
This could be because you hit a bug. It is also possible that this binary
or 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 help diagnose
the problem, but since we have already crashed, something is definitely wrong
and this may fail.

key_buffer_size=134217728
read_buffer_size=1048576
max_used_connections=1
max_connections=400
threads_connected=1
It is possible that mysqld could use up to
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_connections = 950272 K
bytes of memory
Hope that's ok; if not, decrease some variables in the equation.

thd=0x9900950
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
Cannot determine thread, fp=0x46353fa0, backtrace may not be correct.
Stack range sanity check OK, backtrace follows:
(nil)
New value of fp=0x9900950 failed sanity check, terminating stack trace!
Please read http://dev.mysql.com/doc/mysql/en/using-stack-trace.html and follow instructions on how to resolve the stack trace. Resolved
stack trace is much more helpful in diagnosing the problem, so please do
resolve it
Trying to get some variables.
Some pointers may be invalid and cause the dump to abort...
thd->query at 0x993e500 =
thd->thread_id=1
The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains
information that should help you find out what is causing the crash.

オンラインで検索したところ、MySQLのバグであるというヒントを得ましたが、どうすれば解決できるかわかりません。 MySQLバージョン5.0.95を使用しています。

新しいデータベースを作成して古いデータを新しいデータベースにダンプする必要があるようですが、現在のデータベースにSQLコマンドを発行できない場合はどうすればよいですか?

---更新---
バージョン: '5.0.95-log'ソケット: '/var/lib/mysql/mysql.sock'ポート:3306ソース配布InnoDB:エラー:テーブルInnoDBのインデックスPRIMARYをロードしようとしています:インデックスツリー解放されました! 121206 4:13:41-mysqldはシグナル11を受け取りました。これは、バグにぶつかったことが原因である可能性があります。また、このバイナリまたはそれがリンクされたライブラリの1つが破損しているか、不適切に構築されているか、正しく構成されていない可能性もあります。このエラーは、ハードウェアの誤動作によっても発生する可能性があります。問題の診断に役立つと思われる情報を収集するために最善を尽くしますが、すでにクラッシュしているため、何かが確実に間違っており、失敗する可能性があります。

key_buffer_size=134217728
read_buffer_size=1048576
max_used_connections=1
max_connections=400
threads_connected=1
It is possible that mysqld could use up to
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_connections = 950272 K
bytes of memory
Hope that's ok; if not, decrease some variables in the equation.

thd=0x17fb8950
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
Cannot determine thread, fp=0x464a3fa0, backtrace may not be correct.
Stack range sanity check OK, backtrace follows:
(nil)
New value of fp=0x17fb8950 failed sanity check, terminating stack trace!
Please read http://dev.mysql.com/doc/mysql/en/using-stack-trace.html and follow instructions on how to resolve the stack trace. Resolved
stack trace is much more helpful in diagnosing the problem, so please do
resolve it
Trying to get some variables.
Some pointers may be invalid and cause the dump to abort...
thd->query at 0x17ff6500 =
thd->thread_id=3
The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains
information that should help you find out what is causing the crash.

Number of processes running now: 0
121206 04:13:41  mysqld restarted
InnoDB: The log sequence number in ibdata files does not match
InnoDB: the log sequence number in the ib_logfiles!
121206  4:13:42  InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.
InnoDB: Reading tablespace information from the .ibd files...
InnoDB: Restoring possible half-written data pages from the doublewrite
InnoDB: buffer...
121206  4:13:43  InnoDB: Started; log sequence number 275 559323148
121206  4:13:43 [Note] /usr/libexec/mysqld: ready for connections.
Version: '5.0.95-log'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  Source distribution
9
Andrew

側面#1

最初に目に入ったのはこの線

InnoDB:エラー:テーブル/のインデックスPRIMARYをロードしようとしています

これは、InnoDBストレージエンジンを使用するテーブルがあることを示します

InnoDBの興味深い点は、主キーの格納方法です。 gen_clust_index と呼ばれる構造、またはより一般的にはクラスター化インデックスと呼ばれる構造に格納されます。

私の即座の推測は、特定のPRIMARY KEYエントリが大きすぎることです

長いPRIMARY KEYを使用することの良い点、悪い点、そして醜い点について、いくつかの記事を検討してください。

次に、<DB Hidden>.<Table Hidden>を再設計する必要があるかどうかを確認します。

側面#2

並列切り捨てテーブルに関する推測に関しては、それは一種の危険に聞こえます。どうして? InnoDBはTRUNCATE TABLEをDDLではなくDMLとして実行します。私は以前にこれについて書いています:

側面#3

チューニングの提案

以下をmy.iniに追加してください

[mysqld]
max_allowed_packet=1G
innodb_fast_shutdown=0

Mysqlを起動

別のセッションでtail -f <errorlogfile>を実行し、InnoDBクラッシュリカバリを監視します。

Mysqlが完全にバックアップされ、InnoDBクラッシュリカバリが完了した場合は、mysqlをすぐにシャットダウンしてみてください。 InnoDBトランザクションログのサイズを変更する必要がある場合があります。

これらの乱暴な提案には申し訳ありませんが、私はここで盲目的に飛んでいます。

質問には以下を投稿してください:

  • my.cnf全体
  • どれくらいRAMが搭載されています

UPDATE 2012-12-05 12:09 EDT

以下を行ってください:

ステップ01)これらの変更をmy.cnfに追加します

[mysqld]
max_allowed_packet=1G
innodb_fast_shutdown=0
innodb_thread_concurrency=0

ステップ02)service mysql restart

mysqlが起動することを確認する

ステップ03)ib_logfile0とib_logfile1のサイズを変更する必要があります(24Mは小さすぎる可能性があります)

service mysql stop
cd /var/lib/mysql
mv ib_logfile0 ib_logfile0.bak
mv ib_logfile1 ib_logfile1.bak

ステップ04)これらの変更をmy.cnfに追加します

[mysqld]
innodb_log_file_size=512M
innodb_log_buffer_size=8M

ステップ05)service mysql start

mysqldはib_logfile0とib_logfile1をそれぞれ512M再作成します

さて、何が起こるか見てみてください...

UPDATE 2012-12-05 12:18 EDT

それまでの間、 mysqlパケットで私のServerFaultの投稿を読んでくださいinnodb_log_file_size および innodb_log_buffer_size に関するそのサイジングの意味- 他の誰かのServerFault投稿

UPDATE 2012-12-05 14:28 EDT

この質問のうち、顧客テーブルへのすべての参照を編集しました。

根本的な原因は、データページとインデックスページが混在しているibdata1の破損したページでした。 Andrewがデータを移行し、 innodb_file_per_table を使用してibdata1を再作成するのを支援し、Andrewがデータを再ロードしました。

6
RolandoMySQLDBA