Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove unflushed events warning when trx metadata is enabled on SBR
Summary: mysqlbinlog expects rows_query event only in RBR. It prints an unflushed event warning when it parses a transaction which has rows_query but not a rows events with STMT_END_F flag set. Since there is no direct way to tell the binlog format in mysqlbinlog, we'll just forgo the warning for rows_event which contain metadata. Reference Patch: facebook/mysql-5.6@89e1c03ac Reviewed By: lloyd Differential Revision: D10054923 ----------------------------------------------------------------------- optimize Rows_query_log_event::has_trx_meta_data() Summary: Rows_query_log_event::has_trx_meta_data() is expensive as it does a bunch of string manipulation to figure out if it is prepended by TRX_META_DATA. In a random profile, it shows to take up 2.7% CPU cycles on secondaries. The function is called multiple times from different places during applying a trx from worker threads: 1. Rows_query_log_event::do_apply_event(): The 'apply' of this event stashes the trx_meta_data_json into 'rli' _only_ if the event contains trx_meta_data. This is the first invocation of Rows_query_log_event::has_trx_meta_data() 2. Query_log_event::do_apply_event(): It needs to cleanup the 'rows_query_ev' stashed in 'rli' _only_ if it has trx_meta_data. Hence it calls Rows_query_log_event::has_trx_metadata() again 3. Log_event::apply_event(): This extracts the timestamp (for 'milli-secs behind master' calculation) from trx_meta_data (stashed inside rli in #1) and needs to check if the event contains trx_meta_data. Hence it calls Rows_query_log_event::has_trx_metadata() again It is best to cache this information in the event itself so that the cost of Rows_query_log_event::has_trx_metadata() is paid only once. This reduces the cost of this method by 3x. In a subsequent diff, I intend to cache the result of Query_log_event::extract_trx_metadata() since this method is also called multiple times and it is expensive as it does a bunch of json parsing and string construction/manipulation. Reviewed By: abhinav04sharma Differential Revision: D31373879
- Loading branch information