Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug 79610 / 1525407 (Failed DROP DATABASE due FK constraint on ma… #666

Merged
merged 1 commit into from Jul 19, 2016

Conversation

laurynas-biveinis
Copy link
Contributor

…ster breaks slave)

If DROP DATABASE fails to delete any of the tables, it is binlogged as
DROP TABLE t1, t2, ... for the tables for which drop succeeded. If slave
has different schema so that it references any of the dropped tables,
replication will break.

Fix by running foreign key checks on all the DROP DATABASE tables before
any table is actually dropped. If any FK constraint would fail, do not
convert DROP DATABASE to DROP TABLE in the binary log and abort
immediately.

To implement the fix,

  • add a new handlerton method get_parent_fk_list, that returns the list
    of foreign keys referencing the given table;
  • implement this method for InnoDB, make it share code with
    ha_innobase::get_parent_foreign_key_list handler method;
  • call it from a new function check_drop_database_foreign_keys, which is
    called from mysql_rm_table_no_locks.

Add a testcase to rpl.rpl_foreign_key_innodb, and adjust
binlog.binlog_database as needed.

http://jenkins.percona.com/job/percona-server-5.5-param/1253/ + http://jenkins.percona.com/job/percona-server-5.5-param/1254/


USE `db2`;

create table a1(f1 int);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a1 and a2 are not used

@percona-ysorokin
Copy link
Collaborator

LGTM, minor comments only

…ster breaks slave)

If DROP DATABASE fails to delete any of the tables, it is binlogged as
DROP TABLE t1, t2, ... for the tables for which drop succeeded. If slave
has different schema so that it references any of the dropped tables,
replication will break.

Fix by running foreign key checks on all the DROP DATABASE tables before
any table is actually dropped. If any FK constraint would fail, do not
convert DROP DATABASE to DROP TABLE in the binary log and abort
immediately.

To implement the fix,
- add a new handlerton method get_parent_fk_list, that returns the list
of foreign keys referencing the given table;
- implement this method for InnoDB, make it share code with
ha_innobase::get_parent_foreign_key_list handler method;
- call it from a new function check_drop_database_foreign_keys, which is
called from mysql_rm_table_no_locks.

Add a testcase to rpl.rpl_foreign_key_innodb, and adjust
binlog.binlog_database as needed.
@laurynas-biveinis
Copy link
Contributor Author

@percona-ysorokin
Copy link
Collaborator

LGTM

@laurynas-biveinis laurynas-biveinis merged commit aa5c319 into percona:5.5 Jul 19, 2016
@laurynas-biveinis laurynas-biveinis deleted the bug1525407-5.5 branch July 19, 2016 14:26
inikep pushed a commit to inikep/percona-server that referenced this pull request Apr 23, 2020
Summary:
update-submodule: rocksdb

Changes:
* extracted deadock information buffer from rocksdb
* displayed information of interest to the user by adding a section with information about the latest deadlocks
* annotates the transaction id of the transaction that go the deadlock
* added small test case to verify the changes and recorded engine transaction status tests
Closes facebook/mysql-5.6#666

Reviewed By: lth

Differential Revision: D5519254

fbshipit-source-id: 4a46422436b
inikep pushed a commit to inikep/percona-server that referenced this pull request Feb 24, 2021
Summary:
update-submodule: rocksdb

Changes:
* extracted deadock information buffer from rocksdb
* displayed information of interest to the user by adding a section with information about the latest deadlocks
* annotates the transaction id of the transaction that go the deadlock
* added small test case to verify the changes and recorded engine transaction status tests
Closes facebook/mysql-5.6#666

Reviewed By: lth

Differential Revision: D5519254

fbshipit-source-id: 4a46422436b
inikep pushed a commit to inikep/percona-server that referenced this pull request Nov 15, 2021
Summary:
update-submodule: rocksdb

Changes:
* extracted deadock information buffer from rocksdb
* displayed information of interest to the user by adding a section with information about the latest deadlocks
* annotates the transaction id of the transaction that go the deadlock
* added small test case to verify the changes and recorded engine transaction status tests
Closes facebook/mysql-5.6#666

Reviewed By: lloyd

Differential Revision: D5519254 (facebook/mysql-5.6@5913425)

fbshipit-source-id: 7183d2edbc2
ldonoso pushed a commit to ldonoso/percona-server that referenced this pull request Mar 15, 2022
Summary:
@update-submodule: rocksdb

Changes:
* extracted deadock information buffer from rocksdb
* displayed information of interest to the user by adding a section with information about the latest deadlocks
* annotates the transaction id of the transaction that go the deadlock
* added small test case to verify the changes and recorded engine transaction status tests
Closes facebook/mysql-5.6#666

Reviewed By: lloyd

Differential Revision: D5519254
inikep pushed a commit to inikep/percona-server that referenced this pull request Apr 9, 2024
Summary:
@update-submodule: rocksdb

Changes:
* extracted deadock information buffer from rocksdb
* displayed information of interest to the user by adding a section with information about the latest deadlocks
* annotates the transaction id of the transaction that go the deadlock
* added small test case to verify the changes and recorded engine transaction status tests
Closes facebook/mysql-5.6#666

Reviewed By: lloyd

Differential Revision: D5519254
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants