This blog post explains the cause of “ERROR 1412 (HY000): Table definition has changed, please retry transaction” with the specific Isolation level settings. Background As per the MySQL documentation, this error should occur for “operations that make a temporary copy of the original table and delete the original table when the temporary copy is built.” […]
By now you must have read our documentation on isolation levels and also our Support for Transaction Isolation Levels. It is worth noting that the default transaction isolation level in MySQL 8 is REPEATABLE READ.
Here is a simple example of this, in action (you can test this on two different nodes, even across a 9-node Galera Cluster!).
First we do some simple setup:
CREATE DATABASE isolate;
USE isolate;
CREATE TABLE products (
id INT PRIMARY KEY,
name VARCHAR(50),
price DECIMAL(10, 2)
);
Then we insert some initial data:
INSERT INTO products (id, name, …
[Read more]
In this blog, I will provide answers to the Q & A for the “Introduction into storage engine troubleshooting” webinar.
First, I want to thank everybody for attending the July 14 webinar. The recording and slides for the webinar are available here. Below is the list of your questions that I wasn’t able to answer during the webinar, with responses:
Q: At which isolation level do
pt-online-schema-change
and
pt-archive
copy data from a table?
A: Both tools do not change the server’s default transaction isolation level. Use either
REPEATABLE READ
or set …
[Read more]Introduction
XA stands for “eXtended Architecture”, and is a standard created by The Open Group for distributed transaction processing. While MySQL 5.0 was the first version to support XA, MySQL 5.7 has removed major limitations, fixed a number of bugs, and increased overall test-case coverage.…
So I ran across a situation today dealing with having to update a
field but the user was unable to do so because of the related
foreign key constraints.
This blog post with be a simple example showing a foreign key and
how to update them if you have to do so.
First let us create a simple table and populate it with random
data.
CREATE TABLE `table_w_code` (
`SOMECode` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
`NameofCode` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`SOMECode`)
) ENGINE=InnoDB ;
Now we will need another table that has a foreign key tied to our
previous table.
[anothermysqldba]> CREATE TABLE `table_with_fk` (
`SOMEID` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
`SOMECode` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
`Somemorefields` varchar(150) COLLATE utf8_unicode_ci …
This is part of the ongoing work on improving the transaction life cycle management. In 5.7.2 we split the transaction list into two. The read-only transaction list and the read-write transaction list. There was another "virtual" list, the auto-commit non-locking read-only (AC-NL-RO) transaction list. The change in 5.7.2 was that by default a transaction was treated as read only and added to the read-only transaction list. Only when it was determined that the transaction was going to do an update we removed the transaction from the read-only list and moved it to the read-write transaction list. This initial add to the the read-only list forced the acquisition of the trx_sys_t::mutex. Acquiring the mutex during transaction start/begin has a cost. Promoting a transaction from read-only to read-write we had to acquire the trx_sys_t::mutex to add to the read-write transaction list and so that is not too expensive and unavoidable. There is another …
[Read more]While most of the talk recently has mostly been around the new changes in MySQL 5.6 (and that is understandable), I have had lately some very interesting cases to deal with, with respect to the Metadata Locking related changes that were introduced in MySQL 5.5.3. It appears that the implications of Metadata Locking have not been covered well, and since there are still a large number of MySQL 5.0 and 5.1 installations that would upgrade or are in the process of upgrading to MySQL 5.5, I thought it necessary to discuss what these implications exactly are.
To read what Metadata Locking exactly is please read this section here in the MySQL manual.
Let’s start off with having a look at the Meta Data Locking behavior prior to MySQL 5.5.3
Metadata Locking behavior prior to MySQL 5.5.3
Prior to MySQL 5.5.3 a statement that opened a …
[Read more]Global Transaction Identifiers (GTIDs) are one of the key replication enhancements in MySQL 5.6. GTIDs make it simple to track and compare replication across a master - slave topology. This enables:
- Much simpler recovery from failures of the master,
- Introduces great flexibility in the provisioning and on-going management of multi-tier or ring (circular) replication topologies.
A new on-demand MySQL 5.6 GTID webinar delivered by the replication engineering team is now available, providing deep insight into the design and implementation of GTIDs, and how they enable users to simplify MySQL scaling and HA. The webinar covers:
- Concepts: What is a GTID? How does the …
[Read more]By default, when connected to MySQL server, every command is executed as a distinct transaction. As a result, after each INSERT SQL statement MYSQL saves data to the database and commits transaction. When your application inserts hundreds and thousands of records, your database is busy in saving new records all the time and you are loosing in speed.
The solution for this problem is very easy.
Justin Swanhart wrote a blog on Differences between READ-COMMITTED and
REPEATABLE-READ transaction isolation levels and I thought
I'd give my view on this issue.
To begin with, from a technical standpoint, Justin is correct in
his statements, that is not why I am writing this (and this is
the reason I'm writing a separate blogpost instead of just
commenting his), but there is more to it than that.
What Justin really writes about is how these isolation levels are
implemented in a particular database, in this case InnoDB. For
example the sentence "There are a few differences between
READ-COMMITTED and REPEATABLE-READ, and they are all related to
locking." makes this very clear, these isolation levels, as
defined by ANSI SQL as well as how they are implemented by other
databases, …