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

Check for missing primary or unique keys #34

Closed
macbre opened this issue Oct 29, 2017 · 0 comments
Closed

Check for missing primary or unique keys #34

macbre opened this issue Oct 29, 2017 · 0 comments
Labels
Milestone

Comments

@macbre
Copy link
Owner

macbre commented Oct 29, 2017

INSERT ... ON DUPLICATE KEY UPDATE statements on tables with multiple primary or unique keys. When executed against a table that contains more than one primary or unique key, this statement is considered unsafe, being sensitive to the order in which the storage engine checks the keys, which is not deterministic, and on which the choice of rows updated by the MySQL Server depends.

An INSERT ... ON DUPLICATE KEY UPDATE statement against a table having more than one unique or primary key is marked as unsafe for statement-based replication beginning with MySQL 5.6.6. (Bug #11765650, Bug #58637)

https://dev.mysql.com/doc/refman/5.6/en/replication-rbr-safe-unsafe.html

An example

Due to a MySQL 5.6 bug InnoDB tables that do not have primary key defined has problems with replication of heavy transactions (with tens of thousands of rows involved).

We noticed this behavior during updateSpecialPages.php script run which performs heavy (DELETE + INSERT queries) operations on querycache table. This was quite visible when ruvlab wiki was processed - the maintenance script was performing a transaction with delete and insert of 75k rows causing huge lag on DB cluster.

Wikia/app#9863

CREATE TABLE `querycache` (
  `qc_type` varbinary(32) NOT NULL,
  `qc_value` int(10) unsigned NOT NULL DEFAULT '0',
  `qc_namespace` int(11) NOT NULL DEFAULT '0',
  `qc_title` varchar(255) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL DEFAULT '',
  KEY `qc_type` (`qc_type`,`qc_value`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
@macbre macbre added the linters label Nov 20, 2017
@macbre macbre changed the title Check for primary and unique keys Check for missing primary and unique keys Dec 2, 2017
@macbre macbre changed the title Check for missing primary and unique keys Check for missing primary or unique keys Dec 2, 2017
@macbre macbre added this to the v0.2 milestone Dec 3, 2017
@macbre macbre closed this as completed in #71 Dec 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant