Understanding MySql locking issues
Upcoming SlideShare
Loading in...5
×
 

Understanding MySql locking issues

on

  • 872 views

When you start getting MySQL IOPS errors then you should look for some of the Major Locking issues which is described here

When you start getting MySQL IOPS errors then you should look for some of the Major Locking issues which is described here

Statistics

Views

Total Views
872
Slideshare-icon Views on SlideShare
872
Embed Views
0

Actions

Likes
0
Downloads
5
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Understanding MySql locking issues Understanding MySql locking issues Presentation Transcript

    • “Understanding MySQLLocking Issues”
    • Contents Server Variables Query Cache Locking Issues Internal Locking External Locking Concurrent Inserts Connection Pooling
    • Server VariablesThe MySQL server maintains many system variablesthat indicate how it is configured.• Each system variable has its default value.• We can dynamically change these settings usingSET command.• SHOW VARIABLES• Currently there are 291 variables defined inMySQL 5.1.6• SHOW VARIABLES LIKE have_query_cache;• SHOW STATUS LIKE Table%;
    • Query Cache• The have_query_cache server system variableindicates whether the query cache is available.• SHOW VARIABLES LIKE have_query_cache;• It totally depends upon query_cache_type andquery_cache_size• query_cache_type is of 0,1 and 2 (On DEMAND)• You can set max query_cache_size (1MB) aswell as query_cache_min_res_unit (4KB)• SHOW STATUS LIKE %qcache%;
    • Locking Issues• SHOW STATUS LIKE Table%;To achieve a very high lock speed, MySQL uses tablelocking (instead of page, row, or column locking)for all storage engines except InnoDB andNDBCLUSTER.• Internal Locking• External Locking• Concurrent Inserts
    • Internal LockingPerformed within the MySQL server itself to managecontention for table contents by multiple sessions.MySQL grants table write locks as follows:-If there are no locks on the table, put a write lockon it.Otherwise, put the lock request in the writelock queue.MySQL grants table read locks as follows:-If there are no write locks on the table, put a readlock on it.Otherwise, put the lock request in theread lock queue.
    • External Locking• External locking is used in situations where asingle process such as the MySQL server cannotbe assumed to be the only process that requiresaccess to tables.• If you run multiple servers that use the samedatabase directory, each server must haveexternal locking enabled.• With external locking in effect, each processthat requires access to a table acquires a filesystem lock for the table files before proceedingto access the table.
    • External Locking• External locking affects server performancebecause the server must sometimes wait forother processes before it can access tables.• The easiest way to satisfy these conditions is toalways use --external-locking together with• skip_external_locking = OFF• SET delay-key-write=OFF• SET query-cache-size=0.
    • Concurrent Inserts• The MySQL storage engine supportsconcurrent inserts to reduce contentionbetween readers and writers for a given table• An INSERT statement can be executed to addrows to the end of the table at the same timethat SELECT statements are reading rowsfrom the table.• If there are multiple INSERT statements,they are queued and performed in sequence,concurrently with the SELECT statements.
    • Concurrent Inserts- concurrent_insert = 0, 1, 20) If concurrent_insert is set to 0, concurrentinserts are disabled.1) By default, the variable is set to 1 andconcurrent inserts are handled.2) If the variable is set to 2, concurrent inserts atthe end of the table are permitted even fortables that have deleted rows(holes).
    • Connection Pooling• By default, connection pooling is enabled inADO.NET, Unless you explicitly disable it.• Only connections with the same configurationcan be pooled. ADO.NET keeps several pools atthe same time, one for each configuration.• Connections are separated into pools byconnection string, and by Windows identity whenintegrated security is used.• A connection pool is created for each uniqueconnection string.
    • Connection Pooling- Connections are added to the pool as needed, up tothe maximum pool size specified (100 is thedefault).- Connections are released back into the pool whenthey are closed or disposed.- If MinPoolSize is either not specified in theconnection string or is specified as 0, theconnections in the pool will be closed after aperiod of inactivity.- However, if the specified MinPoolSize is greaterthan zero, the connection pool is not destroyeduntil the AppDomain is unloaded and the process
    • Take Away