62 Commits

Author SHA1 Message Date
Markus Mäkelä
6f185ff5db MXS-1555: Fix persistent pool qualification
When packets were routed individually, the qualification for the
persistent pool was done before the current command was updated. In
addition to this, the previous commit doesn't seem like it can even build.
2017-12-05 12:09:52 +02:00
Markus Mäkelä
c8b6838bce MXS-1555: Fix statement tracking for readwritesplit
The statement tracking was given the same buffer multiple times when a
large packet was spread across multiple buffers when a router with
RCAP_TYPE_STMT_INPUT was present.

The command tracking packet processing is redundant for routers that
require RCAP_TYPE_STMT as the same processing is done later when the
buffer is split into packets and routed. By using the split packets, the
protocol module can simplify the command tracking by a great deal for most
routers.
2017-12-04 14:49:13 +02:00
Markus Mäkelä
5664cb8bf6 Fix protocol command tracking
The command byte was always read at an offset of 4 instead of the current
offset plus 4.
2017-12-01 11:30:13 +02:00
Markus Mäkelä
f2a0cc8b31 Don't send hangup error on connection close
If the client has sent a COM_QUIT, the hangup error message should not be
written.
2017-11-30 17:25:06 +02:00
Markus Mäkelä
7cc4018c15 Use SQLSTATE 08S01 for hangup errors
This will tell the connectors that the connection cannot be used.
2017-11-15 15:00:40 +02:00
Markus Mäkelä
060a96d7f3 Send error on client DCB hangup events
Sending an error to the client allows the connector to show more
information to the user when the DCB is closed due to a reason internal to
MaxScale.

The error message states that the connection was killed by MaxScale to
distinct it from the error sent by the server. The error number and SQL
state are still the same as both errors should be treated the same way.
2017-11-15 14:57:28 +02:00
Markus Mäkelä
4da28789ac Fix SSL regression
This builds on commit 1287b0e595a5f99026f66df7eeaef091b8ffc774 and cleans
up the original code. This fixes a bug introduced in the aforementioned
commit and cleans up the code.
2017-11-08 10:13:19 +02:00
Markus Mäkelä
1287b0e595 Backport authentication fix from 2.2
The authentication code assumed that the initial request only had
authentication related data. This is not true if the client library
predicts that the authentication will succeed and it sends a query right
after it sends the authentication data.
2017-11-03 11:00:54 +02:00
Markus Mäkelä
5b1f8afcd9 MXS-1366: Validate closed connections before pooling them
When a session is being closed in a controlled manner, i.e. a COM_QUIT is
received from the client, it is possible to deduce from this fact that the
backend connections are very likely to be idle. This can be used as an
additional qualification that must be met by all connections before they
can be candidates for connection pooling.

This assumption will not hold with batched and asynchronous queries. In
this case it is possible that the COM_QUIT is received from the client
before even the first result from the backend is read. For this to work,
the protocol module would need to track the number and state of expected
responses.
2017-08-21 10:31:07 +03:00
Markus Mäkelä
35de0c392f Only store established connections in the pool
If a connection has not been fully established (i.e. authentication has
been completed) then it should not be considered as a connection pool
candidate.
2017-08-09 09:22:57 +03:00
Johan Wikman
8e81941058 Enable trx boundary detection using regexes
Transaction boundaries can now be detected using regexes.
All else being equal, it gives a 10% performance improvement
compared to qc-based detection.

In a subsequent change, mysql_client.c will be modified to use
qc_get_trx_type_mask() instead of qc_get_type_mask().

Currently the use of regex matching is turned on using an
environment variable. That will change.
2017-03-15 09:35:15 +02:00
Markus Mäkelä
4d561c5f6a Detect password usage based on token length
The client protocol module can resolve whether a password was used based
on the information the authenticators gather before authentication is
done. It uses the authentication token length as the basis on which it
makes the decision.
2017-03-13 19:42:38 +02:00
Markus Mäkelä
d4a06c61de Move reauthentication to authenticators
Currently the only situation where a user needs to be authenticated after
the initial authentication is when a COM_CHANGE_USER is being
executed. This was previously handled by directly calling a function in
the MySQLAuth authenticator.

