Commit Graph

921 Commits

Author SHA1 Message Date
bf24f18805 Merge branch 'develop' into MXS-544 2016-02-29 10:40:33 +02:00
395cbdc103 Simplify handling of "client data" by having a pointer to it only in DCB and not in session structure. Change name of session->client to session->client_dcb for greater clarity. Temporary free of client data in DCB, to be moved to authenticator when it becomes a module. Fix incorrect name of listener_alloc. 2016-02-23 11:13:21 +00:00
26cbcb7365 MXS-511: Made log messages about master status coherent
The checking of the master status and the possible error logging were done
in two different steps. This led to confusing error messages when the state
of the server changed between the check and the logging of the error message.
2016-02-12 21:18:57 +02:00
cfefc046e9 Merge branch 'release-1.3.0' into develop 2016-02-11 10:23:00 +02:00
4a4f22c9a7 Make query_classifier part of core.
The query classifier interface is now built as an integral
part of MaxScale core.
2016-02-08 11:44:07 +02:00
379cb6c781 MXS-564: Slave server states were not properly cleared after session commands
When a command that changes the session state is executed on all servers and
a slave server goes down, an error message was sent to the client even though
one wasn't expected. These appeared as odd connection errors on the client side.
2016-02-05 13:54:24 +02:00
9432967da5 Don't assert the master server state when routing query to slave
When a query is being routed to the slave, it is not necessary to assert that
the master server's state is still master. It is possible that the master server
changes states while the query is being routed but that doesn't affect the query
being currently routed.
2016-02-04 09:57:27 +02:00
e731f6a29e Fixed double freeing of buffers
The buffers in readwritesplit are handled at the routeQuery level and freeing
them at lower levels cause a double free of the used buffers.
2016-02-04 09:57:27 +02:00
d9eeb72198 Added missing check for closed master backend reference into readwritesplit
The master DCB was checked for NULL-ness but the proper way is to check if
the backend reference is closed. This will fix a debug assertion in addition
to possibly preventing crashes.
2016-02-04 09:57:27 +02:00
379004a2a4 Removed corrupted error messages from readwritesplit
When a slave server fails to execute a session command, the log message printed
the command that was being executed as if the ERR packet was a COM_QUERY packet.
This caused corrupt strings to be printed into the error logs.
2016-01-28 13:04:23 +02:00
e6d18f0b66 Fixed debug assertion causing a crash in readwritesplit
A debug assertion in the readwritesplit would always fail when the master DCB
was NULL. This was caused by the fact that the debug assertion assumes that the
pointer that is passed to it is a valid pointer.
2016-01-28 10:46:55 +02:00
087ab202c2 MXS-559: Fixed unsafe use of the master DCB in readwritesplit
The master DCB was used without checking if it was still open. It was possible
that the master DCB was closed and processed before the client had fully
processed all queries which caused it to fail at a debug assertion.

The fix to this is to use the client's DCB to get access to the shared session
authentication data as it is protected by additional locks.
2016-01-26 14:48:01 +02:00
1f241a5ed1 Rearrange libraries and build files.
This is the first change in an attempt to arrange the linking so that
more errors are detected at link-time.

- All files in server/core but for gateway.c are linked to one shared
  library called maxscale-common.
- The files log_manager/log_manager.cc and utils/skygw_utils.cc are
  built into maxscale-common as well.
- MaxScale itself consists now only of gateway.c and is linked with
  maxscale-common.
- All plugins link with maxscale-common.
- All executables link in addition with {EMBEDDED_LIB}.

After this change, the change (MXS-517) where query_classifier is the
only component that uses ${EMBEDDED_LIB} and the rest mysqlclient can
be made much cleaner.

After a few additional steps, all shared libraries can be linked with
the linker flags "-Wl,-z,defs", which directs the linker to resolve
all symbols. That will require that all shared libraries list all the
libraries they need, but will at the same time ensure that any
missing symbols are detected at link-time and not at run-time.
2016-01-22 23:26:17 +02:00
d41fe5b9c7 Added extra checks to readwritesplit
Added a check that the master server reference is actually in use before
doing anything with it. Also removed a false assertion.
2016-01-15 16:25:05 +02:00
23a7562d3a Replace skygw_ type prefix with qc_.
- skygw_query_type_t renamed to qc_query_type_t.
- skygw_query_op_t renamed to qc_query_op_t.
2016-01-11 12:06:21 +02:00
2f42246880 Rename query classifier functions consistently.
All public query classifier functions now have the prefix qc_.
2016-01-11 12:04:52 +02:00
cba190f84c Checks for temporary tables are only done if they have been created
Previously all queries were inspected for CREATE, DROP and SELECT statements
which targeted temporary tables even if they haven't been created.
2016-01-08 11:16:43 +02:00
b84e739cfa All queries related to prepared statement are sent to the master
The preparation and closing of prepared statements was sent to all servers
even though the execution was always sent to the master. With this change,
all queries which interact with prepared statements are only sent to the master.

The sending of statement preparations to all servers is a problem when a
statement which depends on a database or a table is created and the DDL
statement which created that table has not yet been replicated to the
slaves.

In addition to fixing the aforementioned problem, this change should also
reduce unnecessary network traffic to slaves and improve the overall
performance of the prepared statements.
2016-01-08 11:16:30 +02:00
d6afe70c6f Fix to MXS-323: Routers properly handle client DCB errors
All routers now detect if a client DCB is passed to handleError and
take the appropriate action.
2015-12-02 18:01:14 +02:00
02da87f737 Fix to MXS-439: Weightby value of 0 no longer causes a crash
A weightby parameter with a value of 0 no longer causes SIGFPE and the
invalid weight value is set to the correct value of 1.
2015-11-30 19:06:04 +02:00
a829b38873 Fix to MXS-363: Added soname versions to libraries
The soname version numbers were missing from all the library targets
properties which caused ldconfig to warn about non-symlink libraries
being installed.
2015-11-30 10:46:08 +02:00
8ae187622c Fixed weightby overflow being silently ignored in readwritesplit
If individual servers had a weightby parameter value greater than INT_MAX * 1000
the integer used for calculation would overflow and the server would end up
having a negative weight. This would cause all connections to pile up on this
server.

The same overflow was possible for the sum of all the weightby parameter values
even if no single parameter exceeded the limit.
2015-11-25 22:43:46 +02:00
038877b8db Fixed minor format errors and resource leaks
Some format strings used integer values for unsigned integers.
Memory and file descriptors leaked in some error conditions.
2015-11-25 12:43:49 +02:00
a8535f42af Remove all traces of logfile_t
The earlier log file based approach for enabling and disabling
messages has now been completely replaced with the syslog priority
based approach.

Similarly as with log files before it is now possible to enable
and disable a log priority for a particular session, even though
it apparently has not been used much.

The local test-programs of the logging has got minimal attention
only to make them compile. They should get an overhaul as they did
not work before either.
2015-11-23 19:10:53 +02:00
422d6f5ab2 Updated readwritesplit default values
The combination of only one slave being used and the slave_selection_criteria
being LEAST_CURRENT_OPERATIONS can possibly cause a connection pileup on one
slave server. This would skew the query distribution heavily towards the first
available slave even if multiple slave were being used.

Having the maximum number of slave servers to be equal to the total amount of
available slaves allows for a more even and responsive distribution of the
query traffic.
2015-11-20 05:57:51 +02:00
ee7793312b Broken error message fixed in readwritesplit.c
When converting the skygw_ logging calls to MXS_ equivalents,
some part of the error message got lost.
2015-11-18 20:51:11 +02:00
d59c6a3570 readwritesplit: skygw_log_writes replaced. 2015-11-18 12:28:40 +02:00
1de202ca20 LOGIF removed from readwritesplit 2015-11-17 12:51:08 +02:00
a355e1beef Printf format checking added to logging function.
Printf format checking added to logging function and all
issues that were revealed by that fixed.
2015-11-16 12:40:49 +02:00
30d1fc66b7 getCapabilities no longer takes arguments and returns an int. 2015-11-11 18:14:03 +02:00
dee20fe077 Merge remote-tracking branch 'origin/develop' into MXS-329-develop-20151111
# Conflicts:
#	server/core/CMakeLists.txt
#	server/core/buffer.c
#	server/core/service.c
#	server/modules/filter/tee.c
#	server/modules/monitor/mysql_mon.c
#	server/modules/routing/binlog/blr.c
#	server/modules/routing/binlog/blr_slave.c
#	server/modules/routing/debugcmd.c
#	server/modules/routing/readwritesplit/readwritesplit.c
#	utils/skygw_utils.cc

- resolved.
2015-11-11 11:08:02 +00:00
834a88aeda Log variables moved to log_manager.h
The log manager variables lm_enabled_log_files_bitmask, log_ses_count
and tls_log_info that earlier were declared separately in every
c-file are now declared in the log_manager.h header.
2015-11-04 14:26:53 +02:00
0accf869de Fix to MXS-365: https://mariadb.atlassian.net/browse/MXS-365 Added tracking of LOAD DATA LOCAL INFILE
While a LOAD DATA LOCAL INFILE query is being executed, all queries will be sent to the master
and they will not be processed as normal packets.
2015-11-04 12:47:55 +02:00
d6230e68ef Moved warnings about session command history limits to message log. 2015-11-04 09:12:37 +02:00
5112d4118f Fix to MXS-409: https://mariadb.atlassian.net/browse/MXS-409
Prepared statements are sent to the master instead of all servers.

The planned functionality to store the types of the prepared statements was not implemented
and all executions of prepared statements are sent to the master. Because of this the preparations
should be all sent to the master server instead of sending them to all servers.
2015-10-19 09:01:58 +03:00
e38ea9d07d Correct missing return value. 2015-10-02 16:19:59 +01:00
4f316419c5 Merge branch 'develop' into MXS-329 2015-09-30 12:47:28 +03:00
638c2250c9 Fixed internal test suite. 2015-09-29 16:36:12 +03:00
96f76a1f2e Changed the way max_sescmd_history works and combined disable_sescmd_history and disable_slave_recovery.
Before these changes when max_sescmd_history was used the session
was closed when the limit was exceeded. With this change, when the
limit is exceeded the recovery of slaves and the session command history
are both disabled. This will allow the sessions to continue while still
keeping the old functionality of limited salve replacement.

The disable_sescmd_history and disable_slave_recovery parameters were combined
so that disabling the session command history will also disable slave recovery.
This way no harm can be done with disable_sescmd_history.
2015-09-29 12:03:22 +03:00
db0e2e881f Double free prevented.
routeQuery calls route_single_stmt, which requires the GWBUF to be
contiguous. Earlier it was made contiguous (if needed) in
route_single_stmt. However, since the process of making a GWBUF
contiguous causes the original buffer to be freed, this would lead
to a double free later in routeQuery that frees the passed buffer.

This is prevented now by making the buffer contiguous before calling
route_single_stmt.
2015-09-29 10:57:45 +03:00
2231d0870c Place checks in callback routines because DCB will not always contain a reference to a router session, and the associated data will be invalid in this case. 2015-09-25 12:17:18 +01:00
2dfb9e3c11 Merge branch 'develop' into MXS-329 2015-09-24 17:59:36 +03:00
561891aac5 Fix for double free, possible fix for bug601.
In the end of execute_sescmd_in_backend the buffer was consumed
in case the protocol function failed. Or actually if it returned
something else but 1.

In the case of mysql_backend, the buffer is always freed when
authorizing and either consumed or placed on the dcb writequeue
when the data is written.

That is, it is never ok to consume the buffer in this function.
The end-result is likely to be an abort.
2015-09-21 13:45:15 +03:00
88716c35fb Various changes to block loopholes in different cases and tidy up. 2015-09-21 09:23:22 +01:00
31c6666278 Ensure DCB for closing session does not become persistent; remove bref_was_not_in_use. 2015-09-17 14:38:56 +01:00
dc3b0b067b Revert the dcb_close changes in handleError. 2015-09-17 13:35:18 +01:00
1ad8e27c91 Try a different arrangement of DCB closures in handleError of read-write split. 2015-09-17 13:27:25 +01:00
357c4bcae5 Add to or take from persistent pool only if server is running; add conditions to DCB close in read-write handleError to check backend reference was in use. 2015-09-17 12:53:59 +01:00
583c9b62fe Close DCB in handleError only if it can be found in a backend reference. 2015-09-17 11:58:19 +01:00
30239f395a Fix bref when backend server fails, error message if fails. 2015-09-15 20:07:56 +01:00