4908 Commits

Author SHA1 Message Date
Markus Mäkelä
6b8b19b439 MXS-1220: Add PUT support for /maxscale/ resource
The /maxscale/ resource now supports PUT requests which modify core
parameters. As not all parameters can be changed at runtime, only
modifications to parameters that support runtime configuration are
allowed.
2017-05-24 15:05:11 +03:00
Markus Mäkelä
3fd82ebae6 MXS-1220: Add alter maxscale MaxAdmin command
A set of the core MaxScale parameters can now be altered at runtime. This
set consists of the authentication timeouts and the admin interface
authentication. Other parameters either can't be modified due to internal
limitations or aren't sensible to modify at runtime.
2017-05-24 15:05:11 +03:00
Markus Mäkelä
69be4d263f MXS-1220: Add admin interface parameters to /maxscale/ resource
The admin interface parameters are now a part of the /maxscale/ resource.
2017-05-24 15:05:11 +03:00
Markus Mäkelä
1067fd352c MXS-1220: Add creation and deletion of admin users
Admin users can now be created via the REST API. This allows remote
management of the administrative interface itself.
2017-05-24 15:05:11 +03:00
Markus Mäkelä
ead9059eeb MXS-1220: Add /users/ resource
The /users/ resource shows all user accounts that can be used with
MaxScale. This resource is further split into two resource collections,
/users/inet and /users/unix, which contain the network users and Linux
accounts respectively.
2017-05-24 15:05:10 +03:00
Markus Mäkelä
7fc2d25cf2 MXS-1220: Allow new REST API users to be created
The REST API now uses the same users as MaxAdmin network interface. This
allows them to be created with MaxAdmin.

The next step is to add user creation to the REST API.
2017-05-24 15:05:10 +03:00
Markus Mäkelä
db78eae9a8 MXS-1220: Use thread-local buffer for errors
The runtime error buffer is now a thread-local buffer. This fixes the
build failure on older systems where the compiler doesn't allow
thread-local non-POD objects to be created.

Also expanded some of the JSON validation functions so that they provide
better errors.
2017-05-24 15:05:10 +03:00
Markus Mäkelä
e3c4bd7f72 MXS-1220: Add more validation checks to request JSON
The requests that send a body should define at least a `data` member.

Added a simple test that checks that bad requests are rejected. This test
should be expanded to check that the returned error body contains the
correct members.
2017-05-24 15:05:10 +03:00
Markus Mäkelä
75e7ac35ed MXS-1220: Always build libmicrohttpd
This allows MaxScale to use the PATCH functionality that's only in the
newer versions of the library. It also removes some of the problems that
exist with older systems that don't support all of the options.
2017-05-24 15:05:10 +03:00
Esa Korhonen
dbfd631fed Change session registry to a template class
The template class wraps a HashMap such that only a few operations
are allowed. Usage requires specializing a RegistryTraits class
template for each entry type.
2017-05-19 10:16:37 +03:00
Markus Mäkelä
322983a5f4 Merge branch '2.1' into develop 2017-05-17 13:48:52 +03:00
Markus Mäkelä
f1c790db52 MXS-1220: Add logging priorities to logs resoure
The logging priorities can now be queried and altered.
2017-05-17 10:14:57 +03:00
Markus Mäkelä
05cb49d48a MXS-1220: Add error messages to bad request
Requests now contain a JSON API-conforming, human-readable error message.
2017-05-17 10:14:57 +03:00
Markus Mäkelä
ac29abd679 MXS-1220: Add support for X-HTTP-Method-Override
This header allows clients to override the request method to work around
client library limitations.
2017-05-17 10:14:57 +03:00
Markus Mäkelä
adbf537d80 MXS-1220: Add more information to the /maxscale/ resource
The /maxscale/ resource now has values for most of the configuration
parameters in the [maxscale] section as well as the version, commit and
uptime information.
2017-05-17 10:14:56 +03:00
Markus Mäkelä
551f635f50 MXS-1220: Make the http.hh header public
As it contains utility functions for formatting time_t values to HTTP-date
values, there's no real need to make it an internal header.
2017-05-17 10:14:56 +03:00
Markus Mäkelä
56cf06ee08 Don't use explicit struct initialization
Older GCC versions don't seem to support explicit struct member
initialization.
2017-05-16 11:39:57 +03:00
Markus Mäkelä
17ba824d9f Only close valid sessions
When a session is being closed, the state needs to be checked. If the
session creation failed, the session need to be only freed.
2017-05-16 11:39:57 +03:00
Markus Mäkelä
39ca791a49 Assign service pointer for cloned tee DCBs
When a cloned DCB is created, the service pointer is not copied and it
needs to be manually set in the newSession entry point. This most likely
due to the fact that the cloned DCB always has a different service and it
is not possible to deduce it.

Another option would be to pass the target service as a parameter but the
whole DCB cloning process could use with a rewrite so any modifications
beyond the required minimum are wasteful.
2017-05-15 19:32:02 +03:00
Markus Mäkelä
159c8bb5d1 Listen for only EPOLLIN events with listeners
The example in the epoll(7) manpage only sets the EPOLLIN event flag.

Although it is not explicitly stated that only EPOLLIN events arrive for
sockets that are listening, any other types of events should not be
relevant for listeners.
2017-05-15 19:32:02 +03:00
Markus Mäkelä
4117dcf410 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-05-15 19:32:02 +03:00
MassimilianoPinto
2d7df3eb89 Merge branch 'develop' into MXS-1209 2017-05-15 10:39:07 +02:00
Markus Mäkelä
4050cd20d8 Merge branch '2.1-merge-2.0' into 2.1 2017-05-15 10:36:58 +03:00
Markus Mäkelä
0c9409ae7f Merge branch '2.0' into 2.1-merge-2.0 2017-05-15 10:35:44 +03:00
Markus Mäkelä
5a0d2c54bd MXS-1216: Fix DATETIME(n) value interpretation
The DATETIME(n) values generated by a MariaDB 10.0 server were not
interpreted correctly as the wrong algorithm was used to extract the
values.

DATETIME(0) values still do not work properly and they require further
debugging and changes to the code.
2017-05-15 10:25:12 +03:00
Markus Mäkelä
a12d19591e MXS-1216: Store field real type and length in Avro schema
The avro schema allows custom properties to be defined for the schema
fields. The avrorouter stored extra information about the table into the
schema for later use.

Currently, this information is only generated by the avrorouter
itself. Further improvements to the schema generator scripts need to be
done.
2017-05-15 10:25:12 +03:00
Markus Mäkelä
6b6a7fa4a1 Do checkpoint processing at end of binlog
When the binlog has been read, it needs to be treated as if the
transaction or row limit has been hit. This will cause all tables to be
flushed to disk before the files are indexed.
2017-05-15 10:25:11 +03:00
Markus Mäkelä
8a288110a9 Rename conflicting Avro fields
When a user defined field conflicts with an internal MaxScale field, the
field is suffixed with an underscore.
2017-05-15 10:25:11 +03:00
Markus Mäkelä
926930e241 MXS-1216: Correct CHAR(n) handling
The field length was wrongly compared to less than 255 for two byte field
lengths. In addition to that, the metadata was interpreted in the wrong
way.
2017-05-15 10:25:09 +03:00
Markus Mäkelä
c988735a03 MXS-1216: Fix crash on MariaDB 10.0 DATETIME(n)
When a MariaDB 10.0 DATETIME field with a custom length was defined, the
field offsets weren't calculated properly.

As there is no metadata for pre-10.1 DATETIME types with decimal
precision, the metadata (i.e. decimal count) needs to be gathered from the
CREATE TABLE statement. This information is then used to calculate the
correct field length when the value is decoded.

This change does not fix the incorrect interpretation of the old DATETIME
value. The converted values are still garbled due to the fact that the
value needs to be shifted out of the decimal format before it can be
properly converted.
2017-05-15 10:25:06 +03:00
Markus Mäkelä
ed653ac729 Merge branch '2.0' into 2.1-merge-2.0 2017-05-14 10:25:12 +03:00
Markus Mäkelä
18c71a8ebd MXS-1220: Fix build failure with older GCC
Older GCC versions seem to have a bug where `struct sockaddr_in` pointers
cannot be accessed directly and need to be dereferenced first.
2017-05-14 10:07:16 +03:00
Markus Mäkelä
ffc6dba720 MXS-1220: Fix error on PUT request with no parameters
Whena server was modified and no parameters were given, the operation was
reported as a failure even though it was successful.
2017-05-14 10:06:02 +03:00
Markus Mäkelä
ca7b24f6fa MXS-1220: Allow admin interface to be disabled
Allowing the admin interface to be disabled completely makes it possible
to remove any security concerns that could arise from its use.
2017-05-14 10:06:02 +03:00
MassimilianoPinto
2c346ffc1b MXS-1209: MariaDB GTID registration: handling of skipped binlog files from a Fake ROTATE_EVENT
MariaDB GTID Master registration:
creating missing binlog files (with 4 byes) between current one and the
filename coming from ROTATE_EVENT.

