简体   繁体   English

MySQL InnoDB 表空间存在(损坏的表空间)

[英]MySQL InnoDB tablespace exists (corrupt tablespace)

First up: I'm not looking for a way to fix the dreaded tablespace exists InnoDB error found here , rather I'm looking for a way to prevent it!首先是:我不是在寻找一种方式来解决这个可怕的tablespace exists的InnoDB发现错误在这里,而我正在寻找一种方法来阻止它! Over the past few weeks we've had a table dissapear from our database at random, with no way to re-create it (because it gives a tablespace exists error).在过去的几周里,我们的数据库中随机消失了一个表,无法重新创建它(因为它给出了表空间存在错误)。 We've narrowed it down to the following table:我们将范围缩小到下表:

CREATE TABLE product_localised (
  id INT (10) UNSIGNED NOT NULL AUTO_INCREMENT,
  product_id INT (10) UNSIGNED NOT NULL,
  language_id INT (10) UNSIGNED NOT NULL,
  slug VARCHAR (255) COLLATE utf8_unicode_ci NOT NULL,
  title TEXT COLLATE utf8_unicode_ci,
  description TEXT COLLATE utf8_unicode_ci,
  description_short TEXT COLLATE utf8_unicode_ci,
  custom_startselect_content TEXT COLLATE utf8_unicode_ci,
  created_at TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00',
  updated_at TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00',
  deleted_at TIMESTAMP NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY product_localised_product_id_language_id_unique (`product_id`, `language_id`),
  KEY product_localised_language_id_foreign (`language_id`),
  CONSTRAINT product_localised_language_id_foreign FOREIGN KEY (`language_id`) REFERENCES languages (`id`),
  CONSTRAINT product_localised_product_id_foreign FOREIGN KEY (`product_id`) REFERENCES products (`id`)
) ENGINE = INNODB AUTO_INCREMENT = 46727 DEFAULT CHARSET = utf8 COLLATE = utf8_unicode_ci;

The question: can someone look at the table's structure and keys and tell if there's anything wrong with it?!问题:有人可以查看表的结构和键并判断它是否有问题吗?!

We're hosting our database on Amazon's RDS and tried MySQL 5.5 and 5.6, with innodb_file_per_table enabled.我们在 Amazon 的 RDS 上托管我们的数据库并尝试了 MySQL 5.5 和 5.6,启用了 innodb_file_per_table。

We also tried MySQL 5.5 on Ubuntu Server 14.04 LTS (using Vagrant) and MySQL 5.6 on Windows using xampp.我们还在 Ubuntu Server 14.04 LTS(使用 Vagrant)上尝试了 MySQL 5.5,在 Windows 上使用 xampp 尝试了 MySQL 5.6。

In response to questions asked below:回答以下问题:

Consider removing id and using (product_id, language_id) as the PK.考虑删除 id 并使用 (product_id, language_id) 作为 PK。 And surely you don't need 2 billion languages, so consider shrinking language_id to SMALLINT UNSIGNED:当然你不需要 20 亿种语言,所以考虑将 language_id 缩小到 SMALLINT UNSIGNED:

  1. We prefer single column primary keys as it makes using our ORM a lot easier我们更喜欢单列主键,因为它使我们的 ORM 更容易使用
  2. We don't have a million languages, but it's simply our auto increment setup we use throughout our project, surely this shouldn't cause any problems?我们没有一百万种语言,但这只是我们在整个项目中使用的自动增量设置,这肯定不会引起任何问题吗?

According to this根据这个

Error: Tablespace for table xxx exists. 错误:表 xxx 的表空间存在。 Please DISCARD the tablespace before IMPORT 请在 IMPORT 之前丢弃表空间

There can be multiple reasons for this.这可能有多种原因。

1) Either your query is timing out 1)要么您的查询超时
2) Either someone has removed foreign key check by running set foreign_key_checks=0 2) 有人通过运行set foreign_key_checks=0删除了外键检查

See if any of these apply:看看这些是否适用:

----- 2015-08-03 5.7.8 -- Bugs Fixed -- ----- ----- 2015-08-03 5.7.8 -- 错误修正 -- -----

