Revenue Source

Welcome to the Revenue Source affiliate marketing forums.

You are viewing our internet marketing and SEO forums as a guest which gives you limited access to most of our discussions.  By joining our free community, you will have access to post affiliate marketing topics, communicate privately with other members (PM), exchange SEO strategies, and access many other special features.  Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems, please don't hesitate to contact us.

Go Back   Revenue Source > Site Design & Development > Databases
Reload this Page Concurrent inserts on MyISAM and the binary log
Tags: , , , ,

Reply
 
LinkBack Thread Tools Search this Thread
Old
  (#1 (permalink))
Affiliate Blogs is Offline
Revenue Source Veteran
Affiliate Blogs has a brilliant future here!
 
Affiliate Blogs's Avatar
 
Join Date: Oct 2005
Posts: 8,937
Jack of All Trades
CyberSpace United States
   
Concurrent inserts on MyISAM and the binary log - 05-15-2008

Recently I had an interesting surprise with concurrent inserts into a MyISAM table. The inserts were not happening concurrently with SELECT statements; they were blocking and the process list was filling up with queries in Locked status.
My first thought was that the customer had deleted from the table, which leaves "holes" in the middle of it and prevents concurrent inserts. (You can configure the server to permit concurrent inserts even when there are holes, but it's disabled by default.) However, that turned out not to be the cause; the table was only inserted into (and selected from). Instead, the blocked statements were because of INSERT... SELECT statements that were running against the table, selecting data from it and inserting into another table.
Let's look at what happens here: suppose you have two tables tbl1 and tbl2 and concurrent inserts into tbl2 are running fine. If you now run the following query,
PLAIN TEXT
SQL:
  1. [FONT='Courier New', Courier, monospace]INSERT INTO tbl1 SELECT * FROM tbl2 [/font]



The concurrent inserts into tbl2 can block. This happens if you have the binary log enabled. If you think about it, this makes sense and is correct behavior. The statements have to be serialized for the binary log; otherwise replaying the binary log can result in a different order of execution.
The MySQL manual actually says this, but not in the clearest way. It just says
If you are using the binary log, concurrent inserts are converted to normal inserts for CREATE ... SELECT or INSERT ... SELECT statements.
If you use mysqladmin debug, you'll see an ordinary SELECT gets a lock on the table like this:
PLAIN TEXT
CODE:
  1. [FONT='Courier New', Courier, monospace]Locked - read Low priority read lock [/font]



But on INSERT...SELECT, you'll see this:
PLAIN TEXT
CODE:
  1. [FONT='Courier New', Courier, monospace]Read lock without concurrent inserts [/font]



That read lock is what's blocking the concurrent inserts from happening.
There's no solution to this, if you need the binary log enabled. (It needs to be enabled for replication.) There are workarounds, though. You can use the old trick of SELECT INTO OUTFILE followed by LOAD DATA INFILE. You can use InnoDB instead. Or you can do something more elaborate and application-specific, but that's a topic for another post.
Entry posted by Baron Schwartz | No comment
Add to: | | | |


Concurrent inserts on MyISAM and the binary log - Read More...
  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads for: Concurrent inserts on MyISAM and the binary log
Thread Thread Starter Forum Replies Last Post
Yahoo Harnesses Search For Keyword Inserts Affiliate Marketing News Internet Marketing Articles 0 12-12-2007 06:15 PM
Is it Binary? Affiliate Blogs Programming Help 0 10-15-2007 04:13 PM
MyISAM Scalability and Innodb, Falcon Benchmarks Affiliate Blogs Databases 0 10-12-2007 12:10 PM
InnoDB vs MyISAM vs Falcon benchmarks - part 1 Affiliate Blogs Databases 0 01-08-2007 08:25 AM
Co-market with commission check inserts, anyone? Shawn Collins Marketing Requests / Traffic Trades 3 11-16-2004 03:56 AM



© 2004-6 RevenueSource.com.  All rights reserved.  Do not duplicate or redistribute in any form.
This website and its logos/design are property of RevenueSource.com.  All rights reserved. vBSEO 3.2.0 RC7


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34