From 5360c4e5bcb29d90c36c775a5f874fefaa4a671b Mon Sep 17 00:00:00 2001 From: Luis Soares Date: Mon, 12 Mar 2012 12:28:27 +0000 Subject: BUG#12400313 RELAY_LOG_SPACE_LIMIT IS NOT WORKING IN MANY CASES BUG#64503: mysql frequently ignores --relay-log-space-limit When the SQL thread goes to sleep, waiting for more events, it sets the flag ignore_log_space_limit to true. This gives the IO thread a chance to queue some more events and ultimately the SQL thread will be able to purge the log once it is rotated. By then the SQL thread resets the ignore_log_space_limit to false. However, between the time the SQL thread has set the ignore flag and the time it resets it, the IO thread will be queuing events in the relay log, possibly going way over the limit. This patch makes the IO and SQL thread to synchronize when they reach the space limit and only ask for one event at a time. Thus the SQL thread sets ignore_log_space_limit flag and the IO thread resets it to false everytime it processes one more event. In addition, everytime the SQL thread processes the next event, and the limit has been reached, it checks if the IO thread should rotate. If it should, it instructs the IO thread to rotate, giving the SQL thread a chance to purge the logs (freeing space). Finally, this patch removes the resetting of the ignore_log_space_limit flag from purge_first_log, because this is now reset by the IO thread every time it processes the next event when the limit has been reached. If the SQL thread is in a transaction, it cannot purge so, there is no point in asking the IO thread to rotate. The only thing it can do is to ask for more events until the transaction is over (then it can ask the IO to rotate and purge the log right away). Otherwise, there would be a deadlock (SQL would not be able to purge and IO thread would not be able to queue events so that the SQL would finish the transaction). --- sql/rpl_rli.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'sql/rpl_rli.h') diff --git a/sql/rpl_rli.h b/sql/rpl_rli.h index 113fb04ce00..f49be72db46 100644 --- a/sql/rpl_rli.h +++ b/sql/rpl_rli.h @@ -189,6 +189,13 @@ public: ulonglong log_space_limit,log_space_total; bool ignore_log_space_limit; + /* + Used by the SQL thread to instructs the IO thread to rotate + the logs when the SQL thread needs to purge to release some + disk space. + */ + bool sql_force_rotate_relay; + /* When it commits, InnoDB internally stores the master log position it has processed so far; the position to store is the one of the end of the -- cgit v1.2.1