| Bug #791 | At binlog rotation, INSERTs may not find their way into the binlog | ||
|---|---|---|---|
| Submitted: | 4 Jul 2003 11:39 | Modified: | 14 Jul 2003 5:59 |
| Reporter: | Guilhem Bichot | ||
| Status: | Closed | ||
| Category: | Server | Severity: | S1 (Critical) |
| Version: | 4.0 | OS: | Any (all) |
| Assigned to: | Target Version: | ||
[11 Jul 2003 7:29]
Guilhem Bichot
Thank you for your bug report. This issue has been fixed in the latest
development tree for that product. You can find more information about
accessing our development trees at
http://www.mysql.com/doc/en/Installing_source_tree.html
fixed in ChangeSet 1.1514
[14 Jul 2003 4:21]
Guilhem Bichot
Re-opened in the 4.0 bk tree after ChangeSet@1.1512.1.13, 2003-07-14 10:12:05+03:00. Can be reproduced by adding a "sleep" in new_file() (see the initial bug report).
[14 Jul 2003 5:59]
Michael Widenius
Thank you for your bug report. This issue has been fixed in the latest
development tree for that product. You can find more information about
accessing our development trees at
http://www.mysql.com/doc/en/Installing_source_tree.html
The fix will appear in 4.0.14

Description: In new_file() (log.cc) I changed code to be like this: close(); + if (save_log_type == LOG_BIN) + { + printf("after close, before open; I wait for 20 seconds\n"); + sleep(20); + printf("sleep finished, opening\n"); + } open(old_name, save_log_type, new_name_ptr, index_file_name, io_cache_type, no_auto_events, max_size); new_file() is called when FLUSH LOGS is issued, or when the binlog exceeds max_binlog_size. Here we sleep between close() and open(), so for 20 seconds the log is marked "closed", i.e. is_open() is false. While in sql_insert we have: if (mysql_bin_log.is_open()) { Query_log_event qinfo(thd, thd->query, thd->query_length, log_delayed); if (mysql_bin_log.write(&qinfo) && transactional_table) error=1; } So any INSERT issued during the 20 seconds silently does not go into the binlog. Indeed, during the sleep I issued INSERT queries and 16 of them are not in the binlog when I finally SHOW BINLOG EVENTS in the old and new binlog. This race condition is just very very serious and critical! How to repeat: Not repeatable except by changing the code or using a debugger to add breakpoints. Suggested fix: is_open() should take locks before reading log_type. I will fix it before 4.0.14 goes out.