I have 4 instance database-clustering (2 of them are mariadb 10.2 server and 2 of them is garbd server)
We use update-heavy queries in our databases, dealing with a huge tables which some of the tables have over 20 million records. Also we have lots of java application which use database and these threads mostly make "update" processes in tables. In the peak_time we use about 200 threads.
Our problem is that we have "Deadlock" in our applications. I believe that I can figure out by making some performance tuning in database configurations. My last configuration is below;
DB1: x.x.x.x
DB2: y.y.y.y
Garbd-1: w.w.w.w
Garbd-2: z.z.z.z
DB-1 : my.cnf
[client-server]
socket=/app/mysql/mysql.sock
port=3306
[mysqld]
user=mysql
port=3306
bind-address=0.0.0.0
socket=/app/mysql/mysql.sock
skip-name-resolve
lower_case_table_names=1
server-id=1
event-scheduler=ON
datadir=/app/mysql
pid-file=/app/mysql/db1.pid
log-error=/app/mysql/db1.err
log_bin_trust_function_creators=1
query_cache_type=0
query_cache_size=0
#query_cache_limit = 4M
default_table_type = InnoDB
table_open_cache = 4096
open_files_limit = 8192
max_connections = 800
wait_timeout=100
interactive_timeout=100
#net_read_timeout=3600
#net_write_timeout=3600
max_heap_table_size=64M
tmp_table_size=64M
thread_cache_size=256
sort_buffer_size = 2M
join_buffer_size = 256K
read_buffer_size=128K
read_rnd_buffer_size = 256M
transaction-isolation=READ-COMMITTED
log_warnings
slow_query_log
long_query_time=5
# Physical RAM is 32G (8-core)
innodb_buffer_pool_size =24G
innodb_buffer_pool_instances=6
key_buffer_size=512M
nnodb_write_io_threads=8
innodb_read_io_threads=8
innodb_thread_concurrency = 16
#innodb_data_file_path = ibdata1:1G:autoextend
#innodb_autoextend_increment=128M
#innodb_file_per_table
innodb_flush_log_at_trx_commit=2
#sync_binlog=1
innodb_log_buffer_size = 16M
innodb_log_file_size = 2G
innodb_max_dirty_pages_pct = 80
innodb_flush_method=O_DIRECT
innodb_lock_wait_timeout = 120
binlog_format=ROW
innodb_autoinc_lock_mode=2
[mysqldump]
quick
max_allowed_packet = 512M
[mysql]
no-auto-rehash
[mysqld_safe]
datadir=/app/mysql
pid-file=/app/mysql/db1.pid
log-error=/app/mysql/db1.err
[mariadb-10.2]
wsrep_on=ON
wsrep_provider=/usr/lib64/galera/libgalera_smm.so
wsrep_provider_options="gcache.size=10G;gmcast.listen_addr=tcp://0.0.0.0:4567;socket.checksum=2"
wsrep_cluster_address="gcomm://10.92.221.215,10.92.221.216,10.92.223.215,10.92.223.216"
wsrep_cluster_name='galera_cluster'
wsrep_node_address='10.92.221.215'
wsrep_node_name='ivrocsdbp00'
wsrep_sst_method=rsync
wsrep_sst_auth=sst_user:dbpass
These are also configured in second server, too with a server-id=2 and db2.pid, db2.err changes.
Is these changes might solve my problem?
I want to know that these parameters are well-configured ?
We have 32 GB RAM (8-core) in the servers.
Thanks for your kind help.
I'm guessing nnodb_write_io_threads is a typo as mysqld wouldn't start with it.
I would start with innodb_thread_concurrency = 0 to de-restrict the thread concurrency throttling.
Are your UPDATEs running fully indexed, ideally with PK in the WHERE?
Is there a good reason you have innodb_file_per_table commented out?
It might be worth verifying that your table_open_cache isn't too small (look at the process list and see if you regularly see queries in state of "opening|closing tables".
Are these servers VMs, and are they on a busy/overbooked host? I have seen very interesting spurious deadlocks in situations where clock ticks are unstable and unpredictable, e.g. on heavily overbooked virtual machines. There is some interesting thread racing happening under those conditions that seems to be completely un-reproducible on bare metal. Bumping up the instance size in the cloud environment usually cures the problem because bigger instances tend to be on less overbooked hosts.
Thanks for your responding.
I have corrected my typo and changed my configuration files as innodb_thread_concurrency = 0 as you mentioned.
I tried to configure very low-performing-consuming parameters and I have read about that innodb_file_per_table parameters could effect the RAM usage, so I decided to comment it out. Actually I couldn't figure out what this parameters use for clearly.
Let me tell you my some observation after I have restarted both DB servers.
First of all I stopped all application that making connection to db-1 (Actually we are making all db connections through DB1), then restarted both DB-servers. First of all, let me clear that there was no any traffic when I started applications.
After I start all appcalitons that we use, I realised that I was seeing about 120 processes that created by our user in PROCESSLIST in the INFORMATION_SCHEMA. Also I know that some of these connections don't make anything but using connnection_pool.
I was set up 100s wait_timeout, after 100s later, PROCESSLIST down to "27" and threads_cache became 92.
I also know that these 27 connection was used by some applications that running some check queries in spesific time interval. (10sec, 4sec, 2sec) So when they run queries , their connection_time return 0 and count again as they are never closed.
I believe that in the peak_time, we are gonna need thread_cache_size, so configuring this parameter as 256 would be good for our system.
I know it is so hard to understand for now but can you please check my innodb engine status and give me some advice as I am not very good at concept of database management systems.
=====================================
2020-05-08 01:10:28 0x7fd8cc55c700 INNODB MONITOR OUTPUT
=====================================
Per second averages calculated from the last 7 seconds
-----------------
BACKGROUND THREAD
-----------------
srv_master_thread loops: 4897 srv_active, 0 srv_shutdown, 371 srv_idle
srv_master_thread log flush and writes: 5266
----------
SEMAPHORES
----------
OS WAIT ARRAY INFO: reservation count 34869
OS WAIT ARRAY INFO: signal count 121009
RW-shared spins 0, rounds 214984, OS waits 15858
RW-excl spins 0, rounds 1540716, OS waits 11401
RW-sx spins 52309, rounds 782230, OS waits 3893
Spin rounds per wait: 214984.00 RW-shared, 1540716.00 RW-excl, 14.95 RW-sx
------------
TRANSACTIONS
------------
Trx id counter 211830460
Purge done for trx's n:o < 211830450 undo n:o < 0 state: running but idle
History list length 1
LIST OF TRANSACTIONS FOR EACH SESSION:
---TRANSACTION 422083415170480, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422083415166264, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422083415162048, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422083415157832, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422083415153616, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422083415149400, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422083415145184, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422083415140968, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422083415136752, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422083415132536, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422083415128320, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422083415124104, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422083415119888, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422083415115672, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422083415111456, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422083415107240, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422083415103024, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422083415098808, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422083415094592, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422083415090376, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422083415086160, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422083415081944, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422083415077728, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422083415073512, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422083415069296, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422083415065080, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422083415060864, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422083415056648, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422083415052432, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
--------
FILE I/O
--------
I/O thread 0 state: waiting for completed aio requests (insert buffer thread)
I/O thread 1 state: waiting for completed aio requests (log thread)
I/O thread 2 state: waiting for completed aio requests (read thread)
I/O thread 3 state: waiting for completed aio requests (read thread)
I/O thread 4 state: waiting for completed aio requests (read thread)
I/O thread 5 state: waiting for completed aio requests (read thread)
I/O thread 6 state: waiting for completed aio requests (read thread)
I/O thread 7 state: waiting for completed aio requests (read thread)
I/O thread 8 state: waiting for completed aio requests (read thread)
I/O thread 9 state: waiting for completed aio requests (read thread)
I/O thread 10 state: waiting for completed aio requests (write thread)
I/O thread 11 state: waiting for completed aio requests (write thread)
I/O thread 12 state: waiting for completed aio requests (write thread)
I/O thread 13 state: waiting for completed aio requests (write thread)
I/O thread 14 state: waiting for completed aio requests (write thread)
I/O thread 15 state: waiting for completed aio requests (write thread)
I/O thread 16 state: waiting for completed aio requests (write thread)
I/O thread 17 state: waiting for completed aio requests (write thread)
Pending normal aio reads: [0, 0, 0, 0, 0, 0, 0, 0] , aio writes: [0, 0, 0, 0, 0, 0, 0, 0] ,
ibuf aio reads:, log i/o's:, sync i/o's:
Pending flushes (fsync) log: 0; buffer pool: 0
363895 OS file reads, 105906 OS file writes, 18722 OS fsyncs
0.00 reads/s, 0 avg bytes/read, 6.14 writes/s, 2.43 fsyncs/s
-------------------------------------
INSERT BUFFER AND ADAPTIVE HASH INDEX
-------------------------------------
Ibuf: size 1, free list len 13430, seg size 13432, 2410 merges
merged operations:
insert 72630, delete mark 0, delete 0
discarded operations:
insert 0, delete mark 0, delete 0
Hash table size 6374293, node heap has 108 buffer(s)
Hash table size 6374293, node heap has 64 buffer(s)
Hash table size 6374293, node heap has 64 buffer(s)
Hash table size 6374293, node heap has 18 buffer(s)
Hash table size 6374293, node heap has 10 buffer(s)
Hash table size 6374293, node heap has 72 buffer(s)
Hash table size 6374293, node heap has 4 buffer(s)
Hash table size 6374293, node heap has 634 buffer(s)
3473.22 hash searches/s, 553.49 non-hash searches/s
---
LOG
---
Log sequence number 129572121784
Log flushed up to 129572121784
Pages flushed up to 129572121784
Last checkpoint at 129572120321
0 pending log flushes, 0 pending chkp writes
3127 log i/o's done, 0.71 log i/o's/second
----------------------
BUFFER POOL AND MEMORY
----------------------
Total large memory allocated 26398949376
Dictionary memory allocated 278784
Buffer pool size 1572672
Free buffers 1200805
Database pages 370893
Old database pages 137029
Modified db pages 0
Percent of dirty pages(LRU & free pages): 0.000
Max dirty pages percent: 80.000
Pending reads 0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 2349, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 363786, created 7107, written 94745
0.00 reads/s, 0.00 creates/s, 4.43 writes/s
Buffer pool hit rate 1000 / 1000, young-making rate 0 / 1000 not 0 / 1000
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 370893, unzip_LRU len: 0
I/O sum[0]:cur[24], unzip sum[0]:cur[0]
----------------------
INDIVIDUAL BUFFER POOL INFO
----------------------
---BUFFER POOL 0
Buffer pool size 262112
Free buffers 198770
Database pages 63178
Old database pages 23341
Modified db pages 0
Percent of dirty pages(LRU & free pages): 0.000
Max dirty pages percent: 80.000
Pending reads 0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 372, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 62294, created 884, written 22682
0.00 reads/s, 0.00 creates/s, 2.14 writes/s
Buffer pool hit rate 1000 / 1000, young-making rate 0 / 1000 not 0 / 1000
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 63178, unzip_LRU len: 0
I/O sum[0]:cur[4], unzip sum[0]:cur[0]
---BUFFER POOL 1
Buffer pool size 262112
Free buffers 198593
Database pages 63353
Old database pages 23406
Modified db pages 0
Percent of dirty pages(LRU & free pages): 0.000
Max dirty pages percent: 80.000
Pending reads 0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 365, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 62005, created 1348, written 17745
0.00 reads/s, 0.00 creates/s, 0.86 writes/s
Buffer pool hit rate 1000 / 1000, young-making rate 0 / 1000 not 0 / 1000
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 63353, unzip_LRU len: 0
I/O sum[0]:cur[4], unzip sum[0]:cur[0]
---BUFFER POOL 2
Buffer pool size 262112
Free buffers 202987
Database pages 58961
Old database pages 21784
Modified db pages 0
Percent of dirty pages(LRU & free pages): 0.000
Max dirty pages percent: 80.000
Pending reads 0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 388, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 58042, created 919, written 15919
0.00 reads/s, 0.00 creates/s, 1.00 writes/s
Buffer pool hit rate 1000 / 1000, young-making rate 0 / 1000 not 0 / 1000
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 58961, unzip_LRU len: 0
I/O sum[0]:cur[4], unzip sum[0]:cur[0]
---BUFFER POOL 3
Buffer pool size 262112
Free buffers 199895
Database pages 62058
Old database pages 22928
Modified db pages 0
Percent of dirty pages(LRU & free pages): 0.000
Max dirty pages percent: 80.000
Pending reads 0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 439, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 60791, created 1267, written 12163
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
Buffer pool hit rate 1000 / 1000, young-making rate 0 / 1000 not 0 / 1000
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 62058, unzip_LRU len: 0
I/O sum[0]:cur[4], unzip sum[0]:cur[0]
---BUFFER POOL 4
Buffer pool size 262112
Free buffers 201239
Database pages 60712
Old database pages 22431
Modified db pages 0
Percent of dirty pages(LRU & free pages): 0.000
Max dirty pages percent: 80.000
Pending reads 0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 382, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 59190, created 1522, written 12539
0.00 reads/s, 0.00 creates/s, 0.43 writes/s
Buffer pool hit rate 1000 / 1000, young-making rate 0 / 1000 not 0 / 1000
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 60712, unzip_LRU len: 0
I/O sum[0]:cur[4], unzip sum[0]:cur[0]
---BUFFER POOL 5
Buffer pool size 262112
Free buffers 199321
Database pages 62631
Old database pages 23139
Modified db pages 0
Percent of dirty pages(LRU & free pages): 0.000
Max dirty pages percent: 80.000
Pending reads 0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 403, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 61464, created 1167, written 13697
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
Buffer pool hit rate 1000 / 1000, young-making rate 0 / 1000 not 0 / 1000
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 62631, unzip_LRU len: 0
I/O sum[0]:cur[4], unzip sum[0]:cur[0]
--------------
ROW OPERATIONS
--------------
0 queries inside InnoDB, 0 queries in queue
0 read views open inside InnoDB
Process ID=31986, Main thread ID=140569828304640, state: sleeping
Number of rows inserted 276741, updated 1143, deleted 276686, read 179703655
0.00 inserts/s, 0.29 updates/s, 0.00 deletes/s, 109971.15 reads/s
Number of system rows inserted 0, updated 0, deleted 0, read 0
0.00 inserts/s, 0.00 updates/s, 0.00 deletes/s, 0.00 reads/s
----------------------------
END OF INNODB MONITOR OUTPUT
============================
I will share threads status and INNODB ENGINE STATUS after 1-2 day later, too.
I hope we won't have face with any lock wait timeout issues.
Have a nice day.
Servers are running over 48 hours and let me share tuning-primer results in DB-1.
-- MYSQL PERFORMANCE TUNING PRIMER --
- By: Matthew Montgomery -
MySQL Version 10.2.27-MariaDB-log x86_64
Uptime = 2 days 3 hrs 54 min 46 sec
Avg. qps = 26
Total Questions = 5022294
Threads Connected = 17
Server has been running for over 48hrs.
It should be safe to follow these recommendations
To find out more information on how each of these
runtime variables effects performance visit:
http://dev.mysql.com/doc/refman/10.2/en/server-system-variables.html
Visit http://www.mysql.com/products/enterprise/advisors.html
for info about MySQL's Enterprise Monitoring and Advisory Service
SLOW QUERIES
The slow query log is NOT enabled.
Current long_query_time = 5.000000 sec.
You have 10 out of 5022308 that take longer than 5.000000 sec. to complete
Your long_query_time seems to be fine
BINARY UPDATE LOG
The binary update log is NOT enabled.
You will not be able to do point in time recovery
See http://dev.mysql.com/doc/refman/10.2/en/point-in-time-recovery.html
WORKER THREADS
Current thread_cache_size = 256
Current threads_cached = 103
Current threads_per_sec = 0
Historic threads_per_sec = 0
Your thread_cache_size is fine
MAX CONNECTIONS
Current max_connections = 800
Current threads_connected = 17
Historic max_used_connections = 120
The number of used connections is 15% of the configured maximum.
Your max_connections variable seems to be fine.
INNODB STATUS
Current InnoDB index space = 4.29 G
Current InnoDB data space = 4.72 G
Current InnoDB buffer pool free = 69 %
Current innodb_buffer_pool_size = 24.00 G
Depending on how much space your innodb indexes take up it may be safe
to increase this value to up to 2 / 3 of total system memory
MEMORY USAGE
Max Memory Ever Allocated : 54.82 G
Configured Max Per-thread Buffers : 202.07 G
Configured Max Global Buffers : 24.51 G
Configured Max Memory Limit : 226.59 G
Physical Memory : 31.26 G
Max memory limit exceeds 90% of physical memory
KEY BUFFER
Current MyISAM index space = 638 K
Current key_buffer_size = 512 M
Key cache miss rate is 1 : 144181
Key buffer free ratio = 81 %
Your key_buffer_size seems to be too high.
Perhaps you can use these resources elsewhere
QUERY CACHE
Query cache is supported but not enabled
Perhaps you should set the query_cache_size
SORT OPERATIONS
Current sort_buffer_size = 2 M
Current read_rnd_buffer_size = 256 M
Sort buffer seems to be fine
JOINS
Current join_buffer_size = 260.00 K
You have had 373030 queries where a join could not use an index properly
You should enable "log-queries-not-using-indexes"
Then look for non indexed joins in the slow query log.
If you are unable to optimize your queries you may want to increase your
join_buffer_size to accommodate larger joins in one pass.
Note! This script will still suggest raising the join_buffer_size when
ANY joins not using indexes are found.
OPEN FILES LIMIT
Current open_files_limit = 9031 files
The open_files_limit should typically be set to at least 2x-3x
that of table_cache if you have heavy MyISAM usage.
Your open_files_limit value seems to be fine
TABLE CACHE
Current table_open_cache = 4096 tables
Current table_definition_cache = 400 tables
You have a total of 186 tables
You have 428 open tables.
The table_cache value seems to be fine
TEMP TABLES
Current max_heap_table_size = 64 M
Current tmp_table_size = 64 M
Of 490764 temp tables, 0% were created on disk
Created disk tmp tables ratio seems fine
TABLE SCANS
Current read_buffer_size = 128 K
Current table scan ratio = 34 : 1
read_buffer_size seems to be fine
TABLE LOCKING
Current Lock Wait ratio = 1 : 383
You may benefit from selective use of InnoDB.
If you have long running SELECT's against MyISAM tables and perform
frequent updates consider setting 'low_priority_updates=1'
If you have a high concurrency of inserts on Dynamic row-length tables
consider setting 'concurrent_insert=ALWAYS'.
Should I decrease some parameters in my.cnf ? Any suggestion please ?
Thanks
-- MYSQL PERFORMANCE TUNING PRIMER --
- By: Matthew Montgomery -
MySQL Version 10.2.27-MariaDB-log x86_64
Uptime = 2 days 9 hrs 24 min 19 sec
Avg. qps = 69
Total Questions = 14381364
Threads Connected = 24
Server has been running for over 48hrs.
It should be safe to follow these recommendations
To find out more information on how each of these
runtime variables effects performance visit:
http://dev.mysql.com/doc/refman/10.2/en/server-system-variables.html
Visit http://www.mysql.com/products/enterprise/advisors.html
for info about MySQL's Enterprise Monitoring and Advisory Service
SLOW QUERIES
The slow query log is NOT enabled.
Current long_query_time = 5.000000 sec.
You have 608 out of 14381378 that take longer than 5.000000 sec. to complete
Your long_query_time seems to be fine
BINARY UPDATE LOG
The binary update log is NOT enabled.
You will not be able to do point in time recovery
See http://dev.mysql.com/doc/refman/10.2/en/point-in-time-recovery.html
WORKER THREADS
Current thread_cache_size = 256
Current threads_cached = 109
Current threads_per_sec = 0
Historic threads_per_sec = 0
Your thread_cache_size is fine
MAX CONNECTIONS
Current max_connections = 800
Current threads_connected = 24
Historic max_used_connections = 156
The number of used connections is 19% of the configured maximum.
Your max_connections variable seems to be fine.
INNODB STATUS
Current InnoDB index space = 5.79 G
Current InnoDB data space = 6.29 G
Current InnoDB buffer pool free = 63 %
Current innodb_buffer_pool_size = 24.00 G
Depending on how much space your innodb indexes take up it may be safe
to increase this value to up to 2 / 3 of total system memory
MEMORY USAGE
Max Memory Ever Allocated : 24.95 G
Configured Max Per-thread Buffers : 2.27 G
Configured Max Global Buffers : 24.51 G
Configured Max Memory Limit : 26.78 G
Physical Memory : 31.26 G
Max memory limit seem to be within acceptable norms
KEY BUFFER
Current MyISAM index space = 684 K
Current key_buffer_size = 512 M
Key cache miss rate is 1 : 111228
Key buffer free ratio = 81 %
Your key_buffer_size seems to be too high.
Perhaps you can use these resources elsewhere
QUERY CACHE
Query cache is supported but not enabled
Perhaps you should set the query_cache_size
SORT OPERATIONS
Current sort_buffer_size = 2 M
Current read_rnd_buffer_size = 256 K
Sort buffer seems to be fine
JOINS
Current join_buffer_size = 260.00 K
You have had 419644 queries where a join could not use an index properly
You should enable "log-queries-not-using-indexes"
Then look for non indexed joins in the slow query log.
If you are unable to optimize your queries you may want to increase your
join_buffer_size to accommodate larger joins in one pass.
Note! This script will still suggest raising the join_buffer_size when
ANY joins not using indexes are found.
OPEN FILES LIMIT
Current open_files_limit = 9031 files
The open_files_limit should typically be set to at least 2x-3x
that of table_cache if you have heavy MyISAM usage.
Your open_files_limit value seems to be fine
TABLE CACHE
Current table_open_cache = 4096 tables
Current table_definition_cache = 400 tables
You have a total of 186 tables
You have 1303 open tables.
The table_cache value seems to be fine
TEMP TABLES
Current max_heap_table_size = 64 M
Current tmp_table_size = 64 M
Of 842280 temp tables, 0% were created on disk
Created disk tmp tables ratio seems fine
TABLE SCANS
Current read_buffer_size = 128 K
Current table scan ratio = 50 : 1
read_buffer_size seems to be fine
TABLE LOCKING
Current Lock Wait ratio = 1 : 29
You may benefit from selective use of InnoDB.
If you have long running SELECT's against MyISAM tables and perform
frequent updates consider setting 'low_priority_updates=1'
If you have a high concurrency of inserts on Dynamic row-length tables
consider setting 'concurrent_insert=ALWAYS'.
Any suggest please ?
I also wanna status my table spesifications. We usually had deadlocks in 3 major tables which are cp_resource_allocation, cp_pending, cp_batch.
CREATE TABLE `cp_resource_allocation` (
`CAMPAIGN_ID` int(11) NOT NULL,
`RESOURCE_QUOTA` int(11) NOT NULL DEFAULT 0,
`RESOURCE_ALLOCATED` int(11) NOT NULL DEFAULT 0,
`DAILY_ATTEMPT` int(11) NOT NULL DEFAULT 0,
`DAILY_SUCCESSFUL` int(11) NOT NULL DEFAULT 0,
`DAILY_RESERVED` int(11) NOT NULL DEFAULT 0,
PRIMARY KEY (`CAMPAIGN_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='Campaign Resource Allocation Table'
CREATE TABLE `cp_pending` (
`RID` int(20) NOT NULL AUTO_INCREMENT,
`CAMPAIGN` int(10) NOT NULL,
`BATCH` int(11) NOT NULL,
`DEST_ADDR` char(20) CHARACTER SET latin1 NOT NULL COMMENT 'Aranan / Gönderilen adres.',
`TRIES_MADE` int(10) NOT NULL DEFAULT 0 COMMENT 'Specifies current retry count for the Called Number.',
`SELECT_LOCK` int(10) NOT NULL DEFAULT 0 COMMENT 'NULL’dan farklı ise kayıt seçilmiştir. ',
`SELECT_TIME` datetime DEFAULT NULL COMMENT 'Seçim zamanı.',
`OUTCOME` int(10) NOT NULL DEFAULT 0 COMMENT 'İşlem durumu. 0 ise işlem devam ediyor. 1 ise işlem başarılı. 2 ise işlem başarısız. 3 ise işlem iptal. 4 ise numara blacklist''de. 5 ise HLR''a tetik konmuş.',
`APP_INT1` int(10) DEFAULT NULL COMMENT 'Uygulamaya özel.',
`APP_INT2` int(10) unsigned zerofill DEFAULT NULL COMMENT 'Uygulamaya özel..',
`CID` int(11) DEFAULT NULL,
`CC_SERVER_ADDRESS` char(45) CHARACTER SET latin1 DEFAULT NULL,
`CALL_START_TIME` datetime DEFAULT NULL,
`CALL_ANSWER_TIME` datetime DEFAULT NULL,
`CALL_END_TIME` datetime DEFAULT NULL,
`CAUSE_VALUE` int(11) DEFAULT NULL COMMENT 'RELEASE CAUSE VALUE',
`CALL_REQUEST_TIME` datetime DEFAULT NULL COMMENT 'time when a call manager retrieves this record',
`CALL_CONNECT_DURATION` int(11) NOT NULL DEFAULT 0 COMMENT 'CALL_END_TIME - CALL_ANSWER_TIME',
`LIST_TYPE` int(11) NOT NULL DEFAULT 0 COMMENT 'List Group Type;\\n0 Start List. \\n1 Main List.\\n2 End List. \\n',
`CALL_ACTIVE_DURATION` int(11) NOT NULL DEFAULT 0 COMMENT 'CALL_END_TIME-CALL_START_TIME',
`DTMF` varchar(5) CHARACTER SET latin1 DEFAULT NULL,
`app_str1` varchar(2048) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`APP_STR2` varchar(2048) CHARACTER SET latin1 DEFAULT NULL,
`APP_STR3` varchar(2048) CHARACTER SET latin1 DEFAULT NULL,
`APP_STR4` varchar(80) CHARACTER SET latin1 DEFAULT NULL,
`APP_STR5` varchar(80) CHARACTER SET latin1 DEFAULT NULL,
`LAST_HLR_UPDATE` datetime DEFAULT NULL,
`TTS_STATUS` int(11) DEFAULT 0 COMMENT '0: initial, 1: Converted, 2: Convert failed, 3: Uploaded, 4: Upload Error, 5: Partial Upload Error',
`TTS_SELECT_LOCK` varchar(100) DEFAULT NULL,
PRIMARY KEY (`RID`) USING BTREE,
KEY `campaign` (`CAMPAIGN`),
KEY `ilock` (`SELECT_LOCK`) USING BTREE,
KEY `iDestAddr` (`DEST_ADDR`),
KEY `ix_cp_pending_2` (`DEST_ADDR`,`OUTCOME`),
KEY `ix_test` (`DEST_ADDR`,`CAMPAIGN`,`OUTCOME`),
KEY `ix_batch` (`OUTCOME`,`BATCH`),
KEY `ix_time` (`SELECT_TIME`,`OUTCOME`),
KEY `ix_mrcp_tts_client` (`TTS_STATUS`,`CAMPAIGN`,`TTS_SELECT_LOCK`)
) ENGINE=InnoDB AUTO_INCREMENT=148583478 DEFAULT CHARSET=utf8mb4
CREATE TABLE `cp_batch` (
`BATCH_ID` int(10) NOT NULL AUTO_INCREMENT,
`BATCH_NAME` varchar(200) NOT NULL,
`BATCH_STATUS` tinyint(3) unsigned NOT NULL COMMENT 'Batch status indicator. 1-Loading, 2-Active, 3-Aborted, 4-Completed, 5-Suspended, 6-Deleted',
`CAMPAIGN_ID` int(10) NOT NULL,
`LIST_ID` int(10) DEFAULT NULL,
`OPERATION_TIME` timestamp NOT NULL DEFAULT current_timestamp(),
`INPUT_FILE` varchar(200) DEFAULT NULL COMMENT 'If this batch was created automatically by text file placed in disk folder, the name of that file.',
`NUM_DESTINATIONS` int(10) unsigned NOT NULL DEFAULT 0 COMMENT 'Total number of destinations used for this batch.',
`NUM_SUCCESS` int(10) unsigned NOT NULL DEFAULT 0 COMMENT 'Total number of successfull calls',
`NUM_CANCEL` int(10) unsigned NOT NULL DEFAULT 0 COMMENT 'Total number of canceled calls\n',
`REMAINING_DESTINATIONS` int(10) unsigned DEFAULT NULL,
`NUM_UNTRIED` int(10) NOT NULL COMMENT 'Number of destinations to which no call attempt has been made yet.',
`NUM_BLACKLIST` int(11) NOT NULL DEFAULT 0 COMMENT 'total number of blacklisted calls',
`COMPLETION_REASON` int(10) unsigned DEFAULT NULL COMMENT 'Indicates how the campaign was completed (end date, max tries, etc.)',
`DEPLETION_TIME` datetime DEFAULT NULL COMMENT 'The time when all numbers in this batch have been processed. Set by CallMgr.',
`IS_DEPLETED` int(10) unsigned NOT NULL DEFAULT 0 COMMENT 'Shows if all numbers in this batch have been processed. 1: All numbers were processed 0: No',
`MIN_RID` bigint(20) NOT NULL DEFAULT 0 COMMENT 'beginning of rid for this campaign',
`MAX_RID` bigint(20) NOT NULL DEFAULT 0 COMMENT 'last rid for this campaign',
`CURRENT_RID` bigint(20) NOT NULL DEFAULT 0 COMMENT 'current pointer for this campaign',
`TRIES_MADE` int(11) NOT NULL DEFAULT 0,
`START_NOTIF` int(11) NOT NULL DEFAULT 0,
`IS_EXPANDABLE` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'default:0, initial:1',
PRIMARY KEY (`BATCH_ID`),
KEY `ix1` (`BATCH_STATUS`,`IS_DEPLETED`),
KEY `ix2_campaign` (`CAMPAIGN_ID`),
KEY `batch_index` (`BATCH_NAME`)
) ENGINE=InnoDB AUTO_INCREMENT=1588730 DEFAULT CHARSET=latin1
We haven't face with any deadlock yet since yesterday. Do you see any suspect value in "create table" parameters ?
Thanks.
Related
I have one server in replication. Whenever I am executing a delete query with a limit of 10000 or 100000 on InnoDB table then it returns me Error 1206 so that's why I have started to look into engine status which may help for better performance.
mysql> delete from cdrs where billseconds=0 limit 10000;
ERROR 1206 (HY000): The total number of locks exceeds the lock table size
But still, A beginner does not get enough understanding of what value can be correct or how to calculate which variable needs to be set up properly.
So anyone please suggest which value should be recommended?
mysql> SHOW ENGINE INNODB STATUS\G;
*************************** 1. row ***************************
Type: InnoDB
Name:
Status:
=====================================
2022-06-25 08:05:35 139698390398720 INNODB MONITOR OUTPUT
=====================================
Per second averages calculated from the last 5 seconds
-----------------
BACKGROUND THREAD
-----------------
srv_master_thread loops: 315147 srv_active, 0 srv_shutdown, 1711532 srv_idle
srv_master_thread log flush and writes: 0
----------
SEMAPHORES
----------
OS WAIT ARRAY INFO: reservation count 107425397
OS WAIT ARRAY INFO: signal count 138090595
RW-shared spins 0, rounds 0, OS waits 0
RW-excl spins 0, rounds 0, OS waits 0
RW-sx spins 0, rounds 0, OS waits 0
Spin rounds per wait: 0.00 RW-shared, 0.00 RW-excl, 0.00 RW-sx
------------
TRANSACTIONS
------------
Trx id counter 5868831
Purge done for trx's n:o < 5868831 undo n:o < 0 state: running but idle
History list length 0
LIST OF TRANSACTIONS FOR EACH SESSION:
---TRANSACTION 421173985799384, not started
0 lock struct(s), heap size 1128, 0 row lock(s)
---TRANSACTION 421173985803424, not started
0 lock struct(s), heap size 1128, 0 row lock(s)
---TRANSACTION 421173985802616, not started
0 lock struct(s), heap size 1128, 0 row lock(s)
---TRANSACTION 421173985801808, not started
0 lock struct(s), heap size 1128, 0 row lock(s)
---TRANSACTION 421173985801000, not started
0 lock struct(s), heap size 1128, 0 row lock(s)
---TRANSACTION 421173985800192, not started
0 lock struct(s), heap size 1128, 0 row lock(s)
---TRANSACTION 421173985798576, not started
0 lock struct(s), heap size 1128, 0 row lock(s)
---TRANSACTION 421173985797768, not started
0 lock struct(s), heap size 1128, 0 row lock(s)
--------
FILE I/O
--------
I/O thread 0 state: waiting for completed aio requests (insert buffer thread)
I/O thread 1 state: waiting for completed aio requests (log thread)
I/O thread 2 state: waiting for completed aio requests (read thread)
I/O thread 3 state: waiting for completed aio requests (read thread)
I/O thread 4 state: waiting for completed aio requests (read thread)
I/O thread 5 state: waiting for completed aio requests (read thread)
I/O thread 6 state: waiting for completed aio requests (write thread)
I/O thread 7 state: waiting for completed aio requests (write thread)
I/O thread 8 state: waiting for completed aio requests (write thread)
I/O thread 9 state: waiting for completed aio requests (write thread)
Pending normal aio reads: [0, 0, 0, 0] , aio writes: [0, 0, 0, 0] ,
ibuf aio reads:, log i/o's:
Pending flushes (fsync) log: 0; buffer pool: 193
184939997 OS file reads, 408993938 OS file writes, 191478723 OS fsyncs
0.00 reads/s, 0 avg bytes/read, 0.00 writes/s, 0.00 fsyncs/s
-------------------------------------
INSERT BUFFER AND ADAPTIVE HASH INDEX
-------------------------------------
Ibuf: size 1, free list len 3093, seg size 3095, 64998391 merges
merged operations:
insert 905575573, delete mark 16719939, delete 5094846
discarded operations:
insert 0, delete mark 0, delete 0
Hash table size 34679, node heap has 1 buffer(s)
Hash table size 34679, node heap has 0 buffer(s)
Hash table size 34679, node heap has 1 buffer(s)
Hash table size 34679, node heap has 1 buffer(s)
Hash table size 34679, node heap has 1 buffer(s)
Hash table size 34679, node heap has 1 buffer(s)
Hash table size 34679, node heap has 1 buffer(s)
Hash table size 34679, node heap has 4 buffer(s)
0.00 hash searches/s, 0.00 non-hash searches/s
---
LOG
---
Log sequence number 759200638267
Log buffer assigned up to 759200638267
Log buffer completed up to 759200638267
Log written up to 759200638267
Log flushed up to 759200638267
Added dirty pages up to 759200638267
Pages flushed up to 759200638267
Last checkpoint at 759200638267
205244131 log i/o's done, 0.00 log i/o's/second
----------------------
BUFFER POOL AND MEMORY
----------------------
Total large memory allocated 0
Dictionary memory allocated 2465252
Buffer pool size 8192
Free buffers 5735
Database pages 2447
Old database pages 922
Modified db pages 0
Pending reads 0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 18667218, not young 4562179027
0.00 youngs/s, 0.00 non-youngs/s
Pages read 184946579, created 25133992, written 155280433
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool page gets since the last printout
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 2447, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
--------------
ROW OPERATIONS
--------------
0 queries inside InnoDB, 0 queries in queue
0 read views open inside InnoDB
Process ID=17499, Main thread ID=139698522695424 , state=sleeping
Number of rows inserted 1052202547, updated 1185599, deleted 18772945, read 2858392871
0.00 inserts/s, 0.00 updates/s, 0.00 deletes/s, 0.00 reads/s
Number of system rows inserted 5488, updated 2933689, deleted 72, read 2992114
0.00 inserts/s, 0.00 updates/s, 0.00 deletes/s, 0.00 reads/s
----------------------------
END OF INNODB MONITOR OUTPUT
============================
1 row in set (0.00 sec)
ERROR:
No query specified
My system memory :
root#ankitdoshi:/home/ankitdoshi# grep MemTotal /proc/meminfo
MemTotal: 131932092 kB
Thanks in advance for your help and suggestions.
By default, MySQL allocates 128MB of space for innodb_buffer_pool_size. To resolve the problem, you'll have to increase the size in /etc/my.cnf file
Edit /etc/my.cnf file, and add the following under the [mysqld] heading.
innodb_buffer_pool_size=256M
after that You'll have to tweak the value of innodb_buffer_pool_size as having large buffer size could introduce Fatal error: cannot allocate memory for the buffer pool problem. You'll have to restart the mysqld service in order to take this new value into effect.
service mysqld restart
Look here enter link description here
Don't delete more than 1000 rows in a chunk, else you hit issues like the one you encountered.
Even better is to avoid big deletes. There are several techniques: http://mysql.rjweb.org/doc.php/deletebig
And, yes, do increase innodb_buffer_pool_size to about 70% of available RAM.
This question has been moved to dba.stackexchange.com
I managed to create a mysql InnoDB cluster with three nodes and a router everything works great but when i try to run a select query from the table below from a another server it freezes, but it works when i limit the result to a number under 26
SET NAMES utf8;
SET time_zone = '+00:00';
SET NAMES utf8mb4;
DROP TABLE IF EXISTS `v7_addad`;
CREATE TABLE `v7_addad` (
`id` int NOT NULL AUTO_INCREMENT,
`body` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`page_id` int NOT NULL,
`done` tinyint NOT NULL DEFAULT '0',
`book` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
PRIMARY KEY (`id`),
FULLTEXT KEY `body` (`body`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
For example :
select * from v7_addad limit 25; # this works
select * from v7_addad limit 26; # this freezes
BTW if doesn't freeze when trying from the R/W node (the server hosting the main mode).
show engine innodb status;
=====================================
2021-01-02 15:49:26 0x7f8584324700 INNODB MONITOR OUTPUT
=====================================
Per second averages calculated from the last 11 seconds
-----------------
BACKGROUND THREAD
-----------------
srv_master_thread loops: 35520 srv_active, 0 srv_shutdown, 135529 srv_idle
srv_master_thread log flush and writes: 0
----------
SEMAPHORES
----------
OS WAIT ARRAY INFO: reservation count 398
OS WAIT ARRAY INFO: signal count 589
RW-shared spins 269, rounds 269, OS waits 0
RW-excl spins 145, rounds 4321, OS waits 134
RW-sx spins 1, rounds 1, OS waits 0
Spin rounds per wait: 1.00 RW-shared, 29.80 RW-excl, 1.00 RW-sx
------------
TRANSACTIONS
------------
Trx id counter 207413
Purge done for trx's n:o < 207412 undo n:o < 0 state: running but idle
History list length 12
LIST OF TRANSACTIONS FOR EACH SESSION:
---TRANSACTION 421696252934904, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 421696252933192, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 421696252934048, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 421696252932336, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 421696252931480, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 421696252930624, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 421696252929768, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
--------
FILE I/O
--------
I/O thread 0 state: waiting for completed aio requests (insert buffer thread)
I/O thread 1 state: waiting for completed aio requests (log thread)
I/O thread 2 state: waiting for completed aio requests (read thread)
I/O thread 3 state: waiting for completed aio requests (read thread)
I/O thread 4 state: waiting for completed aio requests (read thread)
I/O thread 5 state: waiting for completed aio requests (read thread)
I/O thread 6 state: waiting for completed aio requests (write thread)
I/O thread 7 state: waiting for completed aio requests (write thread)
I/O thread 8 state: waiting for completed aio requests (write thread)
I/O thread 9 state: waiting for completed aio requests (write thread)
Pending normal aio reads: [0, 0, 0, 0] , aio writes: [0, 0, 0, 0] ,
ibuf aio reads:, log i/o's:, sync i/o's:
Pending flushes (fsync) log: 0; buffer pool: 18446744073709551589
5225 OS file reads, 765431 OS file writes, 599449 OS fsyncs
0.00 reads/s, 0 avg bytes/read, 2.91 writes/s, 2.45 fsyncs/s
-------------------------------------
INSERT BUFFER AND ADAPTIVE HASH INDEX
-------------------------------------
Ibuf: size 1, free list len 0, seg size 2, 0 merges
merged operations:
insert 0, delete mark 0, delete 0
discarded operations:
insert 0, delete mark 0, delete 0
Hash table size 3984439, node heap has 2 buffer(s)
Hash table size 3984439, node heap has 1 buffer(s)
Hash table size 3984439, node heap has 1 buffer(s)
Hash table size 3984439, node heap has 2 buffer(s)
Hash table size 3984439, node heap has 1 buffer(s)
Hash table size 3984439, node heap has 3 buffer(s)
Hash table size 3984439, node heap has 4 buffer(s)
Hash table size 3984439, node heap has 7 buffer(s)
0.18 hash searches/s, 1.55 non-hash searches/s
---
LOG
---
Log sequence number 2237873266
Log buffer assigned up to 2237873266
Log buffer completed up to 2237873266
Log written up to 2237873266
Log flushed up to 2237873266
Added dirty pages up to 2237873266
Pages flushed up to 2237873266
Last checkpoint at 2237873266
247265 log i/o's done, 1.18 log i/o's/second
----------------------
BUFFER POOL AND MEMORY
----------------------
Total large memory allocated 16483614720
Dictionary memory allocated 1956558
Buffer pool size 983040
Free buffers 977601
Database pages 5418
Old database pages 2027
Modified db pages 0
Pending reads 0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 0, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 5153, created 265, written 361560
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
Buffer pool hit rate 1000 / 1000, young-making rate 0 / 1000 not 0 / 1000
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 5418, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
----------------------
INDIVIDUAL BUFFER POOL INFO
----------------------
---BUFFER POOL 0
Buffer pool size 491520
Free buffers 488755
Database pages 2754
Old database pages 1026
Modified db pages 0
Pending reads 0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 0, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 2596, created 158, written 229420
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
Buffer pool hit rate 1000 / 1000, young-making rate 0 / 1000 not 0 / 1000
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 2754, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
---BUFFER POOL 1
Buffer pool size 491520
Free buffers 488846
Database pages 2664
Old database pages 1001
Modified db pages 0
Pending reads 0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 0, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 2557, created 107, written 132140
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
Buffer pool hit rate 1000 / 1000, young-making rate 0 / 1000 not 0 / 1000
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 2664, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
--------------
ROW OPERATIONS
--------------
0 queries inside InnoDB, 0 queries in queue
0 read views open inside InnoDB
Process ID=3803, Main thread ID=140203552966400 , state=sleeping
Number of rows inserted 0, updated 33674, deleted 0, read 5195822
0.00 inserts/s, 0.18 updates/s, 0.00 deletes/s, 15.91 reads/s
Number of system rows inserted 33706, updated 1120, deleted 33702, read 85994
0.18 inserts/s, 0.00 updates/s, 0.00 deletes/s, 0.00 reads/s
----------------------------
END OF INNODB MONITOR OUTPUT
============================
Cause
After run a backed up sql file to my local computer, My computer cpu run 100%.
my steps:
before run sql file
/*avoid error DETERMINISTIC, NO SQL, or READS SQL DATA in its declaration and binary logging is enabled*/
SET GLOBAL log_bin_trust_function_creators = 1;
SET GLOBAL max_allowed_packet=1073741824;
create a new database
run a sql file (backed up in mysql 5.7.17) to import structure and data at this new database
import success;
1 minute after successful import, win10 cpu usage 100%;
screenshots:
Version
win10 1909(18363.449)
MySQL 8.0.16
Troubleshoot
show full processlist;
results:
show engine innodb status
results:
=====================================
2019-10-25 09:31:09 0x3d00 INNODB MONITOR OUTPUT
=====================================
Per second averages calculated from the last 40 seconds
-----------------
BACKGROUND THREAD
-----------------
srv_master_thread loops: 347 srv_active, 0 srv_shutdown, 2245 srv_idle
srv_master_thread log flush and writes: 0
----------
SEMAPHORES
----------
OS WAIT ARRAY INFO: reservation count 316
OS WAIT ARRAY INFO: signal count 1781
RW-shared spins 799, rounds 800, OS waits 1
RW-excl spins 9658, rounds 25501, OS waits 212
RW-sx spins 8, rounds 172, OS waits 5
Spin rounds per wait: 1.00 RW-shared, 2.64 RW-excl, 21.50 RW-sx
------------
TRANSACTIONS
------------
Trx id counter 371410743
Purge done for trx's n:o < 371410741 undo n:o < 0 state: running but idle
History list length 37
LIST OF TRANSACTIONS FOR EACH SESSION:
---TRANSACTION 282782365114120, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 282782365113248, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 282782365112376, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 282782365111504, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 282782365110632, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 282782365109760, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 282782365108888, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 282782365122840, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 282782365118480, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 282782365108016, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
--------
FILE I/O
--------
I/O thread 0 state: wait Windows aio (insert buffer thread)
I/O thread 1 state: wait Windows aio (log thread)
I/O thread 2 state: wait Windows aio (read thread)
I/O thread 3 state: wait Windows aio (read thread)
I/O thread 4 state: wait Windows aio (read thread)
I/O thread 5 state: wait Windows aio (read thread)
I/O thread 6 state: wait Windows aio (write thread)
I/O thread 7 state: wait Windows aio (write thread)
I/O thread 8 state: wait Windows aio (write thread)
I/O thread 9 state: wait Windows aio (write thread)
Pending normal aio reads: [0, 0, 0, 0] , aio writes: [0, 0, 0, 0] ,
ibuf aio reads:, log i/o's:, sync i/o's:
Pending flushes (fsync) log: 0; buffer pool: 0
1980 OS file reads, 176203 OS file writes, 56718 OS fsyncs
0.00 reads/s, 0 avg bytes/read, 0.67 writes/s, 0.42 fsyncs/s
-------------------------------------
INSERT BUFFER AND ADAPTIVE HASH INDEX
-------------------------------------
Ibuf: size 1, free list len 462, seg size 464, 0 merges
merged operations:
insert 0, delete mark 0, delete 0
discarded operations:
insert 0, delete mark 0, delete 0
Hash table size 34679, node heap has 2 buffer(s)
Hash table size 34679, node heap has 2 buffer(s)
Hash table size 34679, node heap has 1 buffer(s)
Hash table size 34679, node heap has 1 buffer(s)
Hash table size 34679, node heap has 3 buffer(s)
Hash table size 34679, node heap has 4 buffer(s)
Hash table size 34679, node heap has 3 buffer(s)
Hash table size 34679, node heap has 5 buffer(s)
0.00 hash searches/s, 0.35 non-hash searches/s
---
LOG
---
Log sequence number 73725445734
Log buffer assigned up to 73725445734
Log buffer completed up to 73725445734
Log written up to 73725445734
Log flushed up to 73725445734
Added dirty pages up to 73725445734
Pages flushed up to 73725445734
Last checkpoint at 73725445734
136624 log i/o's done, 0.17 log i/o's/second
----------------------
BUFFER POOL AND MEMORY
----------------------
Total large memory allocated 137363456
Dictionary memory allocated 3671937
Buffer pool size 8192
Free buffers 1024
Database pages 7147
Old database pages 2618
Modified db pages 0
Pending reads 0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 1763, not young 20320
0.00 youngs/s, 0.00 non-youngs/s
Pages read 1947, created 17850, written 33619
0.00 reads/s, 0.00 creates/s, 0.30 writes/s
Buffer pool hit rate 1000 / 1000, young-making rate 0 / 1000 not 0 / 1000
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 7147, unzip_LRU len: 0
I/O sum[15]:cur[0], unzip sum[0]:cur[0]
--------------
ROW OPERATIONS
--------------
0 queries inside InnoDB, 0 queries in queue
0 read views open inside InnoDB
Process ID=17416, Main thread ID=0000000000003E6C , state=sleeping
Number of rows inserted 142096, updated 54521, deleted 59578, read 563375
0.00 inserts/s, 0.10 updates/s, 0.00 deletes/s, 0.40 reads/s
----------------------------
END OF INNODB MONITOR OUTPUT
============================
Tried solutions
restart mysql service, no effect, after restart, cpu still 100%
net mysql stop
net mysql start
restart my computer, no effect, after restart, cpu still 100%
show full processlist and kill some sleep or time cost most processes, no effect
show OPEN TABLES where In_use > 0; no results;
delete this new database, everything is ok,but this is useless
Thank you so much to everyone who helped.
Edit:
The queries are executed from AWS Lambda and it is a AWS Aurora MySQL compatible database.
It is a M5.large database that has about 70 database connections and around 7% cpu load.
End Edit.
We have a dead lock that we are struggling to understand. It happens very rarely and of course when the requests are very close to each other in time.
How can we get better understanding when this happens?
What is best practice in cases like this? Is it ok to accept this and write your code to rerun the query?
Below is more information output from show engine innodb status
2019-07-31 10:44:08 0x2b0f9939d700 INNODB MONITOR OUTPUT
=====================================
Per second averages calculated from the last 14 seconds
-----------------
BACKGROUND THREAD
-----------------
srv_master_thread loops: 457179 srv_active, 0 srv_shutdown, 158871 srv_idle
srv_master_thread log flush and writes: 0
----------
SEMAPHORES
----------
OS WAIT ARRAY INFO: reservation count 353267
OS WAIT ARRAY INFO: signal count 363003
RW-shared spins 0, rounds 60860, OS waits 3736
RW-excl spins 0, rounds 278008, OS waits 4241
RW-sx spins 834, rounds 12583, OS waits 94
Spin rounds per wait: 60860.00 RW-shared, 278008.00 RW-excl, 15.09 RW-sx
------------------------
LATEST DETECTED DEADLOCK
------------------------
2019-07-29 00:01:57 0x2b122b42b700
*** (1) TRANSACTION:
TRANSACTION 25004785, ACTIVE 0 sec inserting
mysql tables in use 1, locked 1
LOCK WAIT 7 lock struct(s), heap size 1136, 4 row lock(s), undo log entries 1
MySQL thread id 1067258, OS thread handle 47346011883264, query id 192217819 160.170.30.251 root update
INSERT INTO logs (date, time, duration, source, another_table_id, date_id) VALUES ('2019-07-29', '00:00:06', 20047, 0, 6793, 3629) ON DUPLICATE KEY UPDATE duration = VALUES(duration)
*** (1) WAITING FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 252 page no 15293 n bits 0 index logs_another_table__c5da8410_uniq of table `database`.`logs` trx id 25004785 lock_mode X locks gap before rec insert intention waiting
Record lock, heap no 1 PHYSICAL RECORD: n_fields 1; compact format; info bits 0
0: len=8; bufptr=0x2b1111b00070; hex= 73757072656d756d; asc supremum;;
*** (2) TRANSACTION:
TRANSACTION 25004783, ACTIVE 0 sec inserting
mysql tables in use 1, locked 1
LOCK WAIT 8 lock struct(s), heap size 1136, 5 row lock(s), undo log entries 1
MySQL thread id 1067257, OS thread handle 47345995474688, query id 192217812 160.170.10.38 root update
INSERT INTO logs (date, time, duration, source, another_table_id, date_id) VALUES ('2019-07-28', '23:59:05', 20047, 0, 6792, 3631) ON DUPLICATE KEY UPDATE duration = VALUES(duration)
*** (2) HOLDS THE LOCK(S):
RECORD LOCKS space id 252 page no 15293 n bits 0 index logs_another_table__c5da1234_uniq of table `database`.`logs` trx id 25004783 lock_mode X
Record lock, heap no 1 PHYSICAL RECORD: n_fields 1; compact format; info bits 0
0: len=8; bufptr=0x2b1111b00070; hex= 73757072656d756d; asc supremum;;
*** (2) WAITING FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 252 page no 15293 n bits 0 index logs_another_table__c5da1234_uniq of table `database`.`logs` trx id 25004783 lock_mode X locks gap before rec insert intention waiting
Record lock, heap no 1 PHYSICAL RECORD: n_fields 1; compact format; info bits 0
0: len=8; bufptr=0x2b1111b00070; hex= 73757072656d756d; asc supremum;;
------------
TRANSACTIONS
------------
Trx id counter 30159757
Purge done for trx's n:o < 30159757 undo n:o < 0 state: running but idle
History list length 2976
--------
FILE I/O
--------
I/O thread 0 state: waiting for i/o request (insert buffer thread)
I/O thread 1 state: waiting for i/o request (log thread)
I/O thread 2 state: waiting for i/o request (read thread)
I/O thread 3 state: waiting for i/o request (read thread)
I/O thread 4 state: waiting for i/o request (read thread)
I/O thread 5 state: waiting for i/o request (read thread)
I/O thread 6 state: waiting for i/o request (write thread)
I/O thread 7 state: waiting for i/o request (write thread)
I/O thread 8 state: waiting for i/o request (write thread)
I/O thread 9 state: waiting for i/o request (write thread)
Pending normal aio reads: [0, 0, 0, 0] , aio writes: [0, 0, 0, 0] ,
ibuf aio reads:, log i/o's:, sync i/o's:
Pending flushes (fsync) log: 0; buffer pool: 0
0 OS file reads, 0 OS file writes, 0 OS fsyncs
0.00 reads/s, 0 avg bytes/read, 0.00 writes/s, 0.00 fsyncs/s
-------------------------------------
INSERT BUFFER AND ADAPTIVE HASH INDEX
-------------------------------------
Ibuf: size 1, free list len 0, seg size 2, 0 merges
merged operations:
insert 0, delete mark 0, delete 0
discarded operations:
insert 0, delete mark 0, delete 0
Hash table size 2303461, node heap has 0 buffer(s)
Hash table size 2303461, node heap has 0 buffer(s)
Hash table size 2303461, node heap has 0 buffer(s)
Hash table size 2303461, node heap has 0 buffer(s)
Hash table size 2303461, node heap has 0 buffer(s)
Hash table size 2303461, node heap has 0 buffer(s)
Hash table size 2303461, node heap has 0 buffer(s)
Hash table size 2303461, node heap has 0 buffer(s)
0.00 hash searches/s, 1.00 non-hash searches/s
---
LOG
---
Log sequence number 8204
Log flushed up to 0
Pages flushed up to 8204
Last checkpoint at 8192
0 pending log flushes, 0 pending chkp writes
0 log i/o's done, 0.00 log i/o's/second
----------------------
BUFFER POOL AND MEMORY
----------------------
Total large memory allocated 0
Dictionary memory allocated 4272484
Buffer pool size 510568
Free buffers 271669
Database pages 238899
Old database pages 88146
Modified db pages 0
Pending reads 0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 2287, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 49550, created 189349, written 4828
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
Buffer pool hit rate 1000 / 1000, young-making rate 0 / 1000 not 0 / 1000
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 238899, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
----------------------
INDIVIDUAL BUFFER POOL INFO
----------------------
---BUFFER POOL 0
Buffer pool size 255284
Free buffers 136125
Database pages 119159
Old database pages 43966
Modified db pages 0
Pending reads 0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 1238, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 24722, created 94437, written 68
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
Buffer pool hit rate 1000 / 1000, young-making rate 0 / 1000 not 0 / 1000
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 119159, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
---BUFFER POOL 1
Buffer pool size 255284
Free buffers 135544
Database pages 119740
Old database pages 44180
Modified db pages 0
Pending reads 0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 1049, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 24828, created 94912, written 4760
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
Buffer pool hit rate 1000 / 1000, young-making rate 0 / 1000 not 0 / 1000
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 119740, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
--------------
ROW OPERATIONS
--------------
0 queries inside InnoDB, 0 queries in queue
0 read views open inside InnoDB
Process ID=8465, Main thread ID=47357039400704, state: sleeping
Number of rows inserted 3672324, updated 8861306, deleted 2146, read 1562714829
0.00 inserts/s, 0.50 updates/s, 0.00 deletes/s, 0.64 reads/s
----------------------------
END OF INNODB MONITOR OUTPUT
============================
I performed a schema alteration which involved (among other things) two linked tables.
DROP TABLE `Bump`; # this used to have a foreign key to Place
ALTER TABLE `Place`
...
DROP PRIMARY KEY, #it used to be a composite key from two decmals
ADD PRIMARY KEY (`id`) USING BTREE;
After that, I tried to change the engine of the table:
ALTER TABLE `Place` ENGINE = MyISAM;
But it gives me:
mysql> ALTER TABLE `mydb`.`Place` ENGINE = MyISAM;
ERROR 1217 (23000): Cannot delete or update a parent row: a foreign key constraint fails
This happens consistently for a brand-new table. Here is the trace below. But in an empty table, it does not say anything.
But for a previously populated Place, it had mentioned the Bump table by name. Why is this happening to me, when the parent table does not have its previous primary key and the child table does not exist?
I am converting to MyISAM to avoid transactions overhead for a large number of inserts.
mysql> show engine innodb status;
+--------+------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Type | Name | Status |
+--------+------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| InnoDB | |
=====================================
120806 18:49:20 INNODB MONITOR OUTPUT
=====================================
Per second averages calculated from the last 28 seconds
-----------------
BACKGROUND THREAD
-----------------
srv_master_thread loops: 1 1_second, 1 sleeps, 0 10_second, 1 background, 1 flush
srv_master_thread log flush and writes: 1
----------
SEMAPHORES
----------
OS WAIT ARRAY INFO: reservation count 3, signal count 3
Mutex spin waits 1, rounds 30, OS waits 1
RW-shared spins 2, rounds 60, OS waits 2
RW-excl spins 0, rounds 0, OS waits 0
Spin rounds per wait: 30.00 mutex, 30.00 RW-shared, 0.00 RW-excl
------------
TRANSACTIONS
------------
Trx id counter 2D00
Purge done for trx's n:o < 2BB0 undo n:o < 0
History list length 2467
LIST OF TRANSACTIONS FOR EACH SESSION:
---TRANSACTION 0, not started
MySQL thread id 37, OS thread handle 0xa6affb40, query id 182 localhost root
show engine innodb status
---TRANSACTION 0, not started
MySQL thread id 36, OS thread handle 0xb625ab40, query id 177 localhost 127.0.0.1 root
--------
FILE I/O
--------
I/O thread 0 state: waiting for i/o request (insert buffer thread)
I/O thread 1 state: waiting for i/o request (log thread)
I/O thread 2 state: waiting for i/o request (read thread)
I/O thread 3 state: waiting for i/o request (read thread)
I/O thread 4 state: waiting for i/o request (read thread)
I/O thread 5 state: waiting for i/o request (read thread)
I/O thread 6 state: waiting for i/o request (write thread)
I/O thread 7 state: waiting for i/o request (write thread)
I/O thread 8 state: waiting for i/o request (write thread)
I/O thread 9 state: waiting for i/o request (write thread)
Pending normal aio reads: 0 [0, 0, 0, 0] , aio writes: 0 [0, 0, 0, 0] ,
ibuf aio reads: 0, log i/o's: 0, sync i/o's: 0
Pending flushes (fsync) log: 0; buffer pool: 0
671 OS file reads, 3 OS file writes, 3 OS fsyncs
0.00 reads/s, 0 avg bytes/read, 0.00 writes/s, 0.00 fsyncs/s
-------------------------------------
INSERT BUFFER AND ADAPTIVE HASH INDEX
-------------------------------------
Ibuf: size 1, free list len 0, seg size 2, 0 merges
merged operations:
insert 0, delete mark 0, delete 0
discarded operations:
insert 0, delete mark 0, delete 0
Hash table size 553193, node heap has 2 buffer(s)
0.00 hash searches/s, 0.00 non-hash searches/s
---
LOG
---
Log sequence number 10825171
Log flushed up to 10825171
Last checkpoint at 10825171
0 pending log writes, 0 pending chkp writes
8 log i/o's done, 0.00 log i/o's/second
----------------------
BUFFER POOL AND MEMORY
----------------------
Total memory allocated 135987200; in additional pool allocated 0
Dictionary memory allocated 358285
Buffer pool size 8191
Free buffers 7529
Database pages 660
Old database pages 263
Modified db pages 0
Pending reads 0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 0, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 660, created 0, written 0
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool page gets since the last printout
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 660, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
--------------
ROW OPERATIONS
--------------
0 queries inside InnoDB, 0 queries in queue
1 read views open inside InnoDB
Main thread process no. 26970, id 2791775040, state: waiting for server activity
Number of rows inserted 0, updated 0, deleted 0, read 0
0.00 inserts/s, 0.00 updates/s, 0.00 deletes/s, 0.00 reads/s
----------------------------
END OF INNODB MONITOR OUTPUT
============================
|
+--------+------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
It seems that there must be another foreign key on the table (or linking to the table).
What do you get back from 'show create table mydb.Place'?