Created
March 5, 2021 04:15
-
-
Save arc279/c9d3fd26fde66942f02fc77cdab4b9b1 to your computer and use it in GitHub Desktop.
insert の順序で mysql の deadlock が発生するケースの検証
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# cf. https://ichirin2501.hatenablog.com/entry/2015/12/24/164916 | |
export MYSQL_PWD := db_pass | |
CLI := mysql -h 127.0.0.1 -P 3306 -u root -D hoge | |
Q1 := INSERT INTO player (name) VALUES \ | |
("a"), ("b"), ("c"), ("d"), ("e"), ("f"), ("g"), ("h"), ("i"), ("j"), ("k"), ("l"), ("m"), ("n"), ("o"), ("p"), ("q"), ("r"), ("s"), ("t"), ("u"), ("v"), ("w"), ("x"), ("y"), ("z") | |
Q2 := INSERT INTO player (name) VALUES \ | |
("z"), ("y"), ("x"), ("w"), ("v"), ("u"), ("t"), ("s"), ("r"), ("q"), ("p"), ("o"), ("n"), ("m"), ("l"), ("k"), ("j"), ("i"), ("h"), ("g"), ("f"), ("e"), ("d"), ("c"), ("b"), ("a") | |
default: | |
${CLI} | |
clean: | |
echo "truncate player;" | ${CLI} | |
all: | |
$(MAKE) -j d1 d2 | |
d1: | |
echo '${Q1}' | ${CLI} | |
d2: | |
echo '${Q2}' | ${CLI} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE `player` ( | |
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, | |
`name` varchar(20) NOT NULL, | |
`money` bigint(20) unsigned NOT NULL DEFAULT '0', | |
PRIMARY KEY (`id`), | |
UNIQUE KEY `player_idx_name` (`name`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment