Bug #1100 | LOAD DATA INFILE is badly filtered by binlog-*-db rules | ||
---|---|---|---|
Submitted: | 19 Aug 2003 14:06 | Modified: | 20 Aug 2003 15:27 |
Reporter: | Guilhem Bichot | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Replication | Severity: | S3 (Non-critical) |
Version: | 4.0 | OS: | Any (all) |
Assigned to: | Guilhem Bichot | CPU Architecture: | Any |
[19 Aug 2003 14:06]
Guilhem Bichot
[20 Aug 2003 7:22]
Guilhem Bichot
1) No problem with replicate-*-db rules, they are tested in Load_log_event::exec_event(), that is, tested only once (not: once for Create_file, once for Append_block etc). The problems we are discussing here arise from the fact that several related events are not filtered the same way. 2) Yes problems (as reported by customer) can appear on a slave running with --binlog-do-db and --log-slave-updates. Example: my slave has binlog-do-db=test2; on the master I do use test; load data infile ... into table u; then: # before LOAD is done on the master SLAVE> select count(*) from test.u; +----------+ | count(*) | +----------+ | 200000 | +----------+ 1 row in set (0.01 sec) # after LOAD is done on the master SLAVE> select count(*) from test.u; +----------+ | count(*) | +----------+ | 300000 | +----------+ 1 row in set (0.00 sec) # so it has been replicated, ok SLAVE> show binlog events in 'gbichot2-bin.002'; # the first binlog +------------------+---------+--------------+-----------+--------------+------------------------------+ | Log_name | Pos | Event_type | Server_id | Orig_log_pos | Info | +------------------+---------+--------------+-----------+--------------+------------------------------+ | gbichot2-bin.002 | 4 | Append_block | 1 | 7794487 | ;file_id=12;block_len=131072 | <cut> | gbichot2-bin.002 | 1146031 | Exec_load | 1 | 8940514 | ;file_id=12 # The bug: there is no Create_file event, this is wrong and will cause any slave of this slave to fail when it attempts to execute the first Append_block. The problem is that Create_file event has db=test, so it's not logged by the slave, but Append_block and Exec_load don't have their own db: for the test of rules, no db is available (the 'thd' member of the event is null as usual in replication, so there is no 'thd->db' available). When there is no db, the rules are not tested. That's why Append_block and Execute_load are logged. Example of confusion of a slave of this slave: 030820 16:09:02 Slave: Error in Append_block event: could not open file '/tmp/SQL_LOAD-1-48-12.data', Error_code: 2
[20 Aug 2003 8:24]
Guilhem Bichot
Making myself clearer: what was wrong in the example with a slave having --log-slave-updates, is not that Create_file is not logged; I meant it's that Append_block and Exec_load (or Delete_file) are logged. THAT is wrong. The fact that Create_file was not logged is good in itself, but its absence causes the error message when Append_block is executed (but that's Append_block's fault, it should not be there).
[20 Aug 2003 9:31]
Guilhem Bichot
This is not one bug, but two bugs, absolutely unrelated. First bug (on the master) has already been explained (inside mysql_load(), Append_block uses the thread's db, which is different from the table's db, for testing rules). But second bug (on the slave with --log-slave-updates) has nothing to do with it: it's that in the slave thread, mysql_load() does no logging (never); logging is done by Append_block_log_event::exec_event() (this Append_block() has been read from the relay log, it has thd==0; this is different from mysql_load() where Append_block's thd is not null). This is done on purpose (for failsafe) but makes the bug un-solvable, because only Create_file_log_event contains the db; Append_block, which can be much after in the relay log, with other events intermixed, does not know the db. So I have to change it: Create_file_log_event::exec_event(), Append_block_log_event::exec_event() etc should not write to the binlog (that's already the case for Query_log_event::exec_event(): write is in mysql_parse()); write should be done in mysql_load() called by Load_log_event::exec_event() called by Execute_load_log_event::exec_event()).
[20 Aug 2003 15:27]
Guilhem Bichot
Thank you for your bug report. This issue has been committed to our source repository of that product and will be incorporated into the next release. If necessary, you can access the source repository and build the latest available version, including the bugfix, yourself. More information about accessing the source trees is available at http://www.mysql.com/doc/en/Installing_source_tree.html ChangeSet@1.1581, 2003-08-21 00:23:39+02:00, guilhem@mysql.com