chusiang / mysql-master-master

Automatically exported from code.google.com/p/mysql-master-master
GNU General Public License v2.0
1 stars 1 forks source link

Reader / writer groups sharing hosts can end up with an unbalanced distribution of IP's #3

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Enhancement request:

Since the sub CountHostRoles in lib/config.pm only counts the number of
IP's for a given role, sometimes a host can end up with many IP's (from
different roles) while other hosts end up with no IP's.  This can
especially be true when there are less IP's than hosts for a given group.

A suggested fix is to change CountHostRoles to consider all roles when
counting assigned IP's:

Index: config.pm
===================================================================
--- config.pm   (revision 12)
+++ config.pm   (working copy)
@@ -365,7 +365,7 @@

     my $cnt = 0;
     foreach my $role_name (keys(%$roles)) {
-        next unless ($role_name eq $check_role);
+#        next unless ($role_name eq $check_role);
         my $role = $roles->{$role_name};
         my $role_ips = $role->{ips};

@@ -374,7 +374,7 @@
             next unless ($ip_info->{assigned_to} eq $host);
             $cnt++;
         }
-        last;
+#        last;
     }

Original issue reported on code.google.com by bn-s...@nesbitt.org on 11 Apr 2007 at 7:08

GoogleCodeExporter commented 9 years ago
Sounds pretty reasonable. Will check it now on my test configuration.

Original comment by kovy...@gmail.com on 11 Apr 2007 at 7:19

GoogleCodeExporter commented 9 years ago
Here is an example given the below config:

# Mysql Reader role
role reader
    mode balanced
    servers test01, test02, test03
    ip 10.0.1.11, 10.0.1.12

# Mysql Writer role
role writer
    mode exclusive
    servers test01, test02
    ip 10.0.1.15

Before change:

# ./mmm_control show
Config file: mmm_mon.conf
Daemon is running!
Servers status:
  test01(10.0.1.91): master/ONLINE. Roles: reader(10.0.1.11;), writer(10.0.1.15;)
  test02(10.0.1.92): master/ONLINE. Roles: reader(10.0.1.12;)
  test03(10.0.1.93): slave/ONLINE. Roles: None

After change:

# ./mmm_control show
Config file: mmm_mon.conf
Daemon is running!
Servers status:
  test01(10.0.1.91): master/ONLINE. Roles: writer(10.0.1.15;)
  test02(10.0.1.92): master/ONLINE. Roles: reader(10.0.1.11;)
  test03(10.0.1.93): slave/ONLINE. Roles: reader(10.0.1.12;)

Original comment by bn-s...@nesbitt.org on 11 Apr 2007 at 7:34

GoogleCodeExporter commented 9 years ago
Damn, great! Just realized, that it would allow us to have writer-only hosts 
which
would be promoted to reader when some reader will go down. 

Original comment by kovy...@gmail.com on 11 Apr 2007 at 7:53

GoogleCodeExporter commented 9 years ago
Yes, that's what I was trying to accomplish :)

Original comment by bn-s...@nesbitt.org on 11 Apr 2007 at 8:05

GoogleCodeExporter commented 9 years ago
"Fixed" in revision 14 of the trunk.

Original comment by kovy...@gmail.com on 11 Apr 2007 at 8:28