blr_slave_binlog_dump() is also checking possible empty files.
2017-05-12 17:18:38 +02:00
Markus Mäkelä
70db289c60 MXS-1216: Fix DATETIME(n) value interpretation
The DATETIME(n) values generated by a MariaDB 10.0 server were not
interpreted correctly as the wrong algorithm was used to extract the
values.

DATETIME(0) values still do not work properly and they require further
debugging and changes to the code.
2017-05-12 16:50:41 +03:00
Markus Mäkelä
c464bb4ee1 MXS-1216: Store field real type and length in Avro schema
The avro schema allows custom properties to be defined for the schema
fields. The avrorouter stored extra information about the table into the
schema for later use.

Currently, this information is only generated by the avrorouter
itself. Further improvements to the schema generator scripts need to be
done.
2017-05-12 16:47:20 +03:00
Markus Mäkelä
85b49520a2 Do checkpoint processing at end of binlog
When the binlog has been read, it needs to be treated as if the
transaction or row limit has been hit. This will cause all tables to be
flushed to disk before the files are indexed.
2017-05-12 11:30:19 +03:00
Markus Mäkelä
9ed972e1ac Rename conflicting Avro fields
When a user defined field conflicts with an internal MaxScale field, the
field is suffixed with an underscore.
2017-05-12 11:28:07 +03:00
Markus Mäkelä
da2f7b1efe MXS-1216: Correct CHAR(n) handling
The field length was wrongly compared to less than 255 for two byte field
lengths. In addition to that, the metadata was interpreted in the wrong
way.
2017-05-12 11:27:02 +03:00
Markus Mäkelä
30bd869f1c MXS-1216: Fix crash on MariaDB 10.0 DATETIME(n)
When a MariaDB 10.0 DATETIME field with a custom length was defined, the
field offsets weren't calculated properly.

As there is no metadata for pre-10.1 DATETIME types with decimal
precision, the metadata (i.e. decimal count) needs to be gathered from the
CREATE TABLE statement. This information is then used to calculate the
correct field length when the value is decoded.

This change does not fix the incorrect interpretation of the old DATETIME
value. The converted values are still garbled due to the fact that the
value needs to be shifted out of the decimal format before it can be
properly converted.
2017-05-12 11:22:04 +03:00
Esa Korhonen
39da11763b Add test for parse_kill_query() 2017-05-11 12:41:13 +03:00
Esa Korhonen
4add7a14fc parse_kill_query() now also expects the "KILL"
This was originally removed, since it was checking the same word
twice. However, the parsing is clearer with it and the cost is only
paid when the KILL is detected, which is very rare.

Also, fix some incorrect parsing.
2017-05-11 12:06:42 +03:00
Markus Mäkelä
6c583c43dd MXS-1263: Fix timeouts for partially established connections
When the connection timeout was checked for a connection, it assumed that
only valid and fully established sessions should be timed out.

Taking into account the fact that connections can be idle even before the
session is fully established, the check should be expanded to all
connections regardless of the session state.
2017-05-11 09:31:59 +03:00
Esa Korhonen
a0cd067a03 KILL [CONNECTION | QUERY] support, part3
The text-version of "KILL CONNECTION" command is now supported. To keep the
overhead low, only minimal parsing is done on the query. The query
needs to start in the beginning of the mysql-packet, have no comments
and have limited whitespace as the total length of the query is limited.
Both "KILL 123" and "KILL CONNECTION 123" are accepted.

"KILL QUERY 123" is also accepted but not acted on, as it requires larger
changes.
2017-05-10 13:43:28 +03:00
Esa Korhonen
aebe839990 Change session id to 64bit
The server internal session id may be larger than 4 bytes (MariaDB uses 8)
but only 4 are sent in the handshake. The full value can be queried
from the server, but this query is not supported by MaxScale yet. In any
case, both the protocol and MXS_SESSION now have 64 bit counters. Only the
low 32 bits are sent in the handshake, similar to server.
2017-05-10 13:26:25 +03:00
Markus Mäkelä
8e2c7fd952 Merge branch '2.0' into 2.1 2017-05-10 09:12:42 +03:00
Dong Young Yoon
fb5ca52565 TPMfilter now prints latencies of individual statements. 2017-05-09 16:33:17 +03:00
Markus Mäkelä
370cff3528 Remove dependencies on FLEX/BISON targets
The FLEX and BISON targets don't seem to be actual CMake targets which
cause warnings to be emitted.
2017-05-09 16:22:55 +03:00
Markus Mäkelä
157b7f853b MXS-1220: Fix resource self links
The top level resource self links pointed to the collection instead of the
resource itself. The individual resoures now also have a links field that
contains the self link to the resource. This should make navigation of the
API easier as all objects have valid links in them.
2017-05-09 15:32:42 +03:00