Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I have noticed the same phenomenon on my systems. Queries which normally take a millisecond will suddenly take 1-2 seconds. All of my cases are simple, single table INSERT/UPDATE/REPLACE statements --- not on any SELECTs. No load, locking, or thread build up is evident. </p> <p>I had suspected that it's due to clearing out dirty pages, flushing changes to disk, or some hidden mutex, but I have yet to narrow it down.</p> <p><strong>Also Ruled Out</strong></p> <ul> <li>Server load -- no correlation with high load</li> <li>Engine -- happens with InnoDB/MyISAM/Memory</li> <li>MySQL Query Cache -- happens whether it's on or off</li> <li>Log rotations -- no correlation in events</li> </ul> <p>The only other observation I have at this point is derived from the fact I'm running the same db on multiple machines. I have a heavy read application so I'm using an environment with replication -- most of the load is on the slaves. I've noticed that even though there is minimal load on the master, the phenomenon occurs more there. Even though I see no locking issues, maybe it's Innodb/Mysql having trouble with (thread) concurrency? Recall that the updates on the slave will be single threaded.</p> <p>MySQL Verion 5.1.48</p> <p><strong>Update</strong></p> <p>I think I have a lead for the problem on my case. On some of my servers, I noticed this phenomenon on more than the others. Seeing what was different between the different servers, and tweaking things around, I was lead to the <a href="http://dev.mysql.com/doc/refman/5.1/en/innodb-parameters.html#sysvar_innodb_flush_log_at_trx_commit" rel="noreferrer">MySQL innodb system variable</a> <code>innodb_flush_log_at_trx_commit</code>.</p> <p>I found the doc a bit awkward to read, but <code>innodb_flush_log_at_trx_commit</code> can take the values of 1,2,0:</p> <ul> <li>For 1, the log buffer is flushed to the log file for every commit, and the log file is flushed to disk for every commit.</li> <li>For 2, the log buffer is flushed to the log file for every commit, and the log file is flushed to disk approximately every 1-2 seconds.</li> <li>For 0, the log buffer is flushed to the log file every second, and the log file is flushed to disk every second.</li> </ul> <p>Effectively, in the order (1,2,0), as reported and documented, you're supposed to get with increasing performance in trade for increased risk.</p> <p>Having said that, I found that the servers with <code>innodb_flush_log_at_trx_commit=0</code> were performing worse (i.e. having 10-100 times more "long updates") than the servers with <code>innodb_flush_log_at_trx_commit=2</code>. Moreover, things immediately improved on the bad instances when I switched it to 2 (note you can change it on the fly).</p> <p>So, my question is, what is yours set to? Note that I'm not blaming this parameter, but rather highlighting that it's context is related to this issue.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload