[MDEV-11064] Restrict the speed of reading binlog from Master Created: 2016-10-15  Updated: 2017-10-27  Resolved: 2016-10-21

Status: Closed
Project: MariaDB Server
Component/s: Replication
Fix Version/s: 10.2.3

Type: Task Priority: Major
Reporter: Sergey Vojtovich Assignee: Kristian Nielsen
Resolution: Fixed Votes: 0
Labels: contribution, foundation

Issue Links:
Relates
relates to MDEV-11120 sys_vars.sysvars_server_notembedded f... Closed

 Description   

In some case, the speed of reading binlog from master is high, especially when doing a new replica.
It would bring the high traffic in master.
So We introduce a new variable "read_binlog_speed_limit" to control the binlog reading rate for IO thread to solve the problem.

handle_io_slave:
last_add_time = now() 
  tokens = read_binlog_speed_limit //there are some initial tokens in the bucket
  while(true){
    event = read_event() 
      if (read_binlog_speed_limit > 0) {
        if (tokents > TOKEN_MAX) { 
          tokens = TOKEN_MAX 
            last_add_time = now() 
        } 
        do{ 
          //put some token
          tokens = tokens + (now()-last_add_time)*read_binlog_speed_limit;
          //if the token is not enough, sleep some time.
          if(tokens < event.real_network_read_len)
            sleep((event.len-tokens)/speed_limit) 
        } 
      }
    write_event(event) 
  }

It can work when slave_compressed_protocol is on.
But it maybe doesn't work well when the binlog event is very big.



 Comments   
Comment by Kristian Nielsen [ 2016-10-21 ]

Pushed to 10.2.3, thanks!

Generated at Thu Feb 08 07:47:01 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.