Foreign Key Constrain remains - mysql

MariaDB, myphpadmin
I dropped a table due to issues with creating FK constraint. I am trying to recreate the table but it seems like the FK constraint is still in the DB somewhere. I cannot delete as there is no reference to it, that I can see anyway. I have no idea where to look to drop the constraint
Trying to create the table I get the following error.
=====================================
2020-03-04 18:58:15 0x14c6100cc700 INNODB MONITOR OUTPUT
=====================================
Per second averages calculated from the last 40 seconds
-----------------
BACKGROUND THREAD
-----------------
srv_master_thread loops: 82 srv_active, 0 srv_shutdown, 53679 srv_idle
srv_master_thread log flush and writes: 53761
----------
SEMAPHORES
----------
OS WAIT ARRAY INFO: reservation count 467
OS WAIT ARRAY INFO: signal count 372
RW-shared spins 0, rounds 1085, OS waits 396
RW-excl spins 0, rounds 4555, OS waits 20
RW-sx spins 3, rounds 34, OS waits 1
Spin rounds per wait: 1085.00 RW-shared, 4555.00 RW-excl, 11.33 RW-sx
------------------------
LATEST FOREIGN KEY ERROR
------------------------
2020-03-04 18:58:14 0x14c610081700 Error in foreign key constraint of table moviesdb/movie_genre:
there is no index in the table which would contain
the columns as the first columns, or the data types in the
table do not match the ones in the referenced table
or one of the ON ... SET NULL columns is declared NOT NULL. Constraint:
,
CONSTRAINT `genre_id_fk` FOREIGN KEY (`genre_id`) REFERENCES `genre` (`genre_id`) ON DELETE CASCADE ON UPDATE CASCADE
------------
TRANSACTIONS
------------
Trx id counter 237460
Purge done for trx's n:o < 237460 undo n:o < 0 state: running
History list length 1
LIST OF TRANSACTIONS FOR EACH SESSION:
---TRANSACTION 304315944137048, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 304315944132792, 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: 0
5389 OS file reads, 3086 OS file writes, 1050 OS fsyncs
0.00 reads/s, 0 avg bytes/read, 0.55 writes/s, 0.20 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 69257, node heap has 1 buffer(s)
Hash table size 69257, node heap has 2 buffer(s)
Hash table size 69257, node heap has 1 buffer(s)
Hash table size 69257, node heap has 2 buffer(s)
Hash table size 69257, node heap has 2 buffer(s)
Hash table size 69257, node heap has 2 buffer(s)
Hash table size 69257, node heap has 3 buffer(s)
Hash table size 69257, node heap has 2 buffer(s)
0.07 hash searches/s, 1.10 non-hash searches/s
---
LOG
---
Log sequence number 845237404
Log flushed up to 845237404
Pages flushed up to 845237404
Last checkpoint at 845237395
0 pending log flushes, 0 pending chkp writes
673 log i/o's done, 0.10 log i/o's/second
----------------------
BUFFER POOL AND MEMORY
----------------------
Total large memory allocated 285212672
Dictionary memory allocated 847024
Buffer pool size 16030
Free buffers 10583
Database pages 5432
Old database pages 2018
Modified db pages 0
Percent of dirty pages(LRU & free pages): 0.000
Max dirty pages percent: 75.000
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 5071, created 361, written 2302
0.00 reads/s, 0.10 creates/s, 0.40 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: 5432, 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=488, Main thread ID=22840912578304, state: sleeping
Number of rows inserted 820, updated 2, deleted 4, read 134187
0.00 inserts/s, 0.00 updates/s, 0.00 deletes/s, 0.00 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
============================

The error message is right there in the log:
Error in foreign key constraint of table moviesdb/movie_genre
there is no index in the table which would contain
the columns as the first columns, or the data types in the
table do not match the ones in the referenced table
So basically this means that
either the datatype and length of column genre_id in table movie_genre is not the same as column genre_id in table genre
or: there is no index on genre (genre_id) (or in which genre_id appears first); if so, this would indicate another flaw with your table structure as, most probably, genre_id should be the primary key of the genre table.

Related

Looking for mysql Innodb recommendation

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.

Large import InnoDB - Error log entry analysis

I'm currently import a large CSV file and I'm trying to understand the logs that are coming into my error.log file. The import keeps on going, so this might be nothing, but given that it's logged into the error.log file with a default set-up, and I have no idea what to make out of it, it might be time for me to learn something by reaching out to the MariaDB community.
The log I'm getting is the following:
=====================================
2021-09-30 21:03:22 0x7f0848d41640 INNODB MONITOR OUTPUT
=====================================
Per second averages calculated from the last 20 seconds
-----------------
BACKGROUND THREAD
-----------------
srv_master_thread loops: 564 srv_active, 0 srv_shutdown, 1068 srv_idle
srv_master_thread log flush and writes: 1632
----------
SEMAPHORES
----------
OS WAIT ARRAY INFO: reservation count 309014
--Thread 139674486203968 has waited at trx0undo.cc line 777 for 436.00 seconds the semaphore:
Mutex at 0x56464c440288, Mutex REDO_RSEG created trx0rseg.cc:397, lock var 2
--Thread 139673591895616 has waited at buf0flu.cc line 1214 for 431.00 seconds the semaphore:
SX-lock on RW-latch at 0x7f085fda1ab0 created in file buf0buf.cc line 1563
a writer (thread id 139673460528704) has reserved it in mode exclusive
number of readers 0, waiters flag 1, lock_word: 0
Last time write locked in file trx0rseg.ic line 43
OS WAIT ARRAY INFO: signal count 1296199
RW-shared spins 1239237, rounds 9381718, OS waits 207220
RW-excl spins 865910, rounds 6692891, OS waits 88463
RW-sx spins 375, rounds 11083, OS waits 365
Spin rounds per wait: 7.57 RW-shared, 7.73 RW-excl, 29.55 RW-sx
------------
TRANSACTIONS
------------
Trx id counter 429
Purge done for trx's n:o < 425 undo n:o < 87636886 state: running
History list length 1
LIST OF TRANSACTIONS FOR EACH SESSION:
---TRANSACTION 428, ACTIVE 1482 sec inserting
mysql tables in use 1, locked 1
1 lock struct(s), heap size 1128, 0 row lock(s), undo log entries 51774178
MySQL thread id 48, OS thread handle 139674486203968, query id 78 localhost root Reading file
LOAD DATA INFILE 'file.csv' INTO TABLE TABLE_X
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
lines terminated by '\r\n'
IGNORE 1 LINES
--------
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: 1
452318 OS file reads, 589584 OS file writes, 172513 OS fsyncs
66.75 reads/s, 16384 avg bytes/read, 134.49 writes/s, 134.49 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 34679, node heap has 0 buffer(s)
Hash table size 34679, node heap has 104 buffer(s)
Hash table size 34679, node heap has 0 buffer(s)
Hash table size 34679, node heap has 0 buffer(s)
Hash table size 34679, node heap has 0 buffer(s)
Hash table size 34679, node heap has 0 buffer(s)
Hash table size 34679, node heap has 0 buffer(s)
Hash table size 34679, node heap has 0 buffer(s)
0.00 hash searches/s, 0.00 non-hash searches/s
---
LOG
---
Log sequence number 237726885168
Log flushed up to 237726880386
Pages flushed up to 237724062470
Last checkpoint at 237724062470
0 pending log flushes, 0 pending chkp writes
3473 log i/o's done, 0.95 log i/o's/second
----------------------
BUFFER POOL AND MEMORY
----------------------
Total large memory allocated 405471232
Dictionary memory allocated 24640
Buffer pool size 8192
Free buffers 0
Database pages 8088
Old database pages 3003
Modified db pages 3448
Percent of dirty pages(LRU & free pages): 42.626
Max dirty pages percent: 75.000
Pending reads 0
Pending writes: LRU 0, flush list 2, single page 1
Pages made young 1119, not young 211124188
0.00 youngs/s, 200.24 non-youngs/s
Pages read 452305, created 195449, written 499116
66.75 reads/s, 0.00 creates/s, 66.75 writes/s
Buffer pool hit rate 900 / 1000, young-making rate 0 / 1000 not 298 / 1000
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 8088, unzip_LRU len: 0
I/O sum[27390]:cur[946], unzip sum[0]:cur[0]
--------------
ROW OPERATIONS
--------------
0 queries inside InnoDB, 0 queries in queue
0 read views open inside InnoDB
Process ID=37451, Main thread ID=139673583502912, state: sleeping
Number of rows inserted 51774178, updated 0, deleted 0, read 0
0.00 inserts/s, 0.00 updates/s, 0.00 deletes/s, 0.00 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 believe this is an output due to something timing out, but I have no idea as to what "that" could be. The import doesn't stop either, it just continues on. Any help (or pointers) on dissecting this log would be greatly appreciated!

MySQL hangs on SELECT from table with blob fields

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
============================

Convering an InnoDB table to MyISAM: a non-existent table complains

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'?

SELECT ... FOR UPDATE locking trouble when applied on date range

I'm having following table structure.
reservation: (InnoDB)
------------------------------------------
id INT,
date DATE,
item_id INT,
slot VARCHAR(50);
PRIMARY KEY(id), UNIQUE KEY(item_id,date).
Now i'm trying to use SELECT.....FOR UPDATE on reservation table inside a transaction to lock specific rows within date range(eg:2012-06-15 to 2012-06-16) of a particular item_id.
SELECT availability FROM reservation WHERE item_id={$item_id} AND (date>='{$to_date}' AND date<='{$from_date}') FOR UPDATE
NOW when i use the above statement, it is blocking all the rows of particular item_id even beyond the date range.I'm also using this UNIQUE KEY(item_id,date).
How to lock only particular date range of a specific item_id?
regards,
ravi.
ADDED:
|
=====================================
120615 20:14:13 INNODB MONITOR OUTPUT
=====================================
Per second averages calculated from the last 24 seconds
----------
SEMAPHORES
----------
OS WAIT ARRAY INFO: reservation count 12, signal count 12
Mutex spin waits 0, rounds 180, OS waits 4
RW-shared spins 10, OS waits 5; RW-excl spins 2, OS waits 2
------------
TRANSACTIONS
------------
Trx id counter 0 15147
Purge done for trx's n:o < 0 15136 undo n:o < 0 0
History list length 2
Total number of lock structs in row lock hash table 2
LIST OF TRANSACTIONS FOR EACH SESSION:
---TRANSACTION 0 0, not started, OS thread id 2940
MySQL thread id 76, query id 1487 localhost 127.0.0.1 root
SHOW innodb status
---TRANSACTION 0 15143, not started, OS thread id 2588
MySQL thread id 10, query id 578 localhost 127.0.0.1 root
---TRANSACTION 0 15144, ACTIVE 11526 sec, OS thread id 2740
3 lock struct(s), heap size 320
MySQL thread id 11, query id 577 localhost 127.0.0.1 root
--------
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 (write thread)
Pending normal aio reads: 0, aio writes: 0,
ibuf aio reads: 0, log i/o's: 0, sync i/o's: 0
Pending flushes (fsync) log: 0; buffer pool: 0
187 OS file reads, 75 OS file writes, 29 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 inserts, 0 merged recs, 0 merges
Hash table size 62383, used cells 0, node heap has 1 buffer(s)
0.00 hash searches/s, 0.00 non-hash searches/s
---
LOG
---
Log sequence number 0 8287163
Log flushed up to 0 8287163
Last checkpoint at 0 8287163
0 pending log writes, 0 pending chkp writes
24 log i/o's done, 0.00 log i/o's/second
----------------------
BUFFER POOL AND MEMORY
----------------------
Total memory allocated 23277934; in additional pool allocated 1430400
Buffer pool size 960
Free buffers 895
Database pages 64
Modified db pages 0
Pending reads 0
Pending writes: LRU 0, flush list 0, single page 0
Pages read 64, created 0, written 51
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
Buffer pool hit rate 1000 / 1000
--------------
ROW OPERATIONS
--------------
0 queries inside InnoDB, 0 queries in queue
1 read views open inside InnoDB
Main thread id 1544, state: waiting for server activity
Number of rows inserted 10, updated 0, deleted 0, read 66
0.00 inserts/s, 0.00 updates/s, 0.00 deletes/s, 0.00 reads/s
----------------------------
END OF INNODB MONITOR OUTPUT
============================
|