Commit Graph

775 Commits

Author SHA1 Message Date
ad1c05b015 Merge branch '2.1' into develop 2017-04-05 11:35:13 +03:00
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
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
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
815780aa4a In cache testrules.c ensure there seems to be at least one thread 2017-04-03 14:20:54 +03:00
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
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
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
4b2d94d0f8 When a transaction has been started, no other checks are needed
If we do check then we will end up turning off the read only flag
that just was set on.
2017-03-28 16:17:13 +03:00
f2734f895e Revert "Update dbfwfilter build configuration"
This reverts commit 09ef292283311483354e6cd628318a5cafd96b2c. The old
syntax is still required on SLES 11.
2017-03-27 10:01:54 +03:00
7bd05d4581 Merge branch '2.1' into develop 2017-03-22 15:20:21 +02:00
d0a9571da0 Introduce new qc_parse() prototype
It is now possible to specify what information the caller is interested
in. With this the cost for collecting information during the query parsing
that nobody is interested in can be avoided.
2017-03-22 11:09:36 +02:00
15a22ec295 Do not use shared PCRE2 match data
The match data needs to be unique for each thread, so for the time
being it is created whenever it is needed. A more performant (although
possibly to a negigible amount) solution would be to have a separate
match data for each thread, but that will have to wait for 2.2.
2017-03-21 15:21:13 +02:00
117534d288 Use JIT in regex matching if available 2017-03-21 15:21:13 +02:00
17057ef340 Use thread specific pcre2 match data
For 2.2 a worker/thread object need to be passed around so that
not everyone need to create their own thread id mechanism.
2017-03-21 15:21:13 +02:00
b81c86f228 A rules object may be empty 2017-03-21 10:35:30 +02:00
039f6e3487 Take static module capabilities into use
The static module capabilities are now used to query the capabilities of
filters and routers. The new RCAP_TYPE_NOAUTH capability is also taken
into use. These changes removes the need for the `is_internal_service`
function.
2017-03-20 11:10:08 +02:00
1736aca7f7 Add module level static capabilities
The static capabilities declared in getCapabilities allows certain
capabilities to be queried before instances are created. The intended use
of this capability is to remove the need for the `is_internal_service`
function.
2017-03-20 11:10:08 +02:00
0e9abda06f NamedServerFilter allow ->master and ->slave, check parameter types
The filter now checks what types of parameters it has been given and
only accepts the old style (match, server) XOR new style (match01,
target01 etc).

Adds support for special targets ->master and ->slave.
Code cleanup.
2017-03-20 09:51:01 +02:00
ed06b6a331 The cache storage storage_inmemory is now the default 2017-03-17 13:45:55 +02:00
9c3aaddda1 Improve cache performance
- Selects are picked out using custom parsing, so if a statement is
  anything else but a SELECT, the cache will never cause the statement
  to be parsed.
- The setting of of the cache parameter `selects` is taken into account.
  If it is `assume_cacheable` then the statement will also not be parsed
  even if it is a SELECT.
2017-03-17 12:22:00 +02:00
6db3cc380b Add cache parameter 'selects' 2017-03-17 09:06:27 +02:00
987a52b398 Further simplify key generation
The original approach was made for RocksDB where it is beneficial
to keep keys of stuff related to each other close to each other.
However, as RocksDB is no longer the primary focus, it just causes
additional cost to dig out the table names.

The key is a 64-bit integer, but crc32 only gives us a 32-bit one.
We create an other 32-bit value by running crc32 over the same SQL,
using the first crc value as adler.

I think that further reduces the chance for clashes:

    uint32_t crc0 = crc32(0, Z_NULL, 0);
    uint32_t crc1;
    uint32_t crc2;

    crc1 = crc32(crc0, "codding", 7) => 1774765869
    crc2 = crc32(crc1, "codding", 7) => 1409592046

    crc1 = crc32(crc0, "gnu", 3)     => 1774765869
    crc2 = crc32(crc1, "gnu", 3)     => 1213798908

Note that the first value is the same, but the second is not.
2017-03-16 18:39:10 +02:00
daf3774329 Use simpler function for calculating hash
Now the key is a 64-bit integer and it is created by the cache
component and can not be unique for the storage.
2017-03-16 16:47:15 +02:00
9dbabb666a Rebase NamedServerFilter to develop
Fix conflicts due to ipv6 changes.
Change SourceHost->m_address to string.
SourceHost generation is now cleaner.
2017-03-15 16:19:53 +02:00
ab7b1c227e Refactor nameserverfilter, now uses filter template
Move most of the functions under the filter or session-classes.
Class definitions moved to a header file. General cleanup. Some features
are still incoming.
2017-03-15 16:19:53 +02:00
32fe220a1b NamedServerFilter multiple "match"-"server"-pairs
The filter now accepts (in addition to the old "match" and "server")
parameters of the form "matchN" and "serverN", where N is a decimal
number with two digits, i.e 01, 02, 03 .. 20. When routing queries,
the regural expressions will be tested one by one, and the servers
from the first match will be added as hints. Also, a single "server"-
setting may contain multiple servers separated by ','. The server
names are not verified to be actual servers, this is up to the user.
2017-03-15 16:19:53 +02:00
c235e181ce Null filter no long requires 'capabilities' argument
- If no capabilities are provided, then the filter will have none.
- Now logs its capabilities as startup (useful for debugging).
2017-03-15 10:26:31 +02:00
a58f944f23 Allow query classifier to initialize itself
The process and thread initialization/finalization of the query
classifier plugins is handled using the process and thread
initialization/finalization functions in the module object.

However, the top-level query classifier will also need to perform
process and thread initialization when transaction boundaries are
detected using regular expressions.
2017-03-15 09:35:15 +02:00
7b3c287ac3 Close sessions in MaxScale core
The core now provides a simple function to close a session. This removes
the need for the modules to directly call the API entry points when the
session should be closed. It is also in line with the style that other
objects, namely the DCBs, use. This makes the new session_close very
similar to dcb_close.
2017-03-14 10:45:10 +02:00
147a1f88eb Merge branch '2.1-ipv6' into develop 2017-03-13 13:18:08 +02:00
d88d02ee95 Fix namedserverfilter source parameter
The `source` parameter was broken by the IPv6 change. Now the filter no
longer uses functions from the core to resolve the network addresses.
2017-03-13 10:45:55 +02:00
37dd561470 Add support for IPv6
Both the listeners and servers now support IPv6 addresses.

The namedserverfilter does not yet use the new structures and needs to be
fixed in a following commit.
2017-03-13 10:45:55 +02:00
415001a4cd Merge branch '2.1' into develop 2017-03-09 10:02:36 +02:00
e1a1959bc2 Replace strerror_r with mxs_strerror
The mxs_strerror function requires no local buffer, thus making it simpler
and cleaner to use.
2017-03-09 09:36:57 +02:00
d7e48f93bb NamedServerFilter PCRE2 matching and refactoring
Change to modutil_extract_SQL(), add pcre2_data to filter session.
The pattern is now jit-compiled for maximum speed. Move general
pcre2 error printing to a function and macro. Add instance-level
statistics so the filter always prints diagnostic info. Add a mention
of PCRE2 to release notes.
2017-03-08 14:01:38 +02:00
55f038bc1f RegexHintFilter (namedserverfilter) now uses PCRE2
Also, changed the Filter struct to a class and moved code to class
methods. Renamed to .cc. Modifications in progress.
2017-03-08 13:48:11 +02:00
5975422473 Change namedserverfilter to C++, reorder code, cleanup
Functionality unchanged.
2017-03-08 13:48:11 +02:00
b1521e0545 Log the use of prepared statements
If cache decisions should be logged, we log the presence of
prepared statements as they currently are the primary source
for the cache not caching.
2017-03-07 15:45:29 +02:00
09ef292283 Update dbfwfilter build configuration
The filter now uses a more recent syntax to declare the function name
prefixes. This removes a build warning.
2017-03-03 18:44:58 +02:00
da5edadcda MXS-1150: Do not cache non-cachable functions
The resultset of SELECTs that use functions whose result will
always vary or whose result depend upon the user executing the
query should not be cached. The list of functions is the same
as that specified for the query cache of MariaDB:
https://mariadb.com/kb/en/mariadb/query-cache/
2017-03-02 13:13:31 +02:00
923ed9329d Add better cache debugging
Now the statement and the decision is logged. Easier to figure
out why something is or is not cached.
2017-03-02 12:35:53 +02:00
4902ed7cf5 MXS-1137: Do not cache when [user|system] vars are used
If user or system variables are used in a SELECT statement, then
the result will not be cached. That ensures that the wrong result
will not be returned.
2017-03-02 12:35:53 +02:00
aa51528481 Factor out caching decision making 2017-03-02 12:35:53 +02:00
1d48a24d6a MXS-1149: removed send_ok_upstream() routine
send_ok_upstream is no longer in use, just remove it
2017-03-01 14:53:37 +01:00
c9592aa05e MXS-1149: maxrows should return empty resultset instead of OK
maxrows returns empty resultset instead of OK.

The response with coulmndefs is sent then an EOF without flags is added.

Limitations: in case of MULTI_RESULT sets only the first one coulmndefs
is sent with EOF
2017-03-01 14:48:35 +01:00
eefa63be33 Use qc_query_is_type 2017-03-01 14:46:35 +02:00
82049b8ed1 Use cache as long as a trx only performes reads
As before, the cache will be used if there is no ongoing transaction
(includes autocommit being on), or if there is an explicitly read-
only transaction.

In addition, the cache will be used and populated during any other
transaction as long as only pure read statements are executed. After
first non-read statement, the use of the cache is disabled.
2017-03-01 11:08:52 +02:00
f1ea0b03d1 Change order of testing whether caching should be used
First we check the transaction state, then we check whether it is
a SELECT. In the next step, we will widen the cases when caching
is used.
2017-03-01 11:08:52 +02:00
7bf7b1a47a Simplify logic for when deciding whether to cache
The autocommit state is now included in the result returned
from session_trx_is_active(), so it need not be checked separately.

This is preparatory work for MXS-1136 that will change the approach
so that the cache is used and populated in a non readonly transaction
*until* the first non-read statement is encountered.
2017-03-01 11:08:52 +02:00