From add315d795ffc2b36b828fc5f65aaaad04169695 Mon Sep 17 00:00:00 2001 From: Mark Riddoch Date: Wed, 4 Feb 2015 11:17:29 +0000 Subject: [PATCH 1/6] Updated to reflect the shange to the way servers are stored within services --- server/modules/routing/binlog/blr_slave.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/modules/routing/binlog/blr_slave.c b/server/modules/routing/binlog/blr_slave.c index fdbbd2d11..e69784ddf 100644 --- a/server/modules/routing/binlog/blr_slave.c +++ b/server/modules/routing/binlog/blr_slave.c @@ -706,7 +706,7 @@ int len, actual_len, col_len, seqno, ncols, i; strncpy((char *)ptr, column, col_len); // Result string ptr += col_len; - sprintf(column, "%d", router->service->databases->port); + sprintf(column, "%d", router->service->dbref->server->port); col_len = strlen(column); *ptr++ = col_len; // Length of result string strncpy((char *)ptr, column, col_len); // Result string From 85c752d15ca2ab0d30295bc88a5f4841e173f115 Mon Sep 17 00:00:00 2001 From: Mark Riddoch Date: Wed, 4 Feb 2015 12:15:34 +0000 Subject: [PATCH 2/6] Updated error handlign in lien with new requirements of the core --- server/modules/routing/binlog/blr.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/server/modules/routing/binlog/blr.c b/server/modules/routing/binlog/blr.c index 727de4645..271651c49 100644 --- a/server/modules/routing/binlog/blr.c +++ b/server/modules/routing/binlog/blr.c @@ -977,6 +977,24 @@ ROUTER_INSTANCE *router = (ROUTER_INSTANCE *)instance; int error, len; char msg[85], *errmsg; + if (action == ERRACT_RESET) + { + backend_dcb->dcb_errhandle_called = false; + return; + } + + /** Don't handle same error twice on same DCB */ + if (backend_dcb->dcb_errhandle_called) + { + /** we optimistically assume that previous call succeed */ + *succp = true; + return; + } + else + { + backend_dcb->dcb_errhandle_called = true; + } + len = sizeof(error); if (router->master && getsockopt(router->master->fd, SOL_SOCKET, SO_ERROR, &error, &len) == 0 && error != 0) { From 917ad466e3c6b7bd01bf3de4b2ff7a62f553ee4e Mon Sep 17 00:00:00 2001 From: Mark Riddoch Date: Wed, 4 Feb 2015 12:23:14 +0000 Subject: [PATCH 3/6] Updated defaults for router options. --- .../Tutorials/Replication-Proxy-Binlog-Router-Tutorial.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Documentation/Tutorials/Replication-Proxy-Binlog-Router-Tutorial.md b/Documentation/Tutorials/Replication-Proxy-Binlog-Router-Tutorial.md index 84616a721..ea288044a 100644 --- a/Documentation/Tutorials/Replication-Proxy-Binlog-Router-Tutorial.md +++ b/Documentation/Tutorials/Replication-Proxy-Binlog-Router-Tutorial.md @@ -59,11 +59,11 @@ As with uuid, MaxScale must have a unique server-id for the connection it makes ### user -This is the user name that MaxScale uses when it connects to the master. This user name must have the rights required for replication as with any other user that a slave uses for replication purposes. +This is the user name that MaxScale uses when it connects to the master. This user name must have the rights required for replication as with any other user that a slave uses for replication purposes. If the user parameter is not given in the router options then the same user as is used to retrieve the credential information will be used for the replication connection, i.e. the user in the service entry. ### password -The password of the above user. +The password of the above user. If the password is not explicitly given then the password in the service entry will be used. ### master-id @@ -87,7 +87,7 @@ This defines the value of the heartbeat interval in seconds for the connection t ### burstsize -This parameter is used to define the maximum amount of data that will be sent to a slave by MaxScale when that slave is lagging behind the master. In this situation the slave is said to be in "catchup mode", this parameter is designed to both prevent flooding of that slave and also to prevent threads within MaxScale spending disproportionate amounts of time with slaves that are lagging behind the master. The burst size can be defined in Kb, Mb or Gb by adding the qualifier K, M or G to the number given. +This parameter is used to define the maximum amount of data that will be sent to a slave by MaxScale when that slave is lagging behind the master. In this situation the slave is said to be in "catchup mode", this parameter is designed to both prevent flooding of that slave and also to prevent threads within MaxScale spending disproportionate amounts of time with slaves that are lagging behind the master. The burst size can be defined in Kb, Mb or Gb by adding the qualifier K, M or G to the number given. The default value of burstsize is 1Mb and will be used if burstsize is not given in the router options. A complete example of a service entry for a binlog router service would be as follows. @@ -100,6 +100,8 @@ A complete example of a service entry for a binlog router service would be as fo user=maxscale passwd=Mhu87p2D +The minimum set of router options that must be given in the configuration are are server-id and aster-id, default values may be used for all other options. + ## Listener Section As per any service in MaxScale a listener section is required to define the address, port and protocol that is used to listen for incoming connections. In this case those incoming connections will originate from the slave servers. From 8ddb2fa732ecfb59d2b0294f2e20de4d8b4a02be Mon Sep 17 00:00:00 2001 From: Mark Riddoch Date: Wed, 4 Feb 2015 13:10:46 +0000 Subject: [PATCH 4/6] Update to support servers that do not support GTID --- server/modules/routing/binlog/blr_master.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/server/modules/routing/binlog/blr_master.c b/server/modules/routing/binlog/blr_master.c index ac216c665..7044faf50 100644 --- a/server/modules/routing/binlog/blr_master.c +++ b/server/modules/routing/binlog/blr_master.c @@ -314,6 +314,7 @@ char query[128]; "Invalid master state machine state (%d) for binlog router.", router->master_state))); gwbuf_consume(buf, gwbuf_length(buf)); + spinlock_acquire(&router->lock); if (router->reconnect_pending) { @@ -335,7 +336,20 @@ char query[128]; return; } - if (router->master_state != BLRM_BINLOGDUMP && MYSQL_RESPONSE_ERR(buf)) + if (router->master_state == BLRM_GTIDMODE && MYSQL_RESPONSE_ERR(buf)) + { + /* + * If we get an error response to the GTID Mode then we + * asusme the server does not support GTID modes and + * continue. The error is saved and replayed to slaves if + * they also request the GTID mode. + */ + LOGIF(LE, (skygw_log_write( + LOGFILE_ERROR, + "%s: Master server does not support GTID Mode.", + router->service->name))); + } + else if (router->master_state != BLRM_BINLOGDUMP && MYSQL_RESPONSE_ERR(buf)) { LOGIF(LE, (skygw_log_write( LOGFILE_ERROR, From 6bd8d1b5079a5f44d6248c3c5228f6ec69630066 Mon Sep 17 00:00:00 2001 From: Mark Riddoch Date: Wed, 4 Feb 2015 13:12:19 +0000 Subject: [PATCH 5/6] Updated options procesign to allow either password= or passwd= for compatibility with the way we set passwords in other places --- server/modules/routing/binlog/blr.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/server/modules/routing/binlog/blr.c b/server/modules/routing/binlog/blr.c index 271651c49..2d08b3908 100644 --- a/server/modules/routing/binlog/blr.c +++ b/server/modules/routing/binlog/blr.c @@ -270,6 +270,10 @@ unsigned char *defuuid; { inst->password = strdup(value); } + else if (strcmp(options[i], "passwd") == 0) + { + inst->password = strdup(value); + } else if (strcmp(options[i], "master-id") == 0) { inst->masterid = atoi(value); From 77af6b19d26ae64af770f4f9609c4ab09bef7318 Mon Sep 17 00:00:00 2001 From: Mark Riddoch Date: Wed, 4 Feb 2015 13:26:37 +0000 Subject: [PATCH 6/6] Addition of user privilege requirements --- .../Tutorials/Replication-Proxy-Binlog-Router-Tutorial.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Documentation/Tutorials/Replication-Proxy-Binlog-Router-Tutorial.md b/Documentation/Tutorials/Replication-Proxy-Binlog-Router-Tutorial.md index ea288044a..0e01dad59 100644 --- a/Documentation/Tutorials/Replication-Proxy-Binlog-Router-Tutorial.md +++ b/Documentation/Tutorials/Replication-Proxy-Binlog-Router-Tutorial.md @@ -61,9 +61,14 @@ As with uuid, MaxScale must have a unique server-id for the connection it makes This is the user name that MaxScale uses when it connects to the master. This user name must have the rights required for replication as with any other user that a slave uses for replication purposes. If the user parameter is not given in the router options then the same user as is used to retrieve the credential information will be used for the replication connection, i.e. the user in the service entry. +The user that is used for replication, either defined using the user= option in the router options or using the username and password defined of the service must be granted replication privileges on the database server. + + MariaDB> CREATE USER 'repl'@'maxscalehost' IDENTIFIED by 'password'; + MariaDB> GRANT REPLICATION SLAVE ON *.* TO 'repl'@'maxscalehost'; + ### password -The password of the above user. If the password is not explicitly given then the password in the service entry will be used. +The password of the above user. If the password is not explicitly given then the password in the service entry will be used. For compatibility with other username and password definitions within the MaxScale configuration file it is also possible to use the parameter passwd=. ### master-id