The new entry in the API of the authenticators is very specific to MySQL
and should be reviewed once other protocols are added.
2017-03-13 10:45:51 +02:00
Markus Mäkelä
789c14197d Merge branch '2.0' into 2.1 2017-03-02 14:05:42 +02:00
Markus Mäkelä
9aa22c6eb4 Fix server version detection of 10.2 flags
The code used the wrong version string. Instead of using the server
version string, it used the service version string.
2017-02-21 11:27:04 +02:00
Markus Mäkelä
644b139b00 Add support for 10.2 server capabilities
Added support for 10.2 server capabilities and cleaned up the server
capability flags.
2017-02-21 11:27:03 +02:00
Johan Wikman
49cc2b52e3 Merge branch '2.1.0' into 2.1 2017-02-15 08:44:55 +02:00
Johan Wikman
5648f708af Update license to BSL 1.1 2017-02-14 21:42:28 +02:00
Markus Mäkelä
ce5cd69eb3 Remove unused locks and variables
Removed unused spinlocks from DCBs, sessions and the MySQL protocol
structs. They were used in a context where only one thread has access to
the structure.

Removed unused member variables from DCBs.
2017-02-08 15:31:17 +02:00
Esa Korhonen
8b83bf834e Clean up router.h
Nothing moved to core, just rename and cleanup.
2017-01-26 16:14:17 +02:00
Markus Mäkelä
5630afebff Fix typo in COM_SET_OPTION comment
The comment had the option meanings reversed.
2017-01-26 10:55:32 +02:00
Markus Mäkelä
4b7f282f14 Handle COM_SET_OPTION in client protocol
The client protocol capability bytes are now updated when a COM_SET_OPTION
is executed.
2017-01-26 09:57:29 +02:00
Markus Mäkelä
99f6d4678d Make COMMIT/ROLLBACK a part of the transaction
The transaction tracking now flags the transaction as open even when a
COMMIT/ROLLBACK is received. The next statement after the transaction is
closed resets the transaction state to inactive. This means that the end
of the transaction belongs in the transaction.

This allows all statements that belong to a transaction to be detected
with the transaction tracking functions provided by the core. With this,
the routing modules should have an easier time handling transactions.
2017-01-24 20:36:39 +02:00
Markus Mäkelä
c77bb502e9 Store transaction type bit on transaction end
When the transaction ends, it's good to know what type of a transaction
just ended. Currently, this will be used by readwritesplit to detect when
a read-only transaction ends.
2017-01-24 20:36:39 +02:00
Markus Mäkelä
81be935fa9 Track transaction end as well as start
The COMMIT and ROLLBACK are now detected. This can be used to route the
trailing end of a transaction to a specific server.
2017-01-24 20:36:39 +02:00
Esa Korhonen
6e38276a20 Rename files, removing "gw"-prefix
Also gwdirs.h.in -> paths.h.in
2017-01-20 12:55:52 +02:00
Johan Wikman
16a76fcd28 Rename qc_get_type() to qc_get_type_mask()
To make it plain that it is a mask that is returned and not a
specific value from the enum qc_query_type_t.
2017-01-18 08:34:53 +02:00
Esa Korhonen
fb771c8a2e Rename public types and constants in session.h
Preparing to split session.h into module and core sections.
2017-01-17 16:30:14 +02:00
Markus Mäkelä
1766e3a06b Format protocol modules
Formatted protocol modules with Astyle.
2017-01-17 14:47:50 +02:00
Markus Mäkelä
2cabcea211 Add definitions of MXS_MODULE_NAME to all modules
All modules now declare a name for the module. This is name is added as a
prefix to all messages logged by a module. The prefix should help
determine which part of the system logs a message.
2017-01-16 11:28:34 +02:00
Johan Wikman
2fa12f796b Rename MYSQL_GET_PACKET_LEN to MYSQL_GET_PAYLOAD_LEN
The function returns the length of the payload, not the length of
the entire packet.
2017-01-12 14:24:14 +02:00
Johan Wikman
2d849e0ab2 Remove MySQL dependency from gateway.cc
The MySQL initialization is now performed by the MySQLClient module.
2017-01-09 09:16:35 +02:00
Johan Wikman
a2a38f952a Add [process|thread] [init|finish] functions to modules
The MXS_MODULDE object now contains optinal pointers for functions
to be called att process and thread startup and shutdown. Since the
functions were added to the end, strictly speaking, all structures
would not have needed to have been modified, but better to be
explicit. In a subsequent change, these will be called.

C++ does not support flexible arrays, so for the time being C++
modules are restricted to 10 parameters. Better approach is to
factor out the parameters to a separate array and then just store
a pointer to that array in MXS_MODULE.
2017-01-05 14:44:02 +02:00
Johan Wikman
2abe956056 Rename GWPROTOCOL to MXS_PROTOCOL 2017-01-05 14:36:44 +02:00
Johan Wikman
19ce28a43a Rename gw_protocol.h to protocol.h 2017-01-05 14:36:44 +02:00
Markus Mäkelä
c96bd64aa8 Rename MODULE_INFO to MXS_MODULE
The MODULE_INFO is now the main object which is used by modules to convey
information to the MaxScale core. The MXS_MODULE name is more apt as it
now contains the actual module definition.

The old MODULES structure was moved into load_utils.c as an internal
implementation and was renamed so that it is not confused with the new
MODULE structure.
2017-01-03 18:01:14 +02:00
Markus Mäkelä
b00e0328d5 Create a macro for module declarations
The modules are now declared with a common macro. This allows future
additions to the module loading process while also making the loaded
symbol name a constant.
2017-01-03 18:01:13 +02:00
Markus Mäkelä
ae0577c695 Move module object inside MODULE_INFO
This allows modules to only expose one entry point with a consistent
signature. In the future, this could be used to implement declarations of
module parameters.
2017-01-03 18:01:13 +02:00
Markus Mäkelä
6c53999c97 Combine ModuleInit and GetModuleObject
The two functions can be combined into one as both are called only
once. This removes the need for the explicit ModuleInit function.
2017-01-03 18:01:13 +02:00
Markus Mäkelä
7df29aa1ec Move version entry point into MODULE_INFO
The MODULE_INFO can easily hold the version information of the
module. This removes the need for a explicit version entry point.
2017-01-03 18:01:13 +02:00
Markus Makela
8efdaa1ea6 Move fake events to a thread-specific queue
The fake poll events are now stored in thread specific queues. This
removes the need for the poll event queue.
2016-11-30 10:28:22 +02:00
Markus Makela
1457b88606 Fix transaction tracking
The transaction tracking functionality used the wrong pointer type for
buffer data. This caused the query command comparison to always fail.
2016-11-23 10:11:27 +02:00
Markus Makela
3c15b58891 Merge branch '2.0' into develop-2.0-merge 2016-11-15 00:09:24 +02:00
Johan Wikman
46c2b6e76a Only parse COM_QUERY packets 2016-10-25 20:28:50 +03:00
Johan Wikman
f961f87e5e Update autocommit mode and transaction state
The transaction state only reflects explicitly started transactions.
Thus, by looking at the autocommit mode and the transaction state a
component can figure out whether the current statement will be committed
or not.
2016-10-25 16:21:31 +03:00
Johan Wikman
041df39819 Move transaction state management to the right place
The transaction state must be updated after a buffer has been split
into buffer containing individual packets.

NOTE: The actual updating of the transaction state and the autocommit
      mode is currently wrong, but will be updated in a subsequent change.
2016-10-25 16:21:31 +03:00
Johan Wikman
28ecba4022 Use service capabilities
Now the capabilities of routers and filters alike will be honoured.
2016-10-24 15:19:37 +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
693d8dcbb4 Track session autocommit state
This tracks only what is explicitly set. That is, if autocommit
has been set true then, even if a transaction is started, autocommit
will not be set false.

That is, a user of the session autocommit and transaction states
need to be aware of their semantics. If a transaction is active,
then the state of autocommit is irrelevant.
2016-10-21 13:58:51 +03:00
Markus Makela
3484b34747 Copy client information also for SSL connection
When a MySQL SSL connection is made, the first packet from the client will
contain the SSLRequest packet. This packet is a truncated normal auth
packet and the real auth packet will be sent after SSL has been
established.

The MySQLClient protocol should read the client information for SSL
connections after SSL has been established.
2016-10-21 11:47:27 +03:00