489 Commits

Author SHA1 Message Date
Johan Wikman
265aacaf15 GWBUF_DATA(...) explicitly returns uint8_t* 2016-11-24 13:31:29 +02:00
Markus Makela
f4e3ca2c87 Merge branch '2.0.2' into develop 2016-11-23 11:24:34 +02:00
Markus Makela
1432677406 Fix regression in prepared statement routing
The prepared statements were router according to the real type instead of
being router to the master. This was caused by the change in the route
target function.
2016-11-21 23:05:46 +02:00
Johan Wikman
9e4ee0323d Merge branch '2.0' into develop 2016-11-21 12:23:30 +02:00
Markus Makela
5aefd35df9 MXS-969: Detect user variable modifications
With the use_sql_variables_in=master option, readwritesplit should route
all user variable modifications and reads with user variables to the
master.

Previously, the modification of user variables was grouped into generic
system variables which caused all modifications to system variables to go
to the master only. The router requires a finer grained distiction between
normal system variable modifications and user variable modifications.

With the improvements to the query classifier, readwritesplit now properly
routes all user variable operations to the master and other system
variable modifications to all servers.
2016-11-16 15:26:06 +02:00
Markus Makela
44a55d231f Merge commit 'a7c21eee88c3c2530c06fea8a20c718004eed244' into develop-2.0-merge 2016-11-16 12:57:23 +02:00
Markus Makela
a7c21eee88 Always treat master failures as fatal errors
When a connection to the master fails, readwritesplit should always treat
it the same way. Previously, if a connection to the master was lost but it
hadn't lost the master status, the failure would be treated like a slave
server failure.
2016-11-15 22:18:26 +02:00
Markus Makela
3c15b58891 Merge branch '2.0' into develop-2.0-merge 2016-11-15 00:09:24 +02:00
Markus Makela
da129025eb Use common backend closing function
The backend references now use a common closing function so that all
variables are reset to proper states. The stored queries weren't always
freed and they would leak memory if left open.
2016-11-14 16:14:20 +02:00
Markus Makela
ba4ab9d35f Remove sorting of backends with qsort
The backends are no longer sorted with qsort. This removes the possibility
of stale backend references.
2016-11-14 15:01:41 +02:00
MassimilianoPinto
2334c663e0 Merge branch 'develop' into MXS-936 2016-11-10 15:42:09 +01:00
Markus Makela
65886dc386 Check whether server references are active
Before a query is routed to a backend, the status of the server reference
is checked. This allows the servers that are removed from a service to be
ejected from the list of active servers for active sessions.
2016-11-10 15:15:10 +02:00
Markus Makela
ea0dcea5d6 Clean up instance and session lifecycle functions
The createInstace, newSession, closeSession and freeSession functions were
cleaned up and reorganized to be a bit clearer for the reader. Removed
unnecessary comments and replaced them with ones that explain what's
happening in the code.

Removed unused linked lists from both sessions and instances and replaced
them with better alternatives. This should improve performance since new
session don't have to acquire the instance level lock to put themselves
into the session list.
2016-11-10 15:15:10 +02:00
Markus Makela
88dca05dc7 Remove unused code from readwritesplit
There was a lot of extra debug logging behind unused defines. These were
never enabled and some of the code never worked.
2016-11-10 15:15:10 +02:00
Markus Makela
dc8c068936 Modify readwritesplit to understand changes in server references
The readwritesplit now understands that the amount of servers can change
and some of the items in the list of server references aren't in use. This
allows dynamic changes to the number of servers used by readwritesplit.
2016-11-10 15:15:10 +02:00
Markus Makela
b12a87ef04 Fix false error message in readwritesplit
The error message for failure to find master wasn't included in the new
master error logging.
2016-11-09 23:21:53 +02:00
Markus Makela
8d893b4e56 Reassing master reference after sorting backends
The master reference used by the readwritesplit sessions needs to be
reassigned if slave reconnection occurs. This happens because the
reference refers to a certain place in the backend reference array
instead of the actual backend reference and those places are mixed
when the array is sorted.
2016-11-09 23:21:47 +02:00
MassimilianoPinto
de18f25cb8 MXS-936: add shutdown hooks
First part: add shutdown hooks for routers.

Binlog is the first one with a  destroyInstance() routine
2016-11-08 11:12:37 +01:00
Markus Makela
a163e31b9a Remove BACKEND structure from readwritesplit
The BACKEND structure is no longer created for the instance. This allows
sessions to dynamically create new servers.
2016-11-07 14:10:18 +02:00
Markus Makela
a097204c70 MXS-922: Move server weight calculation into the core
The core now does the server weight calculation instead of each router
module doing the same thing.
2016-11-07 14:10:18 +02:00
Markus Makela
83f3245f75 Improve master routing failure error logging
The error logging is now more detailed and tells why the connection is
being closed. This should help the user figure out what is happening when
write fails and the connection is closed.
2016-11-06 10:25:56 +02:00
Markus Makela
263688d3af Use proper server status macros in readwritesplit
Some of the master server status checks didn't check whether the server
was actually running. The macros in server.h should always be used instead
of manually inspecting the server status.
2016-11-06 07:03:07 +02:00
Markus Makela
3d4a7179c7 Prevent active readwritesplit sessions from connecting to a master
If a readwritesplit session is active, it should never connect to a new
master. This will lead to unexpected results as the session states aren't
consistent.
2016-11-05 11:31:06 +02:00
Markus Makela
c30d0dfc9d Add more error logging to DCB handling
If an illegal DCB close is done with a backend DCB, it will log the server
where it was connected. This allows us to know whether the DCB was
connected to a master or a slave.

Added more debug assertions to readwritesplit code. The DCBs should never
enter the DCB_STATE_DISCONNECTED.

Removed useless debug log messages. The messages usually just flood the
logs with no use to the developers.
2016-11-05 11:28:18 +02:00
Markus Makela
8f6c1bdd5b Add more error messages for unexpected situations
Some error messages were logged at INFO level and some had conditions that
prevent the logging. Removed these restrictions that an error situation is
always logged.
2016-11-03 10:16:46 +02:00
Markus Makela
3870b81244 Prevent unintentional reconnections to the master server
If a master_failure_mode was set to error_on_write, a reconnection to the
old master would happen after the following events:

- Master server fails and the connection is closed
- The master server recovers
- A slave fails and the connection is closed
- A replacement for the slave is searched

If these events took place, the master would be taken back into use with
an inconsistent session state.
2016-11-02 19:55:36 +02:00
Johan Wikman
ab487e687f qc: Remove QUERY_IS_TYPE macro
Explicit call to qc_query_is_type() instead.
2016-11-02 15:50:21 +02:00
Markus Makela
572d466fad Fix read-only mode error handling in readwritesplit
In read-only modes, readwritesplit would always continue even if an active
statement execution was in progress.
2016-11-02 12:12:36 +02:00
Markus Makela
1388686fb7 MXS-957: Fix temporary table detection
Temporary tables which were created from joins with other temporary tables
weren't properly detected as CREATE TEMPORARY TABLE statements.
2016-10-26 17:36:48 +03:00
Johan Wikman
dc97de57c2 qc: Some minor cleanup
- qc_types_to_string renamed to qc_typemask_to_string
- qc_get_qtype_str removed, duplicate of qc_typemask_to_string
2016-10-26 10:21:11 +03:00
Johan Wikman
db2cccbd8f Replace getCapabilities() with getCapabilities(void)
The latter means no args, the former means any args.
2016-10-24 11:19:43 +03:00
Johan Wikman
6bcb3ce4dc Change capabilities to uint64_t
- Since the capabilities are a bitmask, it is better if an unsigned
  integral type is used.
- Since the function is part of an ABI, it is better if an explicit
  size is used.
- 64-bits so that there also is room for independent filter
  capabilities.
2016-10-20 20:14:59 +03:00
Markus Makela
b50e794be7 MXS-917: Only log an error if the master is in use
When the readwritesplit can't locate the master server when it's checking
the list of available servers, it logs an error if the original master
reference isn't in a valid state. This error should only be logged if the
server is in use but in an unexpected state.
2016-10-17 06:54:37 +03:00
Johan Wikman
1333da0712 Remove skygw_utils.h
The general purpose stuff in skygw_utils.h was moved to utils.h
and the corresponding implementation from skygw_utils.cc to utils.c.
Includes updated accordingly.

Skygw_utils.h is now only used by log_manager and by mlist, which
is only used by log_manager. Consequently, skygw_utils.h was moved
to server/maxscale.

Utils.h needs a separate overhaul.
2016-10-14 19:50:54 +03:00
Johan Wikman
03dbc6df80 Remove dependency on skygw_utils.h
- STRERROR_BUFLEN moved to cdefs.h and renamed to MXS_STRERROR_BUFLEN.
  Better would be to provide a 'const char* mxs_strerror(int errno)'
  that would have a thread specific buffer for the error message.
- MIN and MAX also moved to defs.h as MXS_MIN and MXS_MAX.
- Now only mlist.h of the headers depend upon skygw_utils.h.
2016-10-14 15:42:02 +03:00
Johan Wikman
1a978be6b6 Cleanup header files
- All now include maxscale/cdefs.h as the very first file.
- MXS_[BEGIN|END]_DECLS added to all C-headers.
  Strictly speaking not necessary for private headers, but
  does not hurt either.
- Include guards moved to the very top of the file.
- #pragma once added.
2016-10-14 11:54:37 +03:00
Johan Wikman
3a18b64bdd mysql_client_server_protocol.h moved.
Moved to include/maxscale/protocol/mysql.h
2016-10-13 22:59:39 +03:00
Johan Wikman
c433d11b39 Module private headers moved to modules 2016-10-13 22:59:39 +03:00
Johan Wikman
e41589be10 Move headers from server/include to include/maxscale
- Headers now to be included as <maxscale/xyz.h>
- First step, no cleanup of headers has been made. Only moving
  from one place to another + necessary modifications.
2016-10-13 16:19:20 +03:00
Markus Makela
fbf5c331f1 Merge branch '2.0.1' into develop 2016-10-03 15:21:04 +03:00
counterpoint
2ae4fb7745 Add missing comment blocks. 2016-09-28 09:33:28 +01:00
Johan Wikman
8f233d32cf Always update state of bref behind lock 2016-09-28 09:29:56 +03:00
Markus Makela
997fe6b90b Add a fail-safe for active operation counters
If a backend is not in use but it is waiting for a result, the state
should anyways be cleared to keep the operation counters correct.
2016-09-26 09:29:44 +03:00
Markus Makela
eaf43ca92d Merge branch '2.0' into develop-2.0-merge 2016-09-21 14:59:30 +03:00
Markus Makela
578f21e757 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.
2016-09-21 11:15:57 +03:00
Markus Makela
ca9021b835 Merge branch '2.0' into develop 2016-09-21 02:51:27 +03:00
Markus Makela
62ab834e8a Remove unused variables from readwritesplit
There were some unused variables in readwritesplit that caused builds to
fail.
2016-09-20 21:04:10 +03:00
counterpoint
923761159f Move MXS-807 refactor read-write split into develop. 2016-09-20 11:55:02 +01:00
Markus Makela
2a4addc298 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.
2016-09-16 09:58:56 +03:00
Markus Makela
029e6574da 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.
2016-09-15 08:31:15 +03:00