A failing ALTER TABLE ( http://dev.mysql.com/doc/refman/5.7/en/alter-table.html ) tablespace operation (DISCARD TABLESPACE or IMPORT TABLESPACE could produce an incorrect internal tablespace state, causing a succeeding statement to fail. (Bug #76424, Bug #20748660)失败的 ALTER TABLE ( http://dev.mysql.com/doc/refman/5.7/en/alter-table.html ) 表空间操作(DISCARD TABLESPACE 或 IMPORT TABLESPACE 可能会产生不正确的内部表空间状态,导致后续语句失败。(错误 #76424,错误 #20748660)

----- 2015-03-09 5.7.6 Milestone 16 -- Bugs Fixed -- InnoDB ----- ----- 2015-03-09 5.7.6 里程碑 16 -- 错误修复 -- InnoDB -----

The fil_space_t::tablespace_version field, introduced to keep track of ALTER TABLE...DISCARD TABLESPACE ( http://dev.mysql.com/doc/refman/5.7/en/alter-table.html ) followed by ALTER TABLE IMPORT TABLESPACE ( http://dev.mysql.com/doc/refman/5.7/en/alter-table.html ) operations, was removed. fil_space_t::tablespace_version 字段,用于跟踪 ALTER TABLE...DISCARD TABLESPACE ( http://dev.mysql.com/doc/refman/5.7/en/alter-table.html ) 后跟 ALTER TABLE IMPORT TABLESPACE ( http://dev.mysql.com/doc/refman/5.7/en/alter-table.html ) 操作,已删除。 The tablespace_version field ensured that a change buffer merge would not occur for old buffered entries while a tablespace with the same space_id was imported. tablespace_version 字段确保在导入具有相同 space_id 的表空间时不会发生旧缓冲条目的更改缓冲区合并。 The field was redundant and no longer required.该字段是多余的,不再需要。 (Bug #19710564) (错误#19710564)

----- 2014-03-31 5.7.4 Milestone 14 & 2014-01-31 5.6.16 -- Bugs Fixed -- InnoDB ----- ----- 2014-03-31 5.7.4 里程碑 14 & 2014-01-31 5.6.16 -- 错误修正 -- InnoDB -----

Manipulating a table after discarding its tablespace using ALTER TABLE ... DISCARD TABLESPACE ( http://dev.mysql.com/doc/refman/5.7/en/alter-table.html ) could result in a serious error.在使用 ALTER TABLE ... DISCARD TABLESPACE ( http://dev.mysql.com/doc/refman/5.7/en/alter-table.html ) 丢弃表空间后操作表可能会导致严重错误。 (Bug #17700280) (错误#17700280)

----- 2012-12-11 5.6.9 -- Bugs Fixed -- InnoDB ----- ----- 2012-12-11 5.6.9 -- 错误修正 -- InnoDB -----

A timeout error could occur on Windows systems when doing ALTER TABLE ( http://dev.mysql.com/doc/refman/5.6/en/alter-table.html ) statements with the DISCARD TABLESPACE or IMPORT TABLESPACE clauses, due to a temporary tablespace file remaining in the file system.使用 DISCARD TABLESPACE 或 IMPORT TABLESPACE 子句执行 ALTER TABLE ( http://dev.mysql.com/doc/refman/5.6/en/alter-table.html ) 语句时,Windows 系统上可能发生超时错误,原因是保留在文件系统中的临时表空间文件。 (Bug #14776799) (错误#14776799)

----- 2012-12-11 5.6.9 -- Bugs Fixed -- ----- ----- 2012-12-11 5.6.9 -- 错误修正 -- -----

After issuing ALTER TABLE ... DISCARD TABLESPACE, an online DDL operation for the same table could fail on Windows systems with an error: Got error 11 from storage engine.发出 ALTER TABLE ... DISCARD TABLESPACE 后,同一表的在线 DDL 操作可能会在 Windows 系统上失败,并显示错误:来自存储引擎的错误 11。 An ALTER TABLE ( http://dev.mysql.com/doc/refman/5.6/en/alter-table.html ) statement with the ALGORITHM=INPLACE clause could also create an empty .ibd file ( http://dev.mysql.com/doc/refman/5.6/en/glossary.html#glos_ibd_file ), making the tablespace no longer “discarded”.带有 ALGORITHM=INPLACE 子句的 ALTER TABLE ( http://dev.mysql.com/doc/refman/5.6/en/alter-table.html ) 语句也可以创建一个空的 .ibd 文件 ( http: //dev.ibd ) 。 mysql.com/doc/refman/5.6/en/glossary.html#glos_ibd_file ),使表空间不再“丢弃”。 (Bug #14735917) (错误#14735917)

http://forums.mysql.com/read.php?22,633145 (table does not exist) http://forums.mysql.com/read.php?22,633145 (表不存在)
http://forums.mysql.com/read.php?20,615512 (MySQL/innodb database malfunctioning) http://forums.mysql.com/read.php?20,615512(MySQL/innodb数据库故障)
http://forums.mysql.com/read.php?22,603093 (Database keeps crashing - Assertion Failure?) http://forums.mysql.com/read.php?22,603093 (数据库不断崩溃 - 断言失败?)
http://forums.mysql.com/read.php?22,601100 (Help needed with DISCARD TABLESPACE) http://forums.mysql.com/read.php?22,601100(DISCARD TABLESPACE 需要帮助)
http://forums.mysql.com/read.php?10,591035 (what should do after some tables' .ibd file were deleted ?) http://forums.mysql.com/read.php?10,591035 (某些表的.ibd文件被删除后该怎么办?)
http://forums.mysql.com/read.php?22,444342 (database crash and procesor overload) http://forums.mysql.com/read.php?22,444342 (数据库崩溃和处理器过载)
http://forums.mysql.com/read.php?22,355932 (InnoDB can't find "the path" specified) http://forums.mysql.com/read.php?22,355932(InnoDB找不到指定的“路径”)
http://forums.mysql.com/read.php?22,290138 (After deleting database, tables "already exist") http://forums.mysql.com/read.php?22,290138 (删除数据库后,表“已经存在”)
http://forums.mysql.com/read.php?22,270607 (*.frm files and reducing ibdata file) http://forums.mysql.com/read.php?22,270607(*.frm文件和缩减 ibdata 文件)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM