4609 Commits

Author SHA1 Message Date
Johan Wikman
22b39daf06 Make EPOLLET the default
The whole worker thread mechanism assumes EPOLLET and non-blocking
descriptors, so that should be the default.

TODO: In debug mode, check that the provided file descriptor indeed
      is non-blocking.
2017-04-20 13:51:16 +03:00
Johan Wikman
56c132f273 Move poll_[add|remove]_dcb to dcb.c 2017-04-20 13:51:16 +03:00
Johan Wikman
85faca74f7 Move DCB specific event handling to dcb.c 2017-04-20 13:51:16 +03:00
Johan Wikman
b11b848e66 Move all statistics gathering to poll_waitevents().
The handler callback should now return a bitmask with bits set
according to what it did when it was called. That way the actual
statistics gathering can be done in poll_waitevents() and the
handler need not be aware of any thread structs.

Actually, the only thing that needs any assistance is accept handling,
because in poll_waitevents() we do not know whether a READ event
relates to a listening or a normal socket, that is, should the
event be counted as an accept or as a read.
2017-04-20 13:51:16 +03:00
Johan Wikman
dec2bcdab2 Change DCB to MXS_POLL_DATA in statistics
Only the address of the data is used, so the code need not be
DCB specific.
2017-04-20 13:51:16 +03:00
Johan Wikman
8500a980ac Update events bitmap in poll_waitevents
This information is also generally applicable for all
poll event handlers, not just DCB. The state of the thread
is already set in poll_waitevents().
2017-04-20 13:51:16 +03:00
Johan Wikman
1e47c4aa50 Move stats-collecting to poll_waitevents()
If the stats-collecting is performed in poll_waitevents() then it
will be collected for all kinds of sockets (when other that DCB
ones can be added).
2017-04-20 13:51:16 +03:00
Johan Wikman
63141bb191 WIP: Allow the adding of any fds to the poll set
This is just a first step in a trial that will allow the addition
of any file descriptor to the general poll mechanism and hence
allow any i/o to be handled by the worker threads.

There is a structure

  typedef struct mxs_poll_data
  {
      void (*handler)(struct mxs_poll_data *data, int wid, uint32_t events);
      struct
      {
          int id;
      } thread;
  } MXS_POLL_DATA;

that any other structure (e.g. a DCB) encapsulating a file descriptor must
have as its first member (a C++ struct could basically derive from it).

That structure contains two members; 'handler' and 'thread.id'. Handler is a
pointer to a function taking a pointer to a struct mxs_poll_data, a worker thread
if and an epoll event mask as argument.

So, DCB is modified to have MXS_POLL_DATA as its first member and 'handler'
is initialized with a function that *knows* the passed MXS_POLL_DATA can
be downcast to a DCB.

process_pollq no longer exists, but is now called process_pollq_dcb. The
general stuff related to statistics etc. will be moved to poll_waitevents
itself after which the whole function is moved to dcb.c. At that point,
the handler pointer will be set in dcb_alloc().

Effectively poll.[h|c] will provide a generic mechanism for listening on
whatever descriptors and the dcb stuff will be part of dcb.[h|c].
2017-04-20 13:51:16 +03:00
Markus Mäkelä
5704ae5ffd Allow paths to be created if they don't exist
A module can now declare a path parameter for a directory that does not
yet exist. If the directory does not exist, MaxScale will create the
directory with the requested permissions.
2017-04-20 13:26:16 +03:00
MassimilianoPinto
e4941044aa MXS-1209: blr_slave_query cleanup
New routine: blr_handle_set_stmt is in use
2017-04-19 18:04:41 +02:00
Johan Wikman
c3cfc86a7b Merge branch '2.1' into develop 2017-04-19 18:19:13 +03:00
Johan Wikman
d03b059107 Cache length of buffered data
If a complete response is delivered in many buffers, then calling
gwbuf_length() whenever you need the complete size starts to hurt.
By caching the length of the data received sofar and by updating
the length in clientReply(), gwbuf_length() will be called exactly
once for each buffer(chain) delivered to routeQuery().
2017-04-19 18:15:56 +03:00
Johan Wikman
27e97a546d Remove superfluous logging
Just because of a debug build you do not want the transaction
parser to log.
2017-04-19 18:15:56 +03:00
MassimilianoPinto
aa3559c6e9 MXS-1209: blr_slave_query cleanup
new routine: blr_handle_show_stmt
2017-04-19 16:02:07 +02:00
MassimilianoPinto
e09f1db4a6 MXS-1209: blr_slave_query cleanup
new routine: blr_handle_maxwell_stmt
2017-04-19 14:11:59 +02:00
Johan Wikman
3b4fdbcf32 Fix compilation error 2017-04-18 14:53:12 +03:00
Markus Mäkelä
a54d6fe816 Add connector plugindir to help output
The output now displays the connector directory.
2017-04-13 17:57:52 +03:00
MassimilianoPinto
f4a5134a83 MXS-1212: use res.length for buffer length instead of computing the size of the whole buffer chain
This reduces CPU usage and decreases the response time for result sets
with many rows.
2017-04-07 12:16:50 +02:00
Esa Korhonen
dfede32266 Add cast int->uint64_t
Needed for compiling on Centos6.
2017-04-06 13:00:30 +03:00
Esa Korhonen
9e8ddc842c Fix leaks in testconfig 2017-04-06 12:51:09 +03:00
MassimilianoPinto
e0a12820b6 Binlogserver sends GTID_LIST Fake Event when a MariaDB 10 slave connects with GTID
Now sending GTID_LIST Fake Event when a MariaDB10 Slave connects with
GTID
2017-04-06 09:04:19 +02:00
Markus Mäkelä
ce6b52ab39 Rename schemarouter internal functions
Renamed the functions to better describe what they do.
2017-04-06 09:22:21 +03:00
Markus Mäkelä
c37c5abfeb Use collectable resultset type for database mapping
When the databases are mapped, it is desirable to get the complete
response in one contiguous buffer. This removes the need to manually
process the partial packets in the router code.
2017-04-06 09:22:21 +03:00
Markus Mäkelä
2310381465 Make variables of Backend private
The variables are no longer directly manipulated by the session level
code.
2017-04-06 09:22:21 +03:00
Markus Mäkelä
0d7f987598 Move state checks inside the Backend class
The class now has methods to query its internal state.
2017-04-06 09:22:20 +03:00
Esa Korhonen
15951423d8 Fix memory errors in test_poll and test_queuemanager
test_poll was calling poll_init() two times since it's already included in
init_test_env().

test_queuemanager was missing a bunch of frees. This doesn't fix it completely,
but removes most of the leaks and valgrind errors.
2017-04-05 17:37:21 +03:00
Esa Korhonen
b1f66d21c8 Fix valgrind-errors in test_filter and test_modutil
Reduces valgrind clutter quite a bit.
2017-04-05 15:04:36 +03:00
Markus Mäkelä
ad1c05b015 Merge branch '2.1' into develop 2017-04-05 11:35:13 +03:00
Esa Korhonen
2d987b25b2 Fix test_dcb
Set threadcount to one, don't check validity after freeing.
2017-04-05 10:49:43 +03:00
Esa Korhonen
e0a98f6539 Fix calls of pcre2_substitute
If the output buffer given to pcre2_substitute is too small, an error
value is written to the last parameter (output length). That value
should not be used for calculations. This patch gives a copy as
parameter instead.

Coincidentally, this commit fixes the crashes of query classifier tests.

Also, increase buffer growth rate in utils.c.
2017-04-04 16:19:21 +03:00
Esa Korhonen
dca086571b TestMaxScalePCRE2: Fix memory leaks
Not really leaks, but this reduces needless clutter in the valgrind
output.
2017-04-04 16:18:47 +03:00
Markus Mäkelä
872f69b681 Also check IPv6 mapped IPv4 addresses as IPv4
If a client connects from an IPv4 address, but the listener listens on an
IPv6 address, the client IP will be a IPv6 mapped IPv4 address
e.g. ::ffff:127.0.0.1. A grant for an IPv4 address should still match an
IPv6 mapped IPv4 address.
2017-04-04 15:28:39 +03:00
Markus Mäkelä
9f14f3659f Only check user permissions on startup
When users were loaded, the permissions for the service user were
checked. The conditional that makes sure the check is executed only at
startup was checking the listener's users instead of the SQLite handle
which caused all reloads of users to check the permissions.
2017-04-04 15:28:39 +03:00
Markus Mäkelä
860b14526c Fix mxs_mysql_is_result_set
The function assumed that the packet payload was always at least two
bytes.
2017-04-04 15:28:39 +03:00
Markus Mäkelä
1ff83150f0 Revert "Route statements in larger batches"
This reverts commit f3c83770903151a0a3b53593c3e05fa0af94cd5f. The
functionality was used implicitly by modules that declare the
RCAP_TYPE_CONTIGUOUS_OUTPUT capability.
2017-04-04 09:56:51 +03:00
MassimilianoPinto
0c3f9ffa2e Maxrows: documentation update and use of MXS_MODULE_PARAM_SIZE for max_resultset_size parameter
max_resultset_size parameter now uses MXS_MODULE_PARAM_SIZE and
config_get_size

Documentation change follows the change.
2017-04-04 08:43:55 +02:00
Esa Korhonen
1fb8cde5d8 NamedServerFilter: Add HINT_ROUTE_TO_ALL support
This was already supported by HintRouter. The tag for the MaxScale
config file is "->all". Also add note to Documentation and reformat
it a bit.
2017-04-04 09:40:04 +03:00
Johan Wikman
8d2d6d8721 Join threads to prevent leaks 2017-04-03 14:20:54 +03:00
Johan Wikman
815780aa4a In cache testrules.c ensure there seems to be at least one thread 2017-04-03 14:20:54 +03:00
Markus Mäkelä
0f2f9d48b7 Improve maxadmin help messages
The help messages are now more descriptive and have usage information in
them. This should help users use the commands without relying on the
online documentation.
2017-04-03 12:09:59 +03:00
Markus Mäkelä
e650597eb5 MXS-1200: Document and increase line length limitations
The line length limitation is now increased to 16384 bytes. It is now
clearly documented in the limitations document.

The configuration parser now uses memory from the heap instead of the
stack. This should remove any problems caused by the larger line length.
2017-04-03 12:07:45 +03:00
Markus Mäkelä
f3c8377090 Route statements in larger batches
The RCAP_TYPE_STMT_OUTPUT is not used in its previous form. It can be
altered to route only complete packets back to the client. This allows
routers to do safer parsing on the results.
2017-04-03 12:07:45 +03:00
Esa Korhonen
a362bd0024 Add parameter backend_connect_attempts to monitor
This number (defaults to 1) sets how many times mon_connect_to_db
will try to connect to a backend before returning an error. Every
connection attempt may take backend_connect_timeout seconds to
complete.

Also refactored code a bit. Renamed mon_connect_to_db to
mon_ping_or_connect_to_db, since it does not connect if the connection
is already alive.
2017-04-03 09:56:22 +03:00
Esa Korhonen
657d79470c Update NamedServerFilter documentation
The document is now up to date with the rewrite. Also added an assert
to enforce a minimum number of allowed match-target pairs.
2017-04-03 09:49:12 +03:00
MassimilianoPinto
e6d2c96f5b MXS-1211: maxrows should be configurable to return error when limit has been exceeded
New parameter added to maxsrows filter:
max_resultset_return=empty|error|ok
Default, 'empty' is to return an empty set, as the current
implementation.
'err' will return an ERR reply with the input SQL statement
'ok' will return an OK packet
2017-03-31 14:26:44 +02:00
Markus Mäkelä
cbc1e864d9 Use RFC 3986 compliant addresses in log messages
When log messages are written with both address and port information, IPv6
addresses can cause confusion if the normal address:port formatting is
used. The RFC 3986 suggests that all IPv6 addresses are expressed as a
bracket enclosed address optionally followed by the port that is separate
from the address by a colon.

In practice, the "all interfaces" address and port number 3306 can be
written in IPv4 numbers-and-dots notation as 0.0.0.0:3306 and in IPv6
notation as [::]:3306. Using the latter format in log messages keeps the
output consistent with all types of addresses.

The details of the standard can be found at the following addresses:

     https://www.ietf.org/rfc/rfc3986.txt

     https://www.rfc-editor.org/std/std66.txt
2017-03-31 14:12:58 +03:00
Markus Mäkelä
c2857b976a Add collectable resultset buffer type
The new type allows routers to send queries and get complete result sets
as a response. This allows the routers to easily send commands that create
result sets and which are parsed by the router.

Currently only the schemarouter benefits from this new capability as it
generates the database mappings by parsing the output of a SHOW DATABASES
query.
2017-03-31 14:12:02 +03:00
Markus Mäkelä
5c1c89c835 Remove unused buffer types
A part of the buffer types weren't used or provided no real functionality.
2017-03-31 14:12:02 +03:00
Markus Mäkelä
c59ed30da1 Simplify error handling
The error handlers are now simpler as the Backend class handles the
closing of the connections.
2017-03-31 14:12:02 +03:00
Markus Mäkelä
a3396a06b8 Fix shared_ptr usage
The std::shared_ptr type was used instead of std::tr1::shared_ptr. A NULL
pointer was also implicitly cast into a Backend pointer which caused
compilation problems on some platforms with the tr1 version of shared_ptr.
2017-03-31 14:12:02 +03:00