Home > Software design >  Looking for mysql Innodb recommendation
Looking for mysql Innodb recommendation

Time:06-26

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.

CodePudding user response:

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

CodePudding user response:

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.

  • Related