From 6dc75d4b9c4313e8b0e507dd4c0b6bec8dadc268 Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Mon, 12 Sep 2016 05:06:42 +0300 Subject: [PATCH 01/21] MXS-860: Detect whether replication is configured The `detect_stale_slave` functionality used to only work when MaxScale had the knowledge that a master server has existed and that replication was working at some point in time. This might be a "safe" way to do it in regards to staleness of the data but in practice it is preferrable to always allow slave to be used for reads. This change adds the missing functionality to the monitor by assigning slave status to all servers which are configured as replication slaves when no master can be found. The new member variable that was added to the SERVER should be removed in 2.1 where the server_info offers the same functionalty without "polluting" the SERVER type. --- Documentation/Monitors/MySQL-Monitor.md | 4 ---- .../Release-Notes/MaxScale-2.0.1-Release-Notes.md | 1 + server/core/server.c | 1 + server/include/server.h | 2 ++ server/modules/monitor/mysql_mon.c | 14 ++++++++++++++ 5 files changed, 18 insertions(+), 4 deletions(-) diff --git a/Documentation/Monitors/MySQL-Monitor.md b/Documentation/Monitors/MySQL-Monitor.md index e0941b561..2b825e5d8 100644 --- a/Documentation/Monitors/MySQL-Monitor.md +++ b/Documentation/Monitors/MySQL-Monitor.md @@ -78,10 +78,6 @@ With this parameter, slaves that have lost their master but have been slaves of a master server can retain their slave status even without a master. This means that when a slave loses its master, it can still be used for reads. -If MaxScale loses the connection to the slave, the slave will lose the stale -slave state because MaxScale doesn't know if the slave has had recent contact -with the master server. - If this feature is disabled, a server is considered a valid slave if and only if it has a running master server monitored by this monitor. diff --git a/Documentation/Release-Notes/MaxScale-2.0.1-Release-Notes.md b/Documentation/Release-Notes/MaxScale-2.0.1-Release-Notes.md index fe6675efc..195bacf53 100644 --- a/Documentation/Release-Notes/MaxScale-2.0.1-Release-Notes.md +++ b/Documentation/Release-Notes/MaxScale-2.0.1-Release-Notes.md @@ -120,6 +120,7 @@ Please consult * [MXS-845](https://jira.mariadb.org/browse/MXS-845): "Server down" event is re-triggered after maintenance mode is repeated * [MXS-842](https://jira.mariadb.org/browse/MXS-842): Unexpected / undocumented behaviour when multiple available masters from mmmon monitor * [MXS-846](https://jira.mariadb.org/browse/MXS-846): MMMon: Maintenance mode on slave logs error message every second +* [MXS-860](https://jira.mariadb.org/browse/MXS-860): I want to access the web site if master server is down. ## Known Issues and Limitations diff --git a/server/core/server.c b/server/core/server.c index c4ef6426b..a29198791 100644 --- a/server/core/server.c +++ b/server/core/server.c @@ -88,6 +88,7 @@ server_alloc(char *servname, char *protocol, unsigned short port) server->persistmax = 0; server->persistmaxtime = 0; server->persistpoolmax = 0; + server->slave_configured = false; spinlock_init(&server->persistlock); spinlock_acquire(&server_spin); diff --git a/server/include/server.h b/server/include/server.h index 81a6a2313..5dfe79cfc 100644 --- a/server/include/server.h +++ b/server/include/server.h @@ -102,6 +102,8 @@ typedef struct server int depth; /**< Replication level in the tree */ long slaves[MAX_NUM_SLAVES]; /**< Slaves of this node */ bool master_err_is_logged; /*< If node failed, this indicates whether it is logged */ + bool slave_configured; /**< Server is configured as a replication slave + * TODO: Remove this for 2.1 */ DCB *persistent; /**< List of unused persistent connections to the server */ SPINLOCK persistlock; /**< Lock for adjusting the persistent connections list */ long persistpoolmax; /**< Maximum size of persistent connections pool */ diff --git a/server/modules/monitor/mysql_mon.c b/server/modules/monitor/mysql_mon.c index 6948175c1..4305505c2 100644 --- a/server/modules/monitor/mysql_mon.c +++ b/server/modules/monitor/mysql_mon.c @@ -323,8 +323,11 @@ static inline void monitor_mysql100_db(MONITOR_SERVERS* database) return; } + database->server->slave_configured = false; + while ((row = mysql_fetch_row(result))) { + database->server->slave_configured = true; /* get Slave_IO_Running and Slave_SQL_Running values*/ if (strncmp(row[12], "Yes", 3) == 0 && strncmp(row[13], "Yes", 3) == 0) @@ -407,8 +410,11 @@ static inline void monitor_mysql55_db(MONITOR_SERVERS* database) return; } + database->server->slave_configured = false; + while ((row = mysql_fetch_row(result))) { + database->server->slave_configured = true; /* get Slave_IO_Running and Slave_SQL_Running values*/ if (strncmp(row[10], "Yes", 3) == 0 && strncmp(row[11], "Yes", 3) == 0) @@ -479,8 +485,11 @@ static inline void monitor_mysql51_db(MONITOR_SERVERS* database) return; } + database->server->slave_configured = false; + while ((row = mysql_fetch_row(result))) { + database->server->slave_configured = true; /* get Slave_IO_Running and Slave_SQL_Running values*/ if (strncmp(row[10], "Yes", 3) == 0 && strncmp(row[11], "Yes", 3) == 0) @@ -994,6 +1003,11 @@ monitorMain(void *arg) { ptr->pending_status |= SERVER_SLAVE; } + else if (root_master == NULL && ptr->server->slave_configured) + { + /** TODO: Change this in 2.1 to use the server_info mechanism */ + ptr->pending_status |= SERVER_SLAVE; + } } ptr->server->status = ptr->pending_status; From 029e6574da1ace10f367a7848cdfb607f7f7ba56 Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Mon, 12 Sep 2016 15:35:15 +0300 Subject: [PATCH 02/21] MXS-812: Always reset counters when backend is closed The active operation counters are now closed every time a backend referece is taken out of use. This should fix a few debug assertions that were hit in tests. --- server/modules/routing/readwritesplit/readwritesplit.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/server/modules/routing/readwritesplit/readwritesplit.c b/server/modules/routing/readwritesplit/readwritesplit.c index f6a60f788..dd2b8a7e7 100644 --- a/server/modules/routing/readwritesplit/readwritesplit.c +++ b/server/modules/routing/readwritesplit/readwritesplit.c @@ -3135,6 +3135,10 @@ static bool select_connect_backend_servers(backend_ref_t **p_master_ref, ss_dassert(backend_ref[i].bref_backend->backend_conn_count > 0); /** disconnect opened connections */ + if (BREF_IS_WAITING_RESULT(&backend_ref[i])) + { + bref_clear_state(&backend_ref[i], BREF_WAITING_RESULT); + } bref_clear_state(&backend_ref[i], BREF_IN_USE); /** Decrease backend's connection counter. */ atomic_add(&backend_ref[i].bref_backend->backend_conn_count, -1); @@ -4299,6 +4303,10 @@ static void handleError(ROUTER *instance, void *router_session, CHK_BACKEND_REF(bref); bref_clear_state(bref, BREF_IN_USE); bref_set_state(bref, BREF_CLOSED); + if (BREF_IS_WAITING_RESULT(bref)) + { + bref_clear_state(bref, BREF_WAITING_RESULT); + } } else { From 7bd0b19b59dfa77a6b72a5f1202e7d2ad94964c3 Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Thu, 15 Sep 2016 23:12:50 +0300 Subject: [PATCH 03/21] Update MaxScale version number --- VERSION.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/VERSION.cmake b/VERSION.cmake index f7abd4919..0693bfd8b 100644 --- a/VERSION.cmake +++ b/VERSION.cmake @@ -5,10 +5,10 @@ set(MAXSCALE_VERSION_MAJOR "2" CACHE STRING "Major version") set(MAXSCALE_VERSION_MINOR "0" CACHE STRING "Minor version") -set(MAXSCALE_VERSION_PATCH "0" CACHE STRING "Patch version") +set(MAXSCALE_VERSION_PATCH "1" CACHE STRING "Patch version") # This should only be incremented if a package is rebuilt set(MAXSCALE_BUILD_NUMBER 1 CACHE STRING "Release number") set(MAXSCALE_VERSION_NUMERIC "${MAXSCALE_VERSION_MAJOR}.${MAXSCALE_VERSION_MINOR}.${MAXSCALE_VERSION_PATCH}") -set(MAXSCALE_VERSION "beta-${MAXSCALE_VERSION_MAJOR}.${MAXSCALE_VERSION_MINOR}.${MAXSCALE_VERSION_PATCH}") +set(MAXSCALE_VERSION "${MAXSCALE_VERSION_MAJOR}.${MAXSCALE_VERSION_MINOR}.${MAXSCALE_VERSION_PATCH}") From 2a4addc298261dad2d0e52789ad345a2a2a1db9c Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Fri, 16 Sep 2016 01:13:52 +0300 Subject: [PATCH 04/21] Clear waiting results flag on client errors When a backend causes an error and it should be sent to the client, the backend reference was closed but the waiting results state was not cleared. This caused a debug assertion to be hit. --- server/modules/routing/readwritesplit/readwritesplit.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/server/modules/routing/readwritesplit/readwritesplit.c b/server/modules/routing/readwritesplit/readwritesplit.c index dd2b8a7e7..07b768e8b 100644 --- a/server/modules/routing/readwritesplit/readwritesplit.c +++ b/server/modules/routing/readwritesplit/readwritesplit.c @@ -4395,6 +4395,10 @@ static void handle_error_reply_client(SESSION *ses, ROUTER_CLIENT_SES *rses, CHK_BACKEND_REF(bref); bref_clear_state(bref, BREF_IN_USE); bref_set_state(bref, BREF_CLOSED); + if (BREF_IS_WAITING_RESULT(bref)) + { + bref_clear_state(bref, BREF_WAITING_RESULT); + } } if (sesstate == SESSION_STATE_ROUTER_READY) From 89f9f4a42f0ecfbb40ad2ce8ee8dbf3e64168525 Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Fri, 16 Sep 2016 01:11:44 +0300 Subject: [PATCH 05/21] Lock writeq before inspecting it Looking at the contents of the writeq should be done under a spinlock otherwise it is possible that another thread grabs the queue. --- server/modules/protocol/mysql_backend.c | 50 ++++++++++--------------- 1 file changed, 20 insertions(+), 30 deletions(-) diff --git a/server/modules/protocol/mysql_backend.c b/server/modules/protocol/mysql_backend.c index 178d36c61..5addc27b8 100644 --- a/server/modules/protocol/mysql_backend.c +++ b/server/modules/protocol/mysql_backend.c @@ -1184,48 +1184,38 @@ static int gw_write_backend_event(DCB *dcb) */ if (dcb->state != DCB_STATE_POLLING) { - uint8_t* data; + uint8_t* data = NULL; + bool com_quit = false; - if (dcb->writeq != NULL) + spinlock_acquire(&dcb->writeqlock); + if (dcb->writeq) { data = (uint8_t *) GWBUF_DATA(dcb->writeq); + com_quit = MYSQL_IS_COM_QUIT(data); + rc = 0; + } + spinlock_release(&dcb->writeqlock); - if (dcb->session->client_dcb == NULL) - { - rc = 0; - } - else if (!(MYSQL_IS_COM_QUIT(data))) - { - /*< vraa : errorHandle */ - mysql_send_custom_error(dcb->session->client_dcb, - 1, - 0, - "Writing to backend failed due invalid Maxscale " - "state."); - MXS_DEBUG("%lu [gw_write_backend_event] Write to backend " - "dcb %p fd %d " - "failed due invalid state %s.", - pthread_self(), - dcb, - dcb->fd, - STRDCBSTATE(dcb->state)); - MXS_ERROR("Attempt to write buffered data to backend " - "failed " - "due internal inconsistent state."); + if (data && !com_quit) + { + mysql_send_custom_error(dcb->session->client_dcb, 1, 0, + "Writing to backend failed due invalid Maxscale state."); + MXS_DEBUG("%lu [gw_write_backend_event] Write to backend " + "dcb %p fd %d failed due invalid state %s.", + pthread_self(), dcb, dcb->fd, STRDCBSTATE(dcb->state)); - rc = 0; - } + MXS_ERROR("Attempt to write buffered data to backend " + "failed due internal inconsistent state."); } else { MXS_DEBUG("%lu [gw_write_backend_event] Dcb %p in state %s " - "but there's nothing to write either.", - pthread_self(), - dcb, - STRDCBSTATE(dcb->state)); + "but there's nothing to write either.", + pthread_self(), dcb, STRDCBSTATE(dcb->state)); rc = 1; } + goto return_rc; } From 7fc7249349623d2c63176a84726afe7bdcc7c73e Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Thu, 15 Sep 2016 21:28:29 +0300 Subject: [PATCH 06/21] Update installation instructions --- .../MariaDB-MaxScale-Installation-Guide.md | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/Documentation/Getting-Started/MariaDB-MaxScale-Installation-Guide.md b/Documentation/Getting-Started/MariaDB-MaxScale-Installation-Guide.md index 75f1412ae..3a1ad5c20 100644 --- a/Documentation/Getting-Started/MariaDB-MaxScale-Installation-Guide.md +++ b/Documentation/Getting-Started/MariaDB-MaxScale-Installation-Guide.md @@ -6,21 +6,33 @@ In this introduction to MariaDB MaxScale the aim is to take the reader from the ## Installation -The simplest way to install MariaDB MaxScale is to use one of the binary packages that are available for download from the MariaDB website. +MariaDB MaxScale can be installed either using the MariaDB Enterprise Repository or directly from a downloaded package. -* Simply go to [http://www.mariadb.com/my_portal/download](http://www.mariadb.com/my_portal/download) +### Using the MariaDB Enterprise Repository -* Sign in to MariaDB.com +* Go to [https://mariadb.com/my_portal/download](https://mariadb.com/my_portal/download). -* Follow the instructions at the top of the page. +* Sign in or create an account for you. -![image alt text](images/getting_started.png) +* Select your operating system and follow the instructions. -If you want to install only MariaDB MaxScale, further down you will find the product specific download pages. Click on the MariaDB MaxScale link and follow the distribution specific instructions. +### From a Downloaded Package -![image alt text](images/getting_started2.png) +The MaxScale package can be downloaded from the following locations: -After you have installed MariaDB MaxScale, you can start it. +* [https://mariadb.com/my_portal/download/maxscale](https://mariadb.com/my_portal/download/maxscale) + +* [https://mariadb.com/downloads/maxscale](https://mariadb.com/downloads/maxscale) + +Select your operating system and download the package. + +Once you have downloaded the package, install it using the package tool relevant for your operating system. + +### Starting MariaDB MaxScale + +Before starting MariaDB MaxScale, you need to create a configuration file for it; please see further [down](#configuring-mariadb-maxscale). + +Once a configuration file has been created you can start MariaDB MaxScale: ``` systemctl start maxscale.service From 92ef33327edbd95f3908850f31ed777ce225b429 Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Mon, 19 Sep 2016 05:34:03 +0300 Subject: [PATCH 07/21] MXS-870: Handle non-contiguous session command responses Session command responses with multiple packets could be spread across multiple, non-contiguous buffers. If a buffer contained a complete packet and some extra data but it wasn't contiguous, the debug assertion in gwbuf_clone_portion would fail. With release builds, it would cause eventual out-of-bounds memory access when the response would be sent to the client. --- server/core/buffer.c | 6 +++--- server/core/test/testbuffer.c | 9 --------- server/include/buffer.h | 1 - server/modules/protocol/mysql_backend.c | 23 +++++++++-------------- 4 files changed, 12 insertions(+), 27 deletions(-) diff --git a/server/core/buffer.c b/server/core/buffer.c index ce4b794b9..b2dfa4c72 100644 --- a/server/core/buffer.c +++ b/server/core/buffer.c @@ -384,9 +384,9 @@ GWBUF* gwbuf_clone_all(GWBUF* buf) } -GWBUF *gwbuf_clone_portion(GWBUF *buf, - size_t start_offset, - size_t length) +static GWBUF *gwbuf_clone_portion(GWBUF *buf, + size_t start_offset, + size_t length) { GWBUF* clonebuf; diff --git a/server/core/test/testbuffer.c b/server/core/test/testbuffer.c index 8ec09d6d3..ad26f0a5d 100644 --- a/server/core/test/testbuffer.c +++ b/server/core/test/testbuffer.c @@ -375,15 +375,6 @@ test1() gwbuf_free(clone); ss_dfprintf(stderr, "Freed cloned buffer"); ss_dfprintf(stderr, "\t..done\n"); - partclone = gwbuf_clone_portion(buffer, 25, 50); - buflen = GWBUF_LENGTH(partclone); - ss_dfprintf(stderr, "Part cloned buffer length is now %d", buflen); - ss_info_dassert(50 == buflen, "Incorrect buffer size"); - ss_info_dassert(0 == GWBUF_EMPTY(partclone), "Part cloned buffer should not be empty"); - ss_dfprintf(stderr, "\t..done\n"); - gwbuf_free(partclone); - ss_dfprintf(stderr, "Freed part cloned buffer"); - ss_dfprintf(stderr, "\t..done\n"); buffer = gwbuf_consume(buffer, bite1); ss_info_dassert(NULL != buffer, "Buffer should not be null"); buflen = GWBUF_LENGTH(buffer); diff --git a/server/include/buffer.h b/server/include/buffer.h index 42d0aa016..2a55f4963 100644 --- a/server/include/buffer.h +++ b/server/include/buffer.h @@ -194,7 +194,6 @@ extern unsigned int gwbuf_length(GWBUF *head); extern int gwbuf_count(GWBUF *head); extern size_t gwbuf_copy_data(GWBUF *buffer, size_t offset, size_t bytes, uint8_t* dest); -extern GWBUF *gwbuf_clone_portion(GWBUF *head, size_t offset, size_t len); extern GWBUF *gwbuf_split(GWBUF **buf, size_t length); extern GWBUF *gwbuf_clone_transform(GWBUF *head, gwbuf_type_t type); extern GWBUF *gwbuf_clone_all(GWBUF* head); diff --git a/server/modules/protocol/mysql_backend.c b/server/modules/protocol/mysql_backend.c index 5addc27b8..2a9bbbb7d 100644 --- a/server/modules/protocol/mysql_backend.c +++ b/server/modules/protocol/mysql_backend.c @@ -2011,22 +2011,17 @@ static GWBUF* process_response_data(DCB* dcb, outbuf = gwbuf_append(outbuf, readbuf); readbuf = NULL; } - /** - * Packet was read. There should be more since bytes were - * left over. - * Move the next packet to its own buffer and add that next - * to the prev packet's buffer. - */ - else /*< nbytes_left < nbytes_to_process */ + /** + * Buffer contains more data than we need. Split the complete packet and + * the extra data into two separate buffers. + */ + else { - ss_dassert(nbytes_left >= 0); - nbytes_to_process -= nbytes_left; - - /** Move the prefix of the buffer to outbuf from redbuf */ - outbuf = gwbuf_append(outbuf, - gwbuf_clone_portion(readbuf, 0, (size_t) nbytes_left)); - readbuf = gwbuf_consume(readbuf, (size_t) nbytes_left); + ss_dassert(nbytes_left < nbytes_to_process); + ss_dassert(nbytes_left > 0); ss_dassert(npackets_left > 0); + outbuf = gwbuf_append(outbuf, gwbuf_split(&readbuf, nbytes_left)); + nbytes_to_process -= nbytes_left; npackets_left -= 1; nbytes_left = 0; } From e4543881d231cd93fc09e7b1cd081715636fa098 Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Tue, 20 Sep 2016 09:53:27 +0300 Subject: [PATCH 08/21] Add instructions for installing a package --- .../MariaDB-MaxScale-Installation-Guide.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Documentation/Getting-Started/MariaDB-MaxScale-Installation-Guide.md b/Documentation/Getting-Started/MariaDB-MaxScale-Installation-Guide.md index 3a1ad5c20..a8e0f7bd2 100644 --- a/Documentation/Getting-Started/MariaDB-MaxScale-Installation-Guide.md +++ b/Documentation/Getting-Started/MariaDB-MaxScale-Installation-Guide.md @@ -26,7 +26,17 @@ The MaxScale package can be downloaded from the following locations: Select your operating system and download the package. -Once you have downloaded the package, install it using the package tool relevant for your operating system. +Depending on your OS, the package will either be a _deb_ or an _rpm_. + +An _rpm_ is installed as follows +``` +$ sudo yum install path-to-maxscale-package.rpm +``` +and a _deb_ as follows +``` +$ sudo dpkg -i path-to-maxscale-package.deb +$ sudo apt-get install -f +``` ### Starting MariaDB MaxScale From b1b2e5b770fd24a77160e91a07bfb306e065e0f0 Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Tue, 20 Sep 2016 11:17:37 +0300 Subject: [PATCH 09/21] Don't free the shared shard maps When client sessions are closed, the shared shard maps should not be freed. --- server/modules/routing/schemarouter/schemarouter.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/server/modules/routing/schemarouter/schemarouter.c b/server/modules/routing/schemarouter/schemarouter.c index 16b867ae2..29f17d5c3 100644 --- a/server/modules/routing/schemarouter/schemarouter.c +++ b/server/modules/routing/schemarouter/schemarouter.c @@ -1381,11 +1381,6 @@ static void freeSession(ROUTER* router_instance, void* router_client_session) * all the memory and other resources associated * to the client session. */ - if (router_cli_ses->shardmap) - { - hashtable_free(router_cli_ses->shardmap->hash); - free(router_cli_ses->shardmap); - } free(router_cli_ses->rses_backend_ref); free(router_cli_ses); return; From 9a9511fc5868e2467a183fb2aca0307ea0b928d2 Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Tue, 20 Sep 2016 10:53:51 +0300 Subject: [PATCH 10/21] Update tarball instructions --- .../Install-MariaDB-MaxScale-Using-a-Tarball.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Documentation/Getting-Started/Install-MariaDB-MaxScale-Using-a-Tarball.md b/Documentation/Getting-Started/Install-MariaDB-MaxScale-Using-a-Tarball.md index d9ceb1854..5aca16d0b 100644 --- a/Documentation/Getting-Started/Install-MariaDB-MaxScale-Using-a-Tarball.md +++ b/Documentation/Getting-Started/Install-MariaDB-MaxScale-Using-a-Tarball.md @@ -1,6 +1,6 @@ # Installing MariaDB MaxScale using a tarball -MariaDB MaxScale is also made available as a tarball, which is named like `maxscale-X.Y.X.tar.gz` where `X.Y.Z` is the same as the corresponding version, e.g. `maxscale-2.0.1.tar.gz`. +MariaDB MaxScale is also made available as a tarball, which is named like `maxscale-x.y.z.OS.tar.gz` where `x.y.z` is the same as the corresponding version and `OS` identifies the operating system, e.g. `maxscale-2.0.1.centos.7.tar.gz`. The tarball has been built with the assumption that it will be installed in `/usr/local`. However, it is possible to install it in any directory, but in that case MariaDB MaxScale must be invoked with a flag. @@ -13,8 +13,8 @@ The required steps are as follows: $ sudo groupadd maxscale $ sudo useradd -g maxscale maxscale $ cd /usr/local - $ sudo tar -xzvf maxscale-X.Y.Z.tar.gz - $ sudo ln -s maxscale-X.Y.Z maxscale + $ sudo tar -xzvf maxscale-x.y.z.OS.tar.gz + $ sudo ln -s maxscale-x.y.z.OS.maxscale $ cd maxscale $ chown -R maxscale var @@ -34,13 +34,13 @@ If you want to place the configuration file somewhere else but in `/etc` you can Enter a directory where you have the right to create a subdirectory. Then do as follows. - $ tar -xzvf maxscale-X.Y.Z.tar.gz + $ tar -xzvf maxscale-x.y.z.OS.tar.gz -The next step is to create the MaxScale configuration file `maxscale-X.Y.Z/etc/maxscale.cnf`. The file `maxscale-X.Y.Z/etc/maxscale.cnf.template` can be used as a base. Please refer to [Configuration Guide](Configuration-Guide.md) for details. +The next step is to create the MaxScale configuration file `maxscale-x.y.z/etc/maxscale.cnf`. The file `maxscale-x.y.z/etc/maxscale.cnf.template` can be used as a base. Please refer to [Configuration Guide](Configuration-Guide.md) for details. When the configuration file has been created, MariaDB MaxScale can be started. - $ cd maxscale-X.Y.Z + $ cd maxscale-x.y.z $ LD_LIBRARY_PATH=lib/maxscale bin/maxscale -d --basedir=. With the flag `--basedir`, MariaDB MaxScale is told where the `bin`, `etc`, `lib` From 6ec999851ff3e3756fb81a473f2a37ababc8c2ad Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Tue, 20 Sep 2016 12:58:05 +0300 Subject: [PATCH 11/21] Update 2.0.1 release notes --- .../Release-Notes/MaxScale-2.0.1-Release-Notes.md | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Documentation/Release-Notes/MaxScale-2.0.1-Release-Notes.md b/Documentation/Release-Notes/MaxScale-2.0.1-Release-Notes.md index 195bacf53..509cffad5 100644 --- a/Documentation/Release-Notes/MaxScale-2.0.1-Release-Notes.md +++ b/Documentation/Release-Notes/MaxScale-2.0.1-Release-Notes.md @@ -113,14 +113,17 @@ Please consult ## Bug fixes -[Here is a list of bugs fixed since the release of MaxScale 2.0.1.](https://jira.mariadb.org/issues/?jql=project%20%3D%20MXS%20AND%20issuetype%20%3D%20Bug%20AND%20status%20%3D%20Closed%20AND%20fixVersion%20in%20(2.0.0%2C%202.0.1)%20AND%20resolved%20%3E%3D%20-21d%20ORDER%20BY%20priority%20DESC%2C%20updated%20DESC) +[Here is a list of bugs fixed since the release of MaxScale 2.0.0.](https://jira.mariadb.org/browse/MXS-860?jql=project%20%3D%20MXS%20AND%20issuetype%20%3D%20Bug%20AND%20status%20%3D%20Closed%20AND%20fixVersion%20in%20(2.0.1)%20AND%20resolved%20%3E%3D%20-21d%20AND%20(resolution%20%3D%20Done%20OR%20resolution%20%3D%20Fixed)%20ORDER%20BY%20priority%20DESC) -* [MXS-812](https://jira.mariadb.org/browse/MXS-812): Number of conns not matching number of operations -* [MXS-847](https://jira.mariadb.org/browse/MXS-847): server_down event is executed 8 times due to putting sever into maintenance mode +* [MXS-860](https://jira.mariadb.org/browse/MXS-860): I want to access the web site if master server is down +* [MXS-870](https://jira.mariadb.org/browse/MXS-870): Assertion of Buffer Overflow * [MXS-845](https://jira.mariadb.org/browse/MXS-845): "Server down" event is re-triggered after maintenance mode is repeated -* [MXS-842](https://jira.mariadb.org/browse/MXS-842): Unexpected / undocumented behaviour when multiple available masters from mmmon monitor -* [MXS-846](https://jira.mariadb.org/browse/MXS-846): MMMon: Maintenance mode on slave logs error message every second -* [MXS-860](https://jira.mariadb.org/browse/MXS-860): I want to access the web site if master server is down. +* [MXS-836](https://jira.mariadb.org/browse/MXS-836): "Failed to start all MaxScale services" without retrying +* [MXS-835](https://jira.mariadb.org/browse/MXS-835): Please reinstate remote access to maxscaled protocol +* [MXS-773](https://jira.mariadb.org/browse/MXS-773): 100% CPU on idle MaxScale with MaxInfo +* [MXS-812](https://jira.mariadb.org/browse/MXS-812): Number of conns not matching number of operations +* [MXS-856](https://jira.mariadb.org/browse/MXS-856): If config file cannot be accessed and creation of log file fails, MaxScale crashes with SIGSEGV +* [MXS-829](https://jira.mariadb.org/browse/MXS-829): When the config file isn't readable or doesn't exist, maxscale silently ends ## Known Issues and Limitations From 0f6d4e4cdb6e867f43f7579935dd1268f600afaf Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Tue, 20 Sep 2016 13:58:28 +0300 Subject: [PATCH 12/21] Fix typo in tarball documentation --- .../Getting-Started/Install-MariaDB-MaxScale-Using-a-Tarball.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/Getting-Started/Install-MariaDB-MaxScale-Using-a-Tarball.md b/Documentation/Getting-Started/Install-MariaDB-MaxScale-Using-a-Tarball.md index 5aca16d0b..6dd5cd3c8 100644 --- a/Documentation/Getting-Started/Install-MariaDB-MaxScale-Using-a-Tarball.md +++ b/Documentation/Getting-Started/Install-MariaDB-MaxScale-Using-a-Tarball.md @@ -14,7 +14,7 @@ The required steps are as follows: $ sudo useradd -g maxscale maxscale $ cd /usr/local $ sudo tar -xzvf maxscale-x.y.z.OS.tar.gz - $ sudo ln -s maxscale-x.y.z.OS.maxscale + $ sudo ln -s maxscale-x.y.z maxscale $ cd maxscale $ chown -R maxscale var From dfec3c8552b67b31e413bd45298c0897661db8b3 Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Tue, 20 Sep 2016 13:58:30 +0300 Subject: [PATCH 13/21] Install maxbinlogcheck in the right place Maxbinlogcheck was installed in the wrong place. --- server/modules/routing/binlog/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/modules/routing/binlog/CMakeLists.txt b/server/modules/routing/binlog/CMakeLists.txt index 8b9298b22..780a7a564 100644 --- a/server/modules/routing/binlog/CMakeLists.txt +++ b/server/modules/routing/binlog/CMakeLists.txt @@ -7,7 +7,7 @@ install(TARGETS binlogrouter DESTINATION ${MAXSCALE_LIBDIR}) add_executable(maxbinlogcheck maxbinlogcheck.c blr_file.c blr_cache.c blr_master.c blr_slave.c blr.c) target_link_libraries(maxbinlogcheck maxscale-common ${PCRE_LINK_FLAGS} uuid) -install(TARGETS maxbinlogcheck DESTINATION bin) +install(TARGETS maxbinlogcheck DESTINATION ${MAXSCALE_BINDIR}) if(BUILD_TESTS) add_subdirectory(test) From 1331bf9ae817f21430a417b87b0e999f5b955579 Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Tue, 20 Sep 2016 14:11:50 +0300 Subject: [PATCH 14/21] Add CPACK_PACKAGE_FILE_NAME to CMake cache Adding CPACK_PACKAGE_FILE_NAME to the CMake cache allows the user to control it. With this, custom tarball names can be easily generated. --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6da4daeea..ea6506d7e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -265,9 +265,9 @@ if(PACKAGE) set(CPACK_PACKAGE_VERSION_PATCH "${MAXSCALE_VERSION_PATCH}") set(CPACK_PACKAGE_CONTACT "MariaDB Corporation Ab") if(DISTRIB_SUFFIX) - set(CPACK_PACKAGE_FILE_NAME "maxscale-${MAXSCALE_VERSION}-${MAXSCALE_BUILD_NUMBER}.${DISTRIB_SUFFIX}.${CPACK_PACKAGE_ARCHITECTURE}") + set(CPACK_PACKAGE_FILE_NAME "maxscale-${MAXSCALE_VERSION}-${MAXSCALE_BUILD_NUMBER}.${DISTRIB_SUFFIX}.${CPACK_PACKAGE_ARCHITECTURE}" CACHE STRING "MaxScale package filename") else() - set(CPACK_PACKAGE_FILE_NAME "maxscale-${MAXSCALE_VERSION}-${MAXSCALE_BUILD_NUMBER}.${CPACK_PACKAGE_ARCHITECTURE}") + set(CPACK_PACKAGE_FILE_NAME "maxscale-${MAXSCALE_VERSION}-${MAXSCALE_BUILD_NUMBER}.${CPACK_PACKAGE_ARCHITECTURE}" CACHE STRING "MaxScale package filename") endif() set(CPACK_PACKAGE_NAME "maxscale") set(CPACK_PACKAGE_VENDOR "MariaDB Corporation Ab") From 715f978051d8452edbfa3edc57add45d76364f35 Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Tue, 20 Sep 2016 14:36:16 +0300 Subject: [PATCH 15/21] Add TARBALL variable to CMake The TARBALL variable controls if a special tar.gz package is built when packages are generated. This package has a different directory structure compared to the RPM/DEB packages. If RPM/DEB packages are built, tar.gz packages are not built. This makes RPM/DEB generation faster and allows tarballs to be built separately with a proper directory structures. --- CMakeLists.txt | 102 ++++++++++-------- .../Building-MaxScale-from-Source-Code.md | 6 +- cmake/package_tgz.cmake | 19 ++++ 3 files changed, 80 insertions(+), 47 deletions(-) create mode 100644 cmake/package_tgz.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index ea6506d7e..148b915ce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -98,6 +98,61 @@ endif() set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${CMAKE_INSTALL_PREFIX}/${MAXSCALE_LIBDIR}) +# Only do packaging if configured +if(PACKAGE) + + execute_process(COMMAND uname -m COMMAND tr -d '\n' OUTPUT_VARIABLE CPACK_PACKAGE_ARCHITECTURE) + # Install the files copied by the postinst script into the share folder + install(PROGRAMS ${CMAKE_BINARY_DIR}/maxscale DESTINATION ${MAXSCALE_SHAREDIR}) + install(FILES ${CMAKE_BINARY_DIR}/maxscale.conf DESTINATION ${MAXSCALE_SHAREDIR}) + install(PROGRAMS ${CMAKE_BINARY_DIR}/postinst DESTINATION ${MAXSCALE_SHAREDIR}) + install(PROGRAMS ${CMAKE_BINARY_DIR}/postrm DESTINATION ${MAXSCALE_SHAREDIR}) + if(${CMAKE_VERSION} VERSION_LESS 2.8.12) + message(WARNING "CMake version is ${CMAKE_VERSION}. Building of packages requires version 2.8.12 or greater.") + else() + + # Generic CPack configuration variables + SET(CPACK_SET_DESTDIR ON) + set(CPACK_STRIP_FILES FALSE) + set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "MaxScale") + set(CPACK_PACKAGE_VERSION_MAJOR "${MAXSCALE_VERSION_MAJOR}") + set(CPACK_PACKAGE_VERSION_MINOR "${MAXSCALE_VERSION_MINOR}") + set(CPACK_PACKAGE_VERSION_PATCH "${MAXSCALE_VERSION_PATCH}") + set(CPACK_PACKAGE_CONTACT "MariaDB Corporation Ab") + if(DISTRIB_SUFFIX) + set(CPACK_PACKAGE_FILE_NAME "maxscale-${MAXSCALE_VERSION}-${MAXSCALE_BUILD_NUMBER}.${DISTRIB_SUFFIX}.${CPACK_PACKAGE_ARCHITECTURE}" CACHE STRING "MaxScale package filename") + else() + set(CPACK_PACKAGE_FILE_NAME "maxscale-${MAXSCALE_VERSION}-${MAXSCALE_BUILD_NUMBER}.${CPACK_PACKAGE_ARCHITECTURE}" CACHE STRING "MaxScale package filename") + endif() + set(CPACK_PACKAGE_NAME "maxscale") + set(CPACK_PACKAGE_VENDOR "MariaDB Corporation Ab") + set(CPACK_PACKAGE_DESCRIPTION_FILE ${CMAKE_SOURCE_DIR}/etc/DESCRIPTION) + set(CPACK_PACKAGING_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}") + + # See if we are on a RPM-capable or DEB-capable system + find_program(RPMBUILD rpmbuild) + find_program(DEBBUILD dpkg-buildpackage) + + if(TARBALL) + include(cmake/package_tgz.cmake) + + elseif (NOT ( ${RPMBUILD} STREQUAL "RPMBUILD-NOTFOUND" ) OR NOT ( ${DEBBUILD} STREQUAL "DEBBUILD-NOTFOUND" )) + if(NOT ( ${RPMBUILD} STREQUAL "RPMBUILD-NOTFOUND" ) ) + include(cmake/package_rpm.cmake) + message(STATUS "Generating RPM packages") + endif() + if(NOT ( ${DEBBUILD} STREQUAL "DEBBUILD-NOTFOUND" ) ) + include(cmake/package_deb.cmake) + message(STATUS "Generating DEB packages for ${DEB_ARCHITECTURE}") + endif() + else() + message(FATAL_ERROR "Could not automatically resolve the package generator and no generators " + "defined on the command line. Please install distribution specific packaging software or " + "define -DTARBALL=Y to build tar.gz packages.") + endif() + endif() +endif() + # Make sure the release notes for this release are present if it is a stable one if(${MAXSCALE_VERSION} MATCHES "-stable") file(GLOB ${CMAKE_SOURCE_DIR}/Documentation/Release-Notes RELEASE_NOTES *${MAXSCALE_VERSION_NUMERIC}*.md) @@ -243,53 +298,8 @@ if(WITH_SCRIPTS) endif() endif() -# Only do packaging if configured if(PACKAGE) - - execute_process(COMMAND uname -m COMMAND tr -d '\n' OUTPUT_VARIABLE CPACK_PACKAGE_ARCHITECTURE) - # Install the files copied by the postinst script into the share folder - install(PROGRAMS ${CMAKE_BINARY_DIR}/maxscale DESTINATION ${MAXSCALE_SHAREDIR}) - install(FILES ${CMAKE_BINARY_DIR}/maxscale.conf DESTINATION ${MAXSCALE_SHAREDIR}) - install(PROGRAMS ${CMAKE_BINARY_DIR}/postinst DESTINATION ${MAXSCALE_SHAREDIR}) - install(PROGRAMS ${CMAKE_BINARY_DIR}/postrm DESTINATION ${MAXSCALE_SHAREDIR}) - if(${CMAKE_VERSION} VERSION_LESS 2.8.12) - message(WARNING "CMake version is ${CMAKE_VERSION}. Building of packages requires version 2.8.12 or greater.") - else() - - # Generic CPack configuration variables - SET(CPACK_SET_DESTDIR ON) - set(CPACK_STRIP_FILES FALSE) - set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "MaxScale") - set(CPACK_PACKAGE_VERSION_MAJOR "${MAXSCALE_VERSION_MAJOR}") - set(CPACK_PACKAGE_VERSION_MINOR "${MAXSCALE_VERSION_MINOR}") - set(CPACK_PACKAGE_VERSION_PATCH "${MAXSCALE_VERSION_PATCH}") - set(CPACK_PACKAGE_CONTACT "MariaDB Corporation Ab") - if(DISTRIB_SUFFIX) - set(CPACK_PACKAGE_FILE_NAME "maxscale-${MAXSCALE_VERSION}-${MAXSCALE_BUILD_NUMBER}.${DISTRIB_SUFFIX}.${CPACK_PACKAGE_ARCHITECTURE}" CACHE STRING "MaxScale package filename") - else() - set(CPACK_PACKAGE_FILE_NAME "maxscale-${MAXSCALE_VERSION}-${MAXSCALE_BUILD_NUMBER}.${CPACK_PACKAGE_ARCHITECTURE}" CACHE STRING "MaxScale package filename") - endif() - set(CPACK_PACKAGE_NAME "maxscale") - set(CPACK_PACKAGE_VENDOR "MariaDB Corporation Ab") - set(CPACK_PACKAGE_DESCRIPTION_FILE ${CMAKE_SOURCE_DIR}/etc/DESCRIPTION) - set(CPACK_PACKAGING_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}") - - # See if we are on a RPM-capable or DEB-capable system - find_program(RPMBUILD rpmbuild) - find_program(DEBBUILD dpkg-buildpackage) - set(CPACK_GENERATOR "TGZ") - - if(NOT ( ${RPMBUILD} STREQUAL "RPMBUILD-NOTFOUND" ) ) - include(cmake/package_rpm.cmake) - message(STATUS "Generating RPM packages") - endif() - if(NOT ( ${DEBBUILD} STREQUAL "DEBBUILD-NOTFOUND" ) ) - include(cmake/package_deb.cmake) - message(STATUS "Generating DEB packages for ${DEB_ARCHITECTURE}") - endif() - - include(CPack) - endif() + include(CPack) endif() # uninstall target diff --git a/Documentation/Getting-Started/Building-MaxScale-from-Source-Code.md b/Documentation/Getting-Started/Building-MaxScale-from-Source-Code.md index c2a9a409e..afd1da429 100644 --- a/Documentation/Getting-Started/Building-MaxScale-from-Source-Code.md +++ b/Documentation/Getting-Started/Building-MaxScale-from-Source-Code.md @@ -87,6 +87,7 @@ _NAME_=_VALUE_ format (e.g. `-DBUILD_TESTS=Y`). |BUILD_TESTS|Build tests| |WITH_SCRIPTS|Install systemd and init.d scripts| |PACKAGE|Enable building of packages| +|TARBALL|Build tar.gz packages, requires PACKAGE=Y| **Note**: You can look into [defaults.cmake](../../cmake/defaults.cmake) for a list of the CMake variables. @@ -152,7 +153,10 @@ make test make package ``` -This will create a tarball and a RPM/DEB package. +This will create a RPM/DEB package. + +To build a tarball, add `-DTARBALL=Y` to the cmake invokation. This will create +a _maxscale-x.y.z.tar.gz_ file where _x.y.z_ is the version number. Some Debian and Ubuntu systems suffer from a bug where `make package` fails with errors from dpkg-shlibdeps. This can be fixed by running `make` before diff --git a/cmake/package_tgz.cmake b/cmake/package_tgz.cmake new file mode 100644 index 000000000..f99417748 --- /dev/null +++ b/cmake/package_tgz.cmake @@ -0,0 +1,19 @@ +# Tarball package configuration +message(STATUS "Generating tar.gz packages") +set(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE) +set(MAXSCALE_BINDIR /bin CACHE PATH "" FORCE) +set(MAXSCALE_LIBDIR /lib CACHE PATH "" FORCE) +set(MAXSCALE_SHAREDIR /share CACHE PATH "" FORCE) +set(MAXSCALE_DOCDIR /share CACHE PATH "" FORCE) +set(MAXSCALE_VARDIR /var CACHE PATH "" FORCE) +set(MAXSCALE_CONFDIR /etc CACHE PATH "" FORCE) +set(CMAKE_INSTALL_PREFIX "/" CACHE PATH "" FORCE) +set(CMAKE_INSTALL_RPATH "$ORIGIN/../lib" CACHE PATH "" FORCE) +set(CMAKE_INSTALL_DATADIR /share CACHE PATH "" FORCE) +set(CPACK_GENERATOR "TGZ") + +if(DISTRIB_SUFFIX) + set(CPACK_PACKAGE_FILE_NAME "maxscale-${MAXSCALE_VERSION}.${DISTRIB_SUFFIX}") +else() + set(CPACK_PACKAGE_FILE_NAME "maxscale-${MAXSCALE_VERSION}") +endif() From ba2cafc65ec6120481b41bb62dae68c8c7edee91 Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Tue, 20 Sep 2016 16:13:34 +0300 Subject: [PATCH 16/21] Update tarball instructions --- .../Install-MariaDB-MaxScale-Using-a-Tarball.md | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/Documentation/Getting-Started/Install-MariaDB-MaxScale-Using-a-Tarball.md b/Documentation/Getting-Started/Install-MariaDB-MaxScale-Using-a-Tarball.md index 6dd5cd3c8..ac2682979 100644 --- a/Documentation/Getting-Started/Install-MariaDB-MaxScale-Using-a-Tarball.md +++ b/Documentation/Getting-Started/Install-MariaDB-MaxScale-Using-a-Tarball.md @@ -18,7 +18,9 @@ The required steps are as follows: $ cd maxscale $ chown -R maxscale var -Creating the symbolic link is necessary, since MariaDB MaxScale has been built with with the assumption that its base-directory is `/usr/local/maxscale`. It also makes it easy to switch between different versions of MariaDB MaxScale that have been installed side by side in `/usr/local`; just make the symbolic link point to another installation. +Creating the symbolic link is necessary, since MariaDB MaxScale has been built with with the assumption that its base-directory, that is, the directory under which all its sub-directories are found, is `/usr/local/maxscale`. + +The symbolic link also makes it easy to switch between different versions of MariaDB MaxScale that have been installed side by side in `/usr/local`; just make the symbolic link point to another installation. The following step is to create the MariaDB MaxScale configuration file `/etc/maxscale.cnf`. The file `etc/maxscale.cnf.template` can be used as a base. Please refer to [Configuration Guide](Configuration-Guide.md) for details. @@ -41,16 +43,12 @@ The next step is to create the MaxScale configuration file `maxscale-x.y.z/etc/m When the configuration file has been created, MariaDB MaxScale can be started. $ cd maxscale-x.y.z - $ LD_LIBRARY_PATH=lib/maxscale bin/maxscale -d --basedir=. + $ bin/maxscale -d --basedir=. -With the flag `--basedir`, MariaDB MaxScale is told where the `bin`, `etc`, `lib` -and `var` directories are found. Unless it is specified, MariaDB MaxScale assumes -the directories are found in `/usr/local/maxscale` and the configuration -file in `/etc`. +With the flag `--basedir`, MariaDB MaxScale is told where the `bin`, `etc`, `lib` and `var` directories are found. Unless it is specified, MariaDB MaxScale assumes the directories are found in `/usr/local/maxscale` and the configuration file in `/etc`. -It is also possible to specify the directories and the location of the -configuration file individually. Invoke MaxScale like +It is also possible to specify the directories and the location of the configuration file individually. Invoke MaxScale like - $ LD_LIBRARY_PATH=lib/maxscale bin/maxscale --help + $ bin/maxscale --help to find out the appropriate flags. From f6888ef2056478b5a38f2f54eae72d3c8a5ac381 Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Wed, 21 Sep 2016 09:40:15 +0300 Subject: [PATCH 17/21] Install all /var directories The /var/lib/maxscale directory wasn't installed and tarballs didn't have any /var directories. --- CMakeLists.txt | 3 ++- cmake/package_tgz.cmake | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 148b915ce..b37d03670 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -370,8 +370,9 @@ endif() # NOTE: If you make changes here, ensure they are compatible with the # situation in gwdirs.h.in. -if (NOT CMAKE_INSTALL_PREFIX EQUAL "/usr") +if (NOT PACKAGE) install(DIRECTORY DESTINATION var/cache/maxscale) install(DIRECTORY DESTINATION var/log/maxscale) install(DIRECTORY DESTINATION var/run/maxscale) + install(DIRECTORY DESTINATION var/lib/maxscale) endif() diff --git a/cmake/package_tgz.cmake b/cmake/package_tgz.cmake index f99417748..d96756502 100644 --- a/cmake/package_tgz.cmake +++ b/cmake/package_tgz.cmake @@ -12,6 +12,12 @@ set(CMAKE_INSTALL_RPATH "$ORIGIN/../lib" CACHE PATH "" FORCE) set(CMAKE_INSTALL_DATADIR /share CACHE PATH "" FORCE) set(CPACK_GENERATOR "TGZ") +# Include the var directories in the tarball +install(DIRECTORY DESTINATION var/cache/maxscale) +install(DIRECTORY DESTINATION var/log/maxscale) +install(DIRECTORY DESTINATION var/run/maxscale) +install(DIRECTORY DESTINATION var/lib/maxscale) + if(DISTRIB_SUFFIX) set(CPACK_PACKAGE_FILE_NAME "maxscale-${MAXSCALE_VERSION}.${DISTRIB_SUFFIX}") else() From bd60fbde7ecf6b002f8702538c07af0d89a1a529 Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Wed, 21 Sep 2016 10:53:08 +0300 Subject: [PATCH 18/21] Create dummy files in /var directories for tar.gz packages These files allow seemingly empty directories to be installed on various platforms. Some platforms had problems installing empty directories. --- cmake/package_tgz.cmake | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/cmake/package_tgz.cmake b/cmake/package_tgz.cmake index d96756502..06ccf201e 100644 --- a/cmake/package_tgz.cmake +++ b/cmake/package_tgz.cmake @@ -13,10 +13,15 @@ set(CMAKE_INSTALL_DATADIR /share CACHE PATH "" FORCE) set(CPACK_GENERATOR "TGZ") # Include the var directories in the tarball -install(DIRECTORY DESTINATION var/cache/maxscale) -install(DIRECTORY DESTINATION var/log/maxscale) -install(DIRECTORY DESTINATION var/run/maxscale) -install(DIRECTORY DESTINATION var/lib/maxscale) +# +# On some platforms with certain CMake versions, installing empty directories +# with tarballs does not work. As a workaround, the .cmake-tgz-workaround file +# is installed into the would-be empty directories. +file(WRITE ${CMAKE_BINARY_DIR}/.cmake-tgz-workaround "") +install(FILES ${CMAKE_BINARY_DIR}/.cmake-tgz-workaround DESTINATION var/cache/maxscale) +install(FILES ${CMAKE_BINARY_DIR}/.cmake-tgz-workaround DESTINATION var/log/maxscale) +install(FILES ${CMAKE_BINARY_DIR}/.cmake-tgz-workaround DESTINATION var/run/maxscale) +install(FILES ${CMAKE_BINARY_DIR}/.cmake-tgz-workaround DESTINATION var/lib/maxscale) if(DISTRIB_SUFFIX) set(CPACK_PACKAGE_FILE_NAME "maxscale-${MAXSCALE_VERSION}.${DISTRIB_SUFFIX}") From 578f21e757d68806d1812a25bdc81c8ccc6c20d9 Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Wed, 21 Sep 2016 10:08:19 +0300 Subject: [PATCH 19/21] MXS-874: Clear closed state before reconnecting to a server The backend reference states should be cleared when a reconnection attempt is made. Should the creation of a new DCB succeed, the backend should no longer be closed. --- server/modules/routing/readwritesplit/readwritesplit.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/server/modules/routing/readwritesplit/readwritesplit.c b/server/modules/routing/readwritesplit/readwritesplit.c index 07b768e8b..ac5a8781d 100644 --- a/server/modules/routing/readwritesplit/readwritesplit.c +++ b/server/modules/routing/readwritesplit/readwritesplit.c @@ -2889,6 +2889,8 @@ bool connect_server(backend_ref_t *bref, SESSION *session, bool execute_history) if (bref->bref_dcb != NULL) { + bref_clear_state(bref, BREF_CLOSED); + if (!execute_history || execute_sescmd_history(bref)) { /** Add a callback for unresponsive server */ From 4422cd87ebb4790fb41f3b15aa4d1c3aa355d721 Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Wed, 21 Sep 2016 12:48:38 +0300 Subject: [PATCH 20/21] Update tarball installation instructions The /var/[log|lib|run|cache]/maxscale directory must be created manually. --- ...nstall-MariaDB-MaxScale-Using-a-Tarball.md | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/Documentation/Getting-Started/Install-MariaDB-MaxScale-Using-a-Tarball.md b/Documentation/Getting-Started/Install-MariaDB-MaxScale-Using-a-Tarball.md index ac2682979..25ec59a86 100644 --- a/Documentation/Getting-Started/Install-MariaDB-MaxScale-Using-a-Tarball.md +++ b/Documentation/Getting-Started/Install-MariaDB-MaxScale-Using-a-Tarball.md @@ -14,14 +14,28 @@ The required steps are as follows: $ sudo useradd -g maxscale maxscale $ cd /usr/local $ sudo tar -xzvf maxscale-x.y.z.OS.tar.gz - $ sudo ln -s maxscale-x.y.z maxscale + $ sudo ln -s maxscale-x.y.z.OS maxscale $ cd maxscale - $ chown -R maxscale var + $ sudo chown -R maxscale var Creating the symbolic link is necessary, since MariaDB MaxScale has been built with with the assumption that its base-directory, that is, the directory under which all its sub-directories are found, is `/usr/local/maxscale`. The symbolic link also makes it easy to switch between different versions of MariaDB MaxScale that have been installed side by side in `/usr/local`; just make the symbolic link point to another installation. +In addition, the first time you install MariaDB MaxScale from a tarball you need to create the following directories: + + $ sudo mkdir /var/log/maxscale + $ sudo mkdir /var/lib/maxscale + $ sudo mkdir /var/run/maxscale + $ sudo mkdir /var/cache/maxscale + +and make `maxscale` the owner of them: + + $ sudo chown maxscale /var/log/maxscale + $ sudo chown maxscale /var/lib/maxscale + $ sudo chown maxscale /var/run/maxscale + $ sudo chown maxscale /var/cache/maxscale + The following step is to create the MariaDB MaxScale configuration file `/etc/maxscale.cnf`. The file `etc/maxscale.cnf.template` can be used as a base. Please refer to [Configuration Guide](Configuration-Guide.md) for details. When the configuration file has been created, MariaDB MaxScale can be started. @@ -42,10 +56,10 @@ The next step is to create the MaxScale configuration file `maxscale-x.y.z/etc/m When the configuration file has been created, MariaDB MaxScale can be started. - $ cd maxscale-x.y.z + $ cd maxscale-x.y.z.OS $ bin/maxscale -d --basedir=. -With the flag `--basedir`, MariaDB MaxScale is told where the `bin`, `etc`, `lib` and `var` directories are found. Unless it is specified, MariaDB MaxScale assumes the directories are found in `/usr/local/maxscale` and the configuration file in `/etc`. +With the flag `--basedir`, MariaDB MaxScale is told where the `lib`, `etc` and `var` directories are found. Unless it is specified, MariaDB MaxScale assumes the `lib` directory is found in `/usr/local/maxscale`, and the `var` and `etc` directories in `/`. It is also possible to specify the directories and the location of the configuration file individually. Invoke MaxScale like From 0882541c8095e6c1888743be394c1f5877dc0870 Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Wed, 21 Sep 2016 13:49:54 +0300 Subject: [PATCH 21/21] Make the default directories configurable The default directories can now be changed at build time. This allows tarballs to look for libraries in a more sensible place. --- cmake/install_layout.cmake | 21 +++++++++++++++++++++ cmake/package_tgz.cmake | 6 ++++-- server/include/gwdirs.h.in | 37 +++++++++++++++++++------------------ 3 files changed, 44 insertions(+), 20 deletions(-) diff --git a/cmake/install_layout.cmake b/cmake/install_layout.cmake index a14ef05c5..4e3095e8e 100644 --- a/cmake/install_layout.cmake +++ b/cmake/install_layout.cmake @@ -9,3 +9,24 @@ set(MAXSCALE_DOCDIR ${CMAKE_INSTALL_DOCDIR}/maxscale CACHE PATH "Documentation i # These are the only hard-coded absolute paths set(MAXSCALE_VARDIR /var CACHE PATH "Data file path (usually /var/)") set(MAXSCALE_CONFDIR /etc CACHE PATH "Configuration file installation path (/etc/)") + +# Default values for directories and subpaths where files are searched. These +# are used in `server/include/gwdirs.h.in`. + +set(DEFAULT_PID_SUBPATH "run/maxscale" CACHE PATH "Default PID file subpath") +set(DEFAULT_LOG_SUBPATH "log/maxscale" CACHE PATH "Default log subpath") +set(DEFAULT_DATA_SUBPATH "lib/maxscale" CACHE PATH "Default datadir subpath") +set(DEFAULT_LIB_SUBPATH "${MAXSCALE_LIBDIR}" CACHE PATH "Default library subpath") +set(DEFAULT_CACHE_SUBPATH "cache/maxscale" CACHE PATH "Default cache subpath") +set(DEFAULT_LANG_SUBPATH "lib/maxscale" CACHE PATH "Default language file subpath") +set(DEFAULT_EXEC_SUBPATH "${MAXSCALE_BINDIR}" CACHE PATH "Default executable subpath") +set(DEFAULT_CONFIG_SUBPATH "etc" CACHE PATH "Default configuration subpath") + +set(DEFAULT_PIDDIR ${MAXSCALE_VARDIR}/${DEFAULT_PID_SUBPATH} CACHE PATH "Default PID file directory") +set(DEFAULT_LOGDIR ${MAXSCALE_VARDIR}/${DEFAULT_LOG_SUBPATH} CACHE PATH "Default log directory") +set(DEFAULT_DATADIR ${MAXSCALE_VARDIR}/${DEFAULT_DATA_SUBPATH} CACHE PATH "Default datadir path") +set(DEFAULT_LIBDIR ${CMAKE_INSTALL_PREFIX}/${DEFAULT_LIB_SUBPATH}/ CACHE PATH "Default library path") +set(DEFAULT_CACHEDIR ${MAXSCALE_VARDIR}/${DEFAULT_CACHE_SUBPATH} CACHE PATH "Default cache directory") +set(DEFAULT_LANGDIR ${MAXSCALE_VARDIR}/${DEFAULT_LANG_SUBPATH} CACHE PATH "Default language file directory") +set(DEFAULT_EXECDIR ${CMAKE_INSTALL_PREFIX}/${DEFAULT_EXEC_SUBPATH} CACHE PATH "Default executable directory") +set(DEFAULT_CONFIGDIR /${DEFAULT_CONFIG_SUBPATH} CACHE PATH "Default configuration directory") diff --git a/cmake/package_tgz.cmake b/cmake/package_tgz.cmake index 06ccf201e..cd30b7ce2 100644 --- a/cmake/package_tgz.cmake +++ b/cmake/package_tgz.cmake @@ -2,14 +2,16 @@ message(STATUS "Generating tar.gz packages") set(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE) set(MAXSCALE_BINDIR /bin CACHE PATH "" FORCE) -set(MAXSCALE_LIBDIR /lib CACHE PATH "" FORCE) +set(MAXSCALE_LIBDIR /lib/maxscale CACHE PATH "" FORCE) set(MAXSCALE_SHAREDIR /share CACHE PATH "" FORCE) set(MAXSCALE_DOCDIR /share CACHE PATH "" FORCE) set(MAXSCALE_VARDIR /var CACHE PATH "" FORCE) set(MAXSCALE_CONFDIR /etc CACHE PATH "" FORCE) set(CMAKE_INSTALL_PREFIX "/" CACHE PATH "" FORCE) -set(CMAKE_INSTALL_RPATH "$ORIGIN/../lib" CACHE PATH "" FORCE) +set(CMAKE_INSTALL_RPATH "$ORIGIN/../lib/maxscale/" CACHE PATH "" FORCE) set(CMAKE_INSTALL_DATADIR /share CACHE PATH "" FORCE) +set(DEFAULT_LIB_SUBPATH /lib/maxscale CACHE PATH "" FORCE) +set(DEFAULT_LIBDIR "/usr/local/maxscale/lib/maxscale" CACHE PATH "" FORCE) set(CPACK_GENERATOR "TGZ") # Include the var directories in the tarball diff --git a/server/include/gwdirs.h.in b/server/include/gwdirs.h.in index 0a2c0dab1..d607b021d 100644 --- a/server/include/gwdirs.h.in +++ b/server/include/gwdirs.h.in @@ -21,30 +21,31 @@ EXTERN_C_BLOCK_BEGIN -// NOTE: If you make changes here, ensure they are compatible with the -// situation in /CMakeLists.txt, where directories are installed. -#define MXS_DEFAULT_PID_SUBPATH "run/maxscale" -#define MXS_DEFAULT_LOG_SUBPATH "log/maxscale" -#define MXS_DEFAULT_DATA_SUBPATH "lib/maxscale" -#define MXS_DEFAULT_LIB_SUBPATH "@MAXSCALE_LIBDIR@" -#define MXS_DEFAULT_CACHE_SUBPATH "cache/maxscale" -#define MXS_DEFAULT_LANG_SUBPATH "lib/maxscale" -#define MXS_DEFAULT_EXEC_SUBPATH "@MAXSCALE_BINDIR@" -#define MXS_DEFAULT_CONFIG_SUBPATH "etc" +/** + * All of the following DEFAULT_* variables are defined in cmake/install_layout.cmake + */ +#define MXS_DEFAULT_PID_SUBPATH "@DEFAULT_PID_SUBPATH@" +#define MXS_DEFAULT_LOG_SUBPATH "@DEFAULT_LOG_SUBPATH@" +#define MXS_DEFAULT_DATA_SUBPATH "@DEFAULT_DATA_SUBPATH@" +#define MXS_DEFAULT_LIB_SUBPATH "@DEFAULT_LIB_SUBPATH@" +#define MXS_DEFAULT_CACHE_SUBPATH "@DEFAULT_CACHE_SUBPATH@" +#define MXS_DEFAULT_LANG_SUBPATH "@DEFAULT_LANG_SUBPATH@" +#define MXS_DEFAULT_EXEC_SUBPATH "@DEFAULT_EXEC_SUBPATH@" +#define MXS_DEFAULT_CONFIG_SUBPATH "@DEFAULT_CONFIG_SUBPATH@" /** Default file locations, configured by CMake */ static const char* default_cnf_fname = "maxscale.cnf"; -static const char* default_configdir = "/" MXS_DEFAULT_CONFIG_SUBPATH; +static const char* default_configdir = "@DEFAULT_CONFIGDIR@"; /*< This should be changed to just /run eventually, * the /var/run folder is an old standard and the newer FSH 3.0 * uses /run for PID files.*/ -static const char* default_piddir = "@MAXSCALE_VARDIR@/" MXS_DEFAULT_PID_SUBPATH; -static const char* default_logdir = "@MAXSCALE_VARDIR@/" MXS_DEFAULT_LOG_SUBPATH; -static const char* default_datadir = "@MAXSCALE_VARDIR@/" MXS_DEFAULT_DATA_SUBPATH; -static const char* default_libdir = "@CMAKE_INSTALL_PREFIX@/" MXS_DEFAULT_LIB_SUBPATH; -static const char* default_cachedir = "@MAXSCALE_VARDIR@/" MXS_DEFAULT_CACHE_SUBPATH; -static const char* default_langdir = "@MAXSCALE_VARDIR@/" MXS_DEFAULT_LANG_SUBPATH; -static const char* default_execdir = "@CMAKE_INSTALL_PREFIX@/" MXS_DEFAULT_EXEC_SUBPATH; +static const char* default_piddir = "@DEFAULT_PIDDIR@"; +static const char* default_logdir = "@DEFAULT_LOGDIR@"; +static const char* default_datadir = "@DEFAULT_DATADIR@"; +static const char* default_libdir = "@DEFAULT_LIBDIR@"; +static const char* default_cachedir = "@DEFAULT_CACHEDIR@"; +static const char* default_langdir = "@DEFAULT_LANGDIR@"; +static const char* default_execdir = "@DEFAULT_EXECDIR@"; static char* configdir = NULL; static char* logdir = NULL;