Commit Graph

2658 Commits

Author SHA1 Message Date
f14380243b Rename cppdefs.hh to ccdefs.hh
For obvious reasons; the c++ suffix is .cc and not .cpp
2018-08-10 07:50:18 +03:00
fbd3b08c1e MXS-1992 Make preparations for REST-API 2018-08-08 09:16:19 +03:00
ac57b4f71f Fix show database and show tables queries
Changes with ResultSet caused the send_databases and send_tables
functions to always return false. Also changed send_database to
return void since it shouldn't be able to fail anymore.
2018-08-07 08:54:16 +03:00
710f2d3c79 Unify unit test naming
The tests now all use snake_case naming.
2018-08-06 21:20:29 +03:00
b20decfe1c MXS-1929: Output const strings from serviceGetUser
The values aren't meant to be modified by the caller.
2018-08-06 21:20:29 +03:00
5d085f5cdf MXS-1929: Remove service parameter setters
Removed the explicit setters for the service parameters. Not all of them
were implemented and they were only used internally. Moved the parameter
validation and update processing inside the Service class to reduce the
load on the other parts of the core.
2018-08-06 21:20:29 +03:00
4d3dbb2040 MXS-1929: Take SFilterDef into use
The service now uses a std::vector<SFilterDef> to store the filters it
uses. Most internal parts deal with the SFilterDef but debugcmd.cc still
moves raw pointers around (needs to be changed).
2018-08-06 21:20:29 +03:00
a252b45f18 Don't use auto&& in non-template code
Use explicit types instead.
2018-08-06 21:20:29 +03:00
4c7a5017bc MXS-1929: Create internal server representation
The server now has an internal C++ version that extends the public one.
2018-08-06 21:20:29 +03:00
c01840ffb3 Remove unnecessary SConfig from readwritesplit
The configuration doesn't need to be contained in shared pointer as each
session holds its own version of it. This removes most of the overhead in
configuration reloading. The only thing that's left is any overhead added
by the use of thread-local storage.
2018-08-06 21:20:29 +03:00
166ecfead6 MXS-1992 MaxAdmin uses RoutingWorker for QC stats 2018-08-03 07:33:12 +03:00
c302268ca3 MXS-1992 Provide maxadmin if for getting qc stats
- Equivalent functionality will be provided for maxctrl.
- Functionality for obtaining the data will be moved to RoutingWorker.
2018-08-03 07:33:12 +03:00
359f61c73b Improve shutdown signal safeness
The signal handler no longer acquires the service list lock which removes
a number of deadlock possibilities from the shutdown process. Instead, a
global shutdown flag is set that serves the same purpose as the individual
service shutdown flags did.
2018-08-01 16:48:05 +03:00
f68da38b32 Clean up get_shard_target in schemarouter
get_shard_target had become little bloated with the recent changes so
some routing cases were moved to their own functions. Also removed
some code that was not needed.
2018-08-01 11:55:31 +03:00
ec420332ea MXS-1929: Take ResultSet into use
Replaced the previous RESULTSET with the new implementation. As the new
ResultSet doesn't have a JSON streaming capability, the MaxInfo JSON
interface has been removed. This should not be a big problem as the REST
API offers the same information in a more secure and structured way.
2018-07-31 22:50:08 +03:00
8ababa1d39 MXS-1929: Make core ResultSet functions private
The functions in the core that generate a ResultSet are now private.
2018-07-31 22:32:32 +03:00
1e33ab69f2 Rename server_is_running() to server_is_usable()
The previous name was misleading. The new server_is_running() only
checks for the running bit so that a server is always either running
or down.
2018-07-31 14:53:56 +03:00
3be975ba5d Fix fixing of std::string object names
Comparing two fixed std::strings would have equal C strings but comparing
with operator== they would be different. This was a result of the string
modification done by fix_object_name.

Converted the internal header into a C++ header, added std::string
overload and fixed use of the function.
2018-07-31 09:41:15 +03:00
afde1fa072 MXS-1929: Cache readwritesplit configurations
By using the worker local data mechanism, data can be efficiently cached
on the local worker. This avoids all synchronization on reads and only
requires synchronization on a configuration update.

As an additional observation, the testing of std::mutex and SPINLOCK shows
that std::mutex far outperforms the MaxScale SPINLOCK even on
non-conflicting workloads.
2018-07-31 09:41:14 +03:00
cca7757090 MXS-1929: Take internal Service struct into use
The internals now mostly refer to the Service struct instead of the public
SERVICE struct.
2018-07-31 09:41:13 +03:00
829fdcff83 MXS-1929: Make filters fully opaque
The filter implementation is now fully hidden. Also converted it to a C++
struct allocated with new and stored the filters in a global list instead
of embedding the list in the object itself.
2018-07-31 09:41:13 +03:00
106b1d46d5 Only perform causal reads on slaves
The causal read queries were performed also when the target server was the
master. The extra functionality of the causal reads is only needed on
slaves.

Adjusted the test case to require GTID replication.
2018-07-31 09:41:09 +03:00
d7a3980308 Read correct parameter for causal_reads
The configuration used the wrong parameter name. The test also did not
explicitly enable tracking of the last_gtid variable which caused it to
fail if it wasn't already on.
2018-07-31 09:41:09 +03:00
f10eab4406 MXS-1929: Fix binlogrouter unit test failure
The test failed because router instances are now created when the service
is allocated. In addition to this, a debug assertion was hit when a
service was freed if the router instance creation failed.
2018-07-31 09:41:07 +03:00
11d57a264c MXS-1113 Add support for prepared statements in schemarouter
Add support for binary protocol prepared statements for schemarouter.
This implementation doesn't yet attempt to handle all the edge cases.

Prepared statements are routed to the server that contains the affected
tables, the internal id from the server is then mapped to the session
command id that is inceremented for each prepared statement. This unique
session command id is returned to the client because internal id given
by server might be same around different servers and this way it is
possible to keep track of them and route them to the right servers when
executed.
2018-07-29 14:55:53 +03:00
adbc3a6749 MXS-1113 Add support for prepared statements in schemarouter
Implement handling of the text protocol part of the prepared statements
in schemarouter.
2018-07-29 14:21:55 +03:00
6c59da77fb Merge branch '2.2' into develop 2018-07-26 11:27:09 +03:00
fbce38878b Turn server status macros to functions 2018-07-25 11:19:47 +03:00
4b7cd7a281 Dump queue contents on unexpectedly NULL buffer
When the query queue does not contain a complete packet
(i.e. modutil_get_next_MySQL_packet return NULL), an informative dump of
how many bytes and what is stored is logged.
2018-07-24 09:51:48 +03:00
30ac15817f Assert that query queue contains complete packets
The query queue in readwritesplit must not contain partial packets. If it
does, something is broken as only complete packets should ever be in it.
2018-07-24 09:51:45 +03:00
28609a2c77 Remove session command processing from mariadbbackend
With the removal of the old session command implementation, the code that
used it can be removed or replaced with newer constructs. As a result, the
backend protocol no longer does any session command processing.

The three buffer types, GWBUF_TYPE_SESCMD_RESPONSE,
GWBUF_TYPE_RESPONSE_END and GWBUF_TYPE_SESCMD as well as their related
macros are no longer used and can be removed.
2018-07-17 11:52:22 +03:00
4e8ac8dd4f Fix explicit server allocation
The test cases allocated servers in a way that doesn't comfortably suit
the way the servers are now allocated. Adding a helper C++ class to load
module defaults makes it easier to do explicit server initialization in
tests.

The binlogrouter was also fixed in this commit as it uses servers much
like a test would use.
2018-07-17 11:52:21 +03:00
d28b1c9d1d Validate SSL parameters via the module-type parameters
The configuration system that modules use allows the SSL parameter
validation to be simplified. It should also provide more consistent error
messages for similar types of errors.

The SSL_LISTENER initialization is now done in one step. There was no good
reason to do it in two separate steps for listeners but in one step for
servers.

The `ssl` parameter now also accepts boolean values. As the parameter
behaves like a boolean and looks like a boolean, it ought to be a
boolean. It still accepts the custom `required` and `disabled` values
simply for backwards compatibility.

Also added the missing freeing functions for the SSL_LISTENER type. This
prevents failed SSL_LISTENER creations from leaking memory.
2018-07-17 11:52:20 +03:00
3078da3992 Make use of router_options in readwritesplit an error
As the router_options have been deprecated in 2.2 and removed in 2.3,
using them in readwritesplit is an error.
2018-07-17 11:52:16 +03:00
e963f4e82b Fix reading of past-the-end memory
The buffer that binlogrouter allocated for the error message was too
small. ASAN happened to catch this.
2018-07-17 11:52:16 +03:00
5fdf82a508 Only warn about whitespace in section names
The warnings were logged even when the fix_section_name function was used
to fix non-section names.
2018-07-17 11:52:15 +03:00
f807c21242 Treat service parameters as module parameters
The same mechanism that is used for modules can be used for the
configuration of the core objects. This removes the need for the redundant
code that validates various values that is already present in the code
that modules use.
2018-07-17 11:52:14 +03:00
4fb4ed416b MXS-1977: Fix protocol and readwritesplit memory leaks
The protocol could leak memory in rare cases where several commands were
queued at the same time. Readwritesplit also didn't free the memory it
acquired via qc_get_table_names.
2018-07-16 06:07:14 +03:00
2acf5f545e MXS-1066 Add query hint to route to last used server
Add new hint type and support for it in the readwritesplit router.
2018-07-13 11:11:02 +03:00
cbb8c68770 Remove router_options
Relaced router_options with configuration parameters in the createInstance
router entry point. The same needs to be done for the filter API as barely
any filters use the feature.

Some routers (binlogrouter) still support router_options but using it is
deprecated. This had to be done as their use wasn't deprecated in 2.2.
2018-07-11 14:08:56 +03:00
f11f8980b2 Use mxs::strtok in readconnroute
The configuration can be simplified by using the string tokenization
function.
2018-07-11 14:08:55 +03:00
e353d14550 Prepare binlogrouter for removal of router_options
To prepare the router's for the eventual removal of the router_options
parameter, the API option arguments should not be used. The parameters can
be substituted by tokenizing the value of the parameter that is still
stored as a part of the service.
2018-07-11 14:08:55 +03:00
b320217212 Remove configuration reloading
Removed the deprecated configuration reloading code. Added a entry into
the release notes that states this and the fact that it was deprecated in
2.2.
2018-07-11 14:08:54 +03:00
5903e194a7 Add runtime schemarouter reconfiguration
The schemarouter now also uses versioned configurations implemented by
shared pointers to configuration objects. Moved all the configuration
management into the Config class. Removed router options from
schemarouter.
2018-07-11 14:08:52 +03:00
c4be3f75c0 Add readconnroute runtime reconfiguration
Readconnroute can now be configured at runtime. The changes to
configuration processing allow the removal of router_options now that the
parameters are parsed inside the router.
2018-07-11 14:08:51 +03:00
5604023b26 Clean up readconnroute structures
Removed unused member variables and reduced debug output.
2018-07-11 14:08:51 +03:00
f3c84d84c7 Fix transaction migration
The transaction migration in the case of a changed master never worked as
transaction replay would only be triggered when the master fails. To cover
this case, the transaction replay just needs to be started when the need
for a transaction migration is detected.

To help diagnose the behavior, the Trx class no longer logs a message when
a transaction is closed. This is now done by readwritesplit which has more
knowledge of the context in which the transaction is closed.
2018-07-11 14:08:50 +03:00
98e233bb33 Minor cleanup of route_single_stmt
Moved transaction statistics calculations into a member function and
placed all target type specific processing into their respective
functions.

Also inverted the connection keepalive check to also cover hinted queries.
2018-07-11 14:08:50 +03:00
1e68261bce Add missing handling of max_slave_connections
The parameter accepts both counts and percentages which requires special
handling in the router. This needs to be done when the configuration is
updated.
2018-07-11 14:08:49 +03:00
861b0857cd Use correct type for transaction_replay_max_size
transaction_replay_max_size is a size, not a count.
2018-07-11 14:08:48 +03:00