2122 Commits

Author SHA1 Message Date
Markus Mäkelä
c893e354a9 Add missing variable
The numlocks variable is used when older OpenSSL versions are used.
2018-01-23 09:26:02 +02:00
Markus Mäkelä
c4df28f64a MXS-1416: Skip directory creation with --config-check
The log and data directories aren't created or checked when the
--config-check option is given.
2018-01-17 09:56:50 +02:00
Markus Mäkelä
ab44a941ab MXS-1575: Fix large DECIMAL value handling
DECIMAL types that were larger than 8 bytes were not handled
correctly. The current implementation only prints the lowest 8 bytes of
the integer part of the decimal.
2018-01-15 16:15:20 +02:00
Markus Mäkelä
0416d66bcb Set query classifier with an absolute path in tests
Setting the query classifier with an absolute path makes it easier to
manage test setup without having to manually resolve the relative path to
the query classifier from the test source directory.
2018-01-08 09:41:24 +02:00
Markus Mäkelä
579dca0750 Log to stdout in unit tests
The log manager will log to stdout to work around directory and file
permissions.
2018-01-05 16:12:54 +02:00
Markus Mäkelä
e5b5303137 Initialize the query classifier in tests
The test initialization function now loads the query classifier.
2018-01-05 12:57:09 +02:00
Markus Mäkelä
e310bbbe53 Initialize query classifier in housekeeper thread
The query classifier was not initialized for the housekeeper thread. This
means that tasks could not use the query classifier and as the avro
conversion is done inside a task, it can't use it.
2018-01-05 12:50:39 +02:00
Markus Mäkelä
e9fceff8ce Fix log manager race condition
The log manager could send two messages if a log message was posted soon
before the log manager was stopped. This caused a debug assertion which
then manifested as a deadlock inside the log manager.
2018-01-04 10:27:56 +02:00
Markus Mäkelä
3bba88408c Remove random sleep interval from acquire_lock
The function caused problems with tests and the random sleep is truly not
needed (legacy code and it doesn't bring any visible benefits).
2018-01-03 13:08:46 +02:00
Markus Mäkelä
5ede5a4f96 Fix comment removal regex
The trailing comment removal pattern unnecessarily required that a leading
space is present in all trailing comments.

Also, the pattern didn't match if no line ending was included in the SQL
statement. The subject ending should be the third valid terminator in
addition to UNIX and Windows style line endings.
2017-12-27 17:21:42 +02:00
Johan Wikman
33b1c552e0 Load qc from build directory
The query classifier library will now be loaded from the build
directory and not from the installation directory.
2017-12-27 16:09:54 +02:00
Markus Mäkelä
bdcda0f235 Fix empty TIME2 values
The values for TIME2 were always empty as they weren't processed.
2017-12-14 19:06:17 +02:00
Markus Mäkelä
196821c6fc Assign the service pointer for backend DCBs
The backend DCBs didn't have a valid service pointer whereas the client
DCBs had one. The necessity of the pointer can be questioned as a similar
pointer is located in the session.
2017-12-13 16:42:55 +02:00
Markus Mäkelä
66be882ae0 Don't reload users for dummy sessions
The service for a dummy session will be NULL. If authentication fails for
a dummy session, then no service level actions should be taken.

Only the binlogrouter can trigger authentication failure with a dummy
session as it creates connections before the service itself has started.
2017-12-11 12:31:40 +02:00
Markus Mäkelä
96d9c47016 MXS-1553: Enforce SSL usage for monitors
If a server is configured to use SSL, then MaxScale should respect the
configuration and refuse to use a connection that is not encrypted.
2017-12-01 03:50:57 +02:00
Markus Mäkelä
0ca04cb5d5 MXS-1536: Fix crash in CREATE TABLE
If a CREATE TABLE statement had a quoted keyword as the name of a field,
the calculated column count and actual column counts would differ.

In addition to this, oneline comments before the end of the statement
would truncate the SQL due to the fact that the whitespace was squashed
before the comment removal was done.
2017-11-30 12:38:43 +02:00
Johan Wikman
4ee9f54f5d MXS-1529 Ensure that config file is a file
If the provided configuration file argument does not refer to a
regular file, MaxScale refuses to start.
2017-11-28 15:56:59 +02:00
Johan Wikman
5c9d8c53d9 MXS-1529 Rename file_is_[readable|writable]
Rename file_is_[readable|writable] to path_is_[readable|writable]
as it makes the check for both files and directories.
2017-11-28 15:40:59 +02:00
Johan Wikman
6359b7983f MXS-1529 Prevent endless realloc loop
If the provided config path refers to a directory it can still
be opened and an attempt to read be made. However, as reading
will fail but end-of-file not be reached, we can't rely upon
'feof()' for detecting when to bail out.

As it is a user error to provide a directory as the config path,
that will be detected and deemed an error in a subsequent commit.
2017-11-28 15:33:50 +02:00
Markus Mäkelä
63ae436bd5 MXS-1019: Make peer certificate verification configurable
The new `ssl_verify_peer_certificate` parameter controls whether the peer
certificate is verified. This allows self-signed certificates to be
properly used with MaxScale.
2017-11-14 16:51:34 +02:00
Markus Mäkelä
ff8916046c Add link to documentation in --help output
The link points to the MaxScale 2.1 documentation root.
2017-10-21 14:55:56 +03:00
Markus Mäkelä
eac6d239fc MXS-1468: Fix created monitor serialization
When servers were added to monitors that were created at runtime, the
server list serialization overwrote the original persisted configuration
of the monitor. To solve this problem, the serialization of the server
list and the monitor parameters were combined.
2017-10-11 11:30:58 +03:00
Markus Mäkelä
9280f1a5d7 MXS-1367: Add timeouts for retried queries
The total timeout for the retrying of interrupted queries can now be
configured with the `query_retry_timeout` parameter. It controls the total
timeout in seconds that the query can take.

The actual connection, read and write timeouts of the connector aren't a
good configuration value to use for abstracted queries as the time that it
takes to execute a query can be composed of both connections, reads and
writes. This is caused by the usage of MYSQL_OPT_RECONNECT that hides the
fact that the connector reconnects to the server when a query is
attempted.
2017-10-03 13:03:49 +03:00
Markus Mäkelä
67ef7bd058 MXS-1367: Take mxs_mysql_query into use
The use of a wrapper function allows automated retrying of the queries
without requiring any changes to the code that uses it.
2017-10-03 10:57:12 +03:00
Markus Mäkelä
f1f8a4b5b2 MXS-1367: Retry interrupted queries
The new `query_retries` parameter controls how many times an interrupted
query is retried. This retrying of interrupted queries will reduce the
rate of false positives that MaxScale monitors detect.
2017-10-03 10:57:10 +03:00
Markus Mäkelä
69557c650e Fix stack trace generation
The stack traces weren't logged as the LOG_ALERT priority wasn't enabled
by default. As an alert is intended to be something that must leave a
trace somewhere, and as such, it must not be possible to disable it. For
this reason, it is acceptable to always log the message if the priority is
LOG_ALERT.

Added the -rdynamic linker flag so that all symbols are exported when
linking MaxScale.

As the stack trace is printed in a signal handler, the first attempt
should be to print the stack trace to the standard output. This way the
output is printed before an attempt to use malloc is made when it is
logged to the logfile.
2017-09-30 12:37:40 +03:00
Markus Mäkelä
f06c34f66c MXS-1456: Fix crash on empty script value
If a script variable resolves to an empty string, the replacement attempt
will fail with an out-of-memory error. The following realloc call will
fail as it requires a positive value for the new size.
2017-09-27 10:32:26 +03:00
Johan Wikman
4220e3ca6a MXS-1450 Add more string trimming functions
- trim_leading
- trim_trailing

Implemented trim in terms of trim_leading and trim_trailing
2017-09-26 13:36:10 +03:00
Johan Wikman
bb95074e88 MXS-1450 Add test case for trim 2017-09-26 13:19:09 +03:00
Johan Wikman
9d9cffe4c7 MXS-1377 Always delete the pid-file
Earlier the pid-file was deleted only if the MaxScale startup
succeeded and MaxScale exited in normal fashion.
2017-09-20 10:57:13 +03:00
Johan Wikman
49ab5797a2 MXS-1406 Report CALL operation
Basically it would be trivial to report far more operations
explicitly, but for the fact that the values in qc_query_op_t
currently, quite unnecessarily, form a bitmask.

In 2.2 that is no longer the case, so other operations will be
added there.
2017-09-12 15:38:25 +03:00
Markus Mäkelä
4a42ddfe5f Null-terminate decrypted passwords
The decrypted passwords returned by `decrypt_password` are now properly
null-terminated.
2017-09-12 09:29:26 +03:00
Markus Mäkelä
81202eac89 MXS-1400: Fix crash with OpenSSL 1.1
Added the missing parameter for the RSA key generation function.
2017-09-11 12:50:24 +03:00
Johan Wikman
6794ed907a session_len must be included in assert 2017-09-06 16:41:56 +03:00
Markus Mäkelä
862548666b MXS-1367: Enable MYSQL_OPT_RECONNECT for internal connections
The automatic reconnection feature of the Connector-C was not
enabled. Enabling it should reduce the amount of false positives that the
monitors pick up.
2017-09-04 09:19:20 +03:00
Markus Mäkelä
f9c5578bdd MXS-1384: Remove parameter length limitations
There is no reason to limit configuration parameter names or values to 256
characters.
2017-09-01 22:02:33 +03:00
Markus Mäkelä
d7662a10af MXS-1385: Fix truncation of script variables
The replacement of script variables now uses the maximum string length of
the original and replacement to make sure there's enough buffer space.
2017-09-01 21:51:15 +03:00
Johan Wikman
d0ec6e3762 MXS-1378 Log session id
If the session id is known, it will be logged together with all
messages. If present, the session id appears, enclosed in paranthesis,
right after the message category. E.g.

    2017-08-30 12:20:49   warning: (4711) [masking] The rule ...
2017-09-01 13:22:06 +03:00
Johan Wikman
61a2c960ec MXS-1378 Provide access to current session
Provide access to current session and session id. This will
be used by the logging mechanism for logging the session id
together with messages.
2017-09-01 13:20:20 +03:00
Johan Wikman
eff5e7431a MXS-1378 Provide access to the current DCB in 2.1
Conceptually this is a cherry-pick of commit
67efd1daeabbc398b8a8fbc0cd02c2af26e4cb6c (2.2), but too much has
changed to actually be able to cherry-pick that commit.
2017-09-01 13:20:20 +03:00
Markus Mäkelä
866a15dafa Skip COM_CHANGE_USER for COM_QUIT
As COM_QUIT would terminate the connection, there's no need to initiate
the session reset process. Also make sure all buffers are empty before
putting the DCB into the pool.

Added extra debug assertions for parts of the code that are related to the
COM_CHANGE_USER processing.
2017-08-29 11:15:06 +03:00
Markus Mäkelä
abd99febcf Fix possible crash on show sessions
The function that printed all sessions assumed that all client DCBs had
valid, non-dummy sessions. It is possible that a client with a dummy
session is the list. These sessions should be ignored.
2017-08-25 18:16:07 +03:00
Markus Mäkelä
bc1e2a844c MXS-1374: Add persistpoolmax and persistmaxtime to alter server
The alteration of a server's persistpoolmax and persistmaxtime parameters
appeared to work when in reality it did not change the values.
2017-08-24 09:21:00 +03: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ä
b56594470b Add persistent pool statistics
Added number of times a connection was taken from the pool as well as the
availability of the pool as a percentage of connections taken from the
pool.
2017-08-20 21:54:18 +03:00
Markus Mäkelä
e91c0fe095 Fix insufficient buffer size in maxpasswd
The buffer used to store the hexadecimal string was one byte too
short. This caused the trailing null terminator to be written into
unallocated memory.
2017-08-17 19:43:07 +03:00
Markus Mäkelä
fe580d272f Fix possible out-of-bounds reads in modutil_count_statements
The pointer manipulation in modutil_count_statements assumed that if a
semicolon is found, it is not the last character in the buffer. It also
assumed that the buffer contained at least one readable character.
2017-08-17 15:54:44 +03:00
geaaru
3485a32731 Fix compilation errors/warning with gcc-5.4.0 (#137)
Warning are like this:
 error: ‘delimiter’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
2017-08-15 09:56:22 +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
Markus Mäkelä
f7b8744460 Add more error messages to monitors
When the execution of a query fails, the error reported by the Connector-C
and the server where the query was executed is logged.
2017-08-03 15:42:40 +03:00