1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-27 18:02:13 +03:00

Binlog compressed

Add some event types for the compressed event, there are:
     QUERY_COMPRESSED_EVENT,
     WRITE_ROWS_COMPRESSED_EVENT_V1,
     UPDATE_ROWS_COMPRESSED_EVENT_V1,
     DELETE_POWS_COMPRESSED_EVENT_V1,
     WRITE_ROWS_COMPRESSED_EVENT,
     UPDATE_ROWS_COMPRESSED_EVENT,
     DELETE_POWS_COMPRESSED_EVENT.
These events inheritance the uncompressed editor events. One of their constructor functions and write
function have been overridden for uncompressing and compressing. Anything but this is totally the same.

On slave, The IO thread will uncompress and convert them When it receiving the events from the master.
So the SQL and worker threads can be stay unchanged.

Now we use zlib as compress algorithm. It maybe support other algorithm in the future.
This commit is contained in:
vinchen
2016-10-08 12:07:26 +08:00
committed by Kristian Nielsen
parent 27025221fe
commit 640051e06a
13 changed files with 797 additions and 39 deletions

View File

@ -6373,7 +6373,14 @@ int THD::binlog_write_row(TABLE* table, bool is_trans,
if (variables.option_bits & OPTION_GTID_BEGIN)
is_trans= 1;
Rows_log_event* const ev=
Rows_log_event* ev;
if (binlog_should_compress(len))
ev =
binlog_prepare_pending_rows_event(table, variables.server_id,
len, is_trans,
static_cast<Write_rows_compressed_log_event*>(0));
else
ev =
binlog_prepare_pending_rows_event(table, variables.server_id,
len, is_trans,
static_cast<Write_rows_log_event*>(0));
@ -6421,8 +6428,15 @@ int THD::binlog_update_row(TABLE* table, bool is_trans,
DBUG_DUMP("after_row", after_row, after_size);
#endif
Rows_log_event* const ev=
binlog_prepare_pending_rows_event(table, variables.server_id,
Rows_log_event* ev;
if(binlog_should_compress(before_size + after_size))
ev =
binlog_prepare_pending_rows_event(table, variables.server_id,
before_size + after_size, is_trans,
static_cast<Update_rows_compressed_log_event*>(0));
else
ev =
binlog_prepare_pending_rows_event(table, variables.server_id,
before_size + after_size, is_trans,
static_cast<Update_rows_log_event*>(0));
@ -6474,8 +6488,15 @@ int THD::binlog_delete_row(TABLE* table, bool is_trans,
if (variables.option_bits & OPTION_GTID_BEGIN)
is_trans= 1;
Rows_log_event* const ev=
binlog_prepare_pending_rows_event(table, variables.server_id,
Rows_log_event* ev;
if(binlog_should_compress(len))
ev =
binlog_prepare_pending_rows_event(table, variables.server_id,
len, is_trans,
static_cast<Delete_rows_compressed_log_event*>(0));
else
ev =
binlog_prepare_pending_rows_event(table, variables.server_id,
len, is_trans,
static_cast<Delete_rows_log_event*>(0));
@ -6940,15 +6961,28 @@ int THD::binlog_query(THD::enum_binlog_query_type qtype, char const *query_arg,
flush the pending rows event if necessary.
*/
{
Query_log_event qinfo(this, query_arg, query_len, is_trans, direct,
suppress_use, errcode);
Log_event* ev = NULL;
int error = 0;
/*
Binlog table maps will be irrelevant after a Query_log_event
(they are just removed on the slave side) so after the query
log event is written to the binary log, we pretend that no
table maps were written.
*/
int error= mysql_bin_log.write(&qinfo);
*/
if(binlog_should_compress(query_len))
{
Query_compressed_log_event qinfo(this, query_arg, query_len, is_trans, direct,
suppress_use, errcode);
error= mysql_bin_log.write(&qinfo);
}
else
{
Query_log_event qinfo(this, query_arg, query_len, is_trans, direct,
suppress_use, errcode);
error= mysql_bin_log.write(&qinfo);
}
binlog_table_maps= 0;
DBUG_RETURN(error);
}