Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Intermittent blocking mysql query
 
coteo
Jr. Member
 
Total Posts:  5
Joined:  2012-10-01
 

Hello,

I have a big problem on our server which host about ten magento website. I make all obvious optimizations like APC for Opcode, APC for cache backend, innodb settings tuning, magento compilation, etc.

The websites load correctly but sometimes, 5-6 times a day, there are MySQL queries “COMMIT” that block the MySQL server and put a very long time to execute (> 500s). Then with all the new incoming connections the server is full loaded with an error “Too many connections”.

Any ideas ?

Thank you for your help.

 
Magento Community Magento Community
Magento Community
Magento Community
 
coteo
Jr. Member
 
Total Posts:  5
Joined:  2012-10-01
 

Here a screenshot of mysql processes when the problem come

http://img.imagesia.com/fichiers/2l/process_imagesia-com_2l0n_large.jpg

 
Magento Community Magento Community
Magento Community
Magento Community
 
MagenX
Enthusiast
 
Total Posts:  791
Joined:  2008-05-26
Dublin
 

post your my.cnf file (mysql config) here
and server specs

cheers

 
Magento Community Magento Community
Magento Community
Magento Community
 
coteo
Jr. Member
 
Total Posts:  5
Joined:  2012-10-01
 

#
# * Fine Tuning
#
key_buffer              384M
max_allowed_packet      
16M
thread_stack            
192K
thread_cache_size       
8
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
myisam-recover         BACKUP
#max_connections        = 100
table_cache            2048
#thread_concurrency     = 10

# * Query Cache Configuration
#
query_cache_type        1
query_cache_limit       
1M
query_cache_size        
64M

# * Logging and Replication

# Both location gets rotated by the cronjob.
# Be aware that this log type is a performance killer.
# As of 5.1 you can enable the log at runtime!
#general_log_file        = /var/log/mysql/mysql.log
#general_log             = 1

log_error                = /var/log/mysql/error.log

# Here you can see queries with especially long duration
log_slow_queries        = /var/log/mysql/mysql-slow.log
long_query_time 
5
#log-queries-not-using-indexes

# The following can be used as easy to replay backup logs or for replication.
# note: if you are setting up a replication slave, see README.Debian about
#       other settings you may need to change.
#server-id              = 1
#log_bin                        = /var/log/mysql/mysql-bin.log
expire_logs_days        10
max_binlog_size         
100M

#
# * InnoDB
#
# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
# Read the manual for more InnoDB related options. There are many!
innodb_buffer_pool_size 1024M
innodb_additional_mem_pool_size 
20M
innodb_log_file_size 
64M
innodb_flush_method
=O_DIRECT

#
# * Security Features
#
# Read the manual, too, if you want chroot!
# chroot = /var/lib/mysql/
#
# For generating SSL certificates I recommend the OpenSSL GUI "tinyca".
#
# ssl-ca=/etc/mysql/cacert.pem
# ssl-cert=/etc/mysql/server-cert.pem
# ssl-key=/etc/mysql/server-key.pem


# limite Ã  partir de laquelle les tables temporaires sont créées sur le DD
tmp_table_size=128M
max_heap_table_size
=128M

The server is a virtual one, hosted via Proxmox and OpenVZ on a physical server with 6 x AMD Opteron Processor and 16 GB RAM

 
Magento Community Magento Community
Magento Community
Magento Community
 
MagenX
Enthusiast
 
Total Posts:  791
Joined:  2008-05-26
Dublin
 

please run these two scripts to see full picture
https://launchpadlibrarian.net/78745738/tuning-primer.sh
https://raw.github.com/rackerhacker/MySQLTuner-perl/master/mysqltuner.pl

thank you

 
Magento Community Magento Community
Magento Community
Magento Community
 
coteo
Jr. Member
 
Total Posts:  5
Joined:  2012-10-01
 

This two scripts are great ! Unfortunately I follow the recommendations and I had the problems again

Tunin-primer.sh:

SLOW QUERIES
The slow query log is enabled
.
Current long_query_time 10.000000 sec.
You have 166291 out of 6706177 that take longer than 10.000000 secto 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/5.1/en/point-in-time-recovery.html

WORKER THREADS
Current thread_cache_size 
8
Current threads_cached 
7
Current threads_per_sec 
0
Historic threads_per_sec 
0
Your thread_cache_size is fine

MAX CONNECTIONS
Current max_connections 
151
Current threads_connected 
1
Historic max_used_connections 
152
The number of used connections is 100
of the configured maximum.
You should raise max_connections

INNODB STATUS
Current InnoDB index space 
236 M
Current InnoDB data space 
322 M
Current InnoDB buffer pool free 
53 %
Current innodb_buffer_pool_size 1.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 
1.87 G
Configured Max Per
-thread Buffers 424 M
Configured Max 
Global Buffers 1.45 G
Configured Max Memory Limit 
1.87 G
Physical Memory 
7.85 G
Max memory limit seem to be within acceptable norms

KEY BUFFER
Current MyISAM index space 
161 M
Current key_buffer_size 
384 M
Key cache miss rate is 1 
5810
Key buffer free ratio 
75 %
Your key_buffer_size seems to be fine

QUERY CACHE
Query cache is enabled
Current query_cache_size 
64 M
Current query_cache_used 
43 M
Current query_cache_limit 
1 M
Current Query cache Memory fill ratio 
67.68 %
Current query_cache_min_res_unit 4 K
MySQL won
't cache query results that are larger than query_cache_limit in 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 5454 queries where a join could not use an index properly
You have had 33 joins without keys that check for key usage after each row
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 = 20161 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 = 10000 tables
Current table_definition_cache = 256 tables
You have a total of 4459 tables
You have 6179 open tables.
The table_cache value seems to be fine
You should probably increase your table_definition_cache value.

TEMP TABLES
Current max_heap_table_size = 256 M
Current tmp_table_size = 256 M
Of 151485 temp tables, 28% were created on disk
Perhaps you should increase your tmp_table_size and/or max_heap_table_size
to reduce the number of disk-based temporary tables
Note! BLOB and TEXT columns are not allow in memory tables.
If you are using these columns raising these values might not impact your 
ratio of on disk temp tables.

TABLE SCANS
Current read_buffer_size = 128 K
Current table scan ratio = 158 : 1
read_buffer_size seems to be fine

TABLE LOCKING
Current Lock Wait ratio = 1 : 24224
Your table locking seems to be fine

Mysqltuner.pl

>>  MySQLTuner 1.2.0 Major Hayden <major@mhtx.net>
 >>  
Bug reportsfeature requests, and downloads at http://mysqltuner.com/
 
>>  Run with '--help' for additional options and output filtering
[OK] Logged in using credentials from debian maintenance account
.

-------- 
General Statistics --------------------------------------------------
[--] Skipped version check for MySQLTuner script
[OK] Currently running supported MySQL version 5.1.61
-0ubuntu0.10.04.1-log
[OK] Operating on 64
-bit architecture

-------- Storage Engine Statistics -------------------------------------------
[--] Status: +Archive -BDB -Federated +InnoDB -ISAM -NDBCluster 
[
--] Data in MyISAM tables310M (Tables1464)
[--] Data in InnoDB tables322M (Tables2886)
[--] Data in MEMORY tables0B (Tables86)
[!!] Total fragmented tables2895

-------- Security Recommendations  -------------------------------------------
[OK] All database users have passwords assigned

-------- Performance Metrics -------------------------------------------------
[--] Up for: 23h 40m 58s (6M q [79.073 qps]55K connTX8BRX1B)
[--] Reads Writes85% / 15%
[--] Total buffers1.7G global + 2.8M per thread (151 max threads)
[OK] Maximum possible memory usage2.1G (27of installed RAM)
[OK] Slow queries2% (167K/6M)
[!!] Highest connection usage100%  (152/151)
[OK] Key buffer size total MyISAM indexes384.0M/161.1M
[OK] Key buffer hit rate
100.0% (137M cached 23K reads)
[OK] Query cache efficiency85.9% (5M cached 6M selects)
[!!] Query cache prunes per day606827
[OK] Sorts requiring temporary tables
0% (1 temp sorts 245K sorts)
[!!] Joins performed without indexes5502
[
!!] Temporary tables created on disk28% (61K on disk 214K total)
[OK] Thread cache hit rate98% (736 created 55K connections)
[!!] Table cache hit rate19% (6K open 31K opened)
[OK] Open file limit used17% (3K/20K)
[OK] Table locks acquired immediately99% (2M immediate 2M locks)
[OK] InnoDB data size buffer pool322.1M/1.0G
 
Magento Community Magento Community
Magento Community
Magento Community
 
coteo
Jr. Member
 
Total Posts:  5
Joined:  2012-10-01
 

I made many MySQL optimizations and know the problem is gone, thank you for your help

 
Magento Community Magento Community
Magento Community
Magento Community
 
merchantguru
Sr. Member
 
Avatar
Total Posts:  133
Joined:  2008-10-05
San Francisco
 

@coteo, can you post your mysql optimizations so we can see what works for you?

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top