35 Commits

Author SHA1 Message Date
Johan Wikman
fbb79adc52 MXS-1992 Address review issues 2018-08-08 09:17:15 +03:00
Johan Wikman
1b521b16a9 MXS-1992 Move QC json "parsing" to query_classifier.cc 2018-08-08 09:17:15 +03:00
Johan Wikman
dae6cf0648 MXS-1992 Allow the setting/getting of cache size at runtime 2018-08-08 09:16:19 +03:00
Johan Wikman
bb77ae7b95 MXS-1992 Rename internal/query_classifier.h to .hh 2018-08-08 09:16:19 +03:00
Johan Wikman
90569e3a28 MXS-1992 Expose qc stats in threads info
In principle it would be better if the qc information were
obtained via a specific query_classifier resource. However,
there are multiple problems with that (e.g. the qc has no way
of safely accessing information of another thread) and hence
the worker specific qc cache statistics is reported as part of
the worker statistics.
2018-08-08 09:16:19 +03:00
Johan Wikman
25536af91f MXW-1992 Update size when inserting 2018-08-03 07:33:12 +03:00
Johan Wikman
e637acd0a2 MXS-1992 Canonicalize using std::string
Significantly reducing the number of allocations done.
2018-08-02 14:16:53 +03:00
Johan Wikman
ef7fa7f879 MXS-1992 Implement cache size control
The cache now enforces the defined maximum size by evicting some
entries in case the insertion of a new entry would cause the max
size to be exceeded. Currently the eviction algorithm simply
removes a random element.
2018-08-01 11:10:34 +03:00
Johan Wikman
466e8a923c MXS-1992 Handle 'query_classifier_cache_size' parameter
No effect yet on the caching.
2018-08-01 11:10:34 +03:00
Johan Wikman
18180cd4ac MXS-1624 Also explicit parsing should utilize the cache 2018-08-01 11:10:34 +03:00
Esa Korhonen
f7538db3b7 Fix release-mode compile error
Caused by merging 2.2.
2018-07-16 15:40:08 +03:00
Johan Wikman
f2b8487577 MXS-1624 Add configuration parameter
With the global configuration parameter 'query_classifier_cache'
the query classification cache can be turned on. At the moment it
does not matter what value it has; its presence simply enables the
caching.

Eventually you will be able to specify how much memory the cache
is allowed to consume.
2018-07-06 12:12:31 +03:00
Johan Wikman
e7913cc022 MXS-1624 Update qc_setup() prototype
Now takes a structure that, if present, enables the query
classification caching and specifies the properties of the
cache.

For the time being no actual properties are yet available.
2018-07-06 12:12:31 +03:00
Johan Wikman
b7c5abf73b MXS-1624 Discard QC result if the sql mode has changed
The sql mode affects the result of the query classification.
Consequently, we cannot use the cached result if it was generated
when the sql mode was something else than what it currently is.
2018-07-06 12:12:31 +03:00
Johan Wikman
1be9528227 MXS-1624 Provide initial implemenation of QC caching
The mapping from a canonical statement to the query classification
result is maintained by the class QCInfoCache of which there exist
an instance per thread. That way no locking is needed but the
information will be cached multiple times (but that is a smaller
price to pay). Currently the information is stored in a regular
std::unordered_map, which means that the consumed amount of
memory will just keep on growing unless the number of canonical
statements used by clients happens to have an upper bound.

The LRU cache (that provides means for putting a bound on the
amount of memory used and number of items) used in the cache filter
will be generalized and be taken into use here as well.

The key is now the canonical statement itself, which means that
a fair amount of memory will be used. To preserve memory it might
make sense to use a hashed value instead, although that at least
in principle opens up the possibility for unintended collisions.

This feature will also be made configurable.
2018-07-06 12:12:31 +03:00
Johan Wikman
d01db42679 MXS-1624 Clean up query_classifier.cc
Minor cleanup:
- Unit variables places in anonymous namespace.
- Unit variables accessed via this_unit struct.

This is the first commit of many where the mapping from canonical
statement to query classification result is introduced.

The mapping is placed above the actual query classifier, so that all
query classifiers will benefit from it.

The mapping will be maintained by thread so that there will not be
any synchronization issues. Further, initially a simple map without
upper boundary will be used; if this is found to provide measurable
benefits, the map will then be replaced with an LRU mechanism so
that it becomes possible to specify just how much memory the mapping
may use.
2018-07-06 12:12:31 +03:00
Johan Wikman
cc0299aee6 Update change date of 2.3 2018-06-25 10:07:52 +03:00
Johan Wikman
45bda0f72e MXS-1936 Make qc_mysqlembedded compatible with qc_sqlite
qc_mysqlembedded must also be updated to handle the new type
QUERY_TYPE_DEALLOC_PREPARE. Some adjustements were also needed
elsewhere.
2018-06-21 12:51:47 +03:00
Markus Mäkelä
cddcc6d7d5
MXS-1896: Distinct LOAD DATA LOCAL INFILE from LOAD DATA INFILE
The two operations return different types of results and need to be
treated differently in order for them to be handled correctly in 2.2.

This fixes the unexpected internal state errors that happened in all 2.2
versions due to a wrong assumption made by readwritesplit. This fix is not
necessary for newer versions as the LOAD DATA LOCAL INFILE processing is
done with a simpler, and more robust, method.
2018-06-04 15:17:48 +03:00
Markus Mäkelä
396b81f336 Fix in-source builds
The internal header directory conflicted with in-source builds causing a
build failure. This is fixed by renaming the internal header directory to
something other than maxscale.

The renaming pointed out a few problems in a couple of source files that
appeared to include internal headers when the headers were in fact public
headers.

Fixed maxctrl in-source builds by making the copying of the sources
optional.
2017-11-22 18:40:18 +02:00
Markus Mäkelä
895d950da0 Format all source files with Astyle
Formatted all source files Astyle.
2017-09-28 07:04:21 +03:00
Johan Wikman
a2d0d24b2c Merge branch '2.1' into develop
Bringing in MXS-1406
2017-09-13 10:02:37 +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
Johan Wikman
ad4e8dad94 MXS-1364 Drop the usage field
But for the most trivial statements did not really provide
useful information.

The arguments of the "function" '=' are now reported.
2017-08-24 09:58:18 +03:00
MassimilianoPinto
cb57e10761 Develop merge
Develop merge
2017-06-29 15:34:22 +02:00
Johan Wikman
dcfe118457 MXS-1249: Qc, the server version is passed as a single integer
To be compatible with how the version is managed elsewhere.
2017-06-21 13:28:59 +03:00
Johan Wikman
1034cc51be MXS-1249: Qc, allow setting the server version
In the case of qc_sqlite, the server version may affect how statements
are parsed.
2017-06-21 13:28:59 +03:00
Johan Wikman
f546a17e77 Update change date of 2.2 2017-06-01 10:24:20 +03:00
Johan Wikman
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
Johan Wikman
1b418b517c Custom parsing for trx state is now the default
The possibility for turning on query_classifier parsing using
an environment variable is retained as a backdoor for sorting
out potential issues.
2017-03-17 12:30:20 +02:00
Johan Wikman
5e39268e37 Remove support for TrxBoundaryMatcher
For the general case, regex matching simply will not do. The
regex becomes so hairy so it turns write-only, i.e. unmaintainable.
Regex matching is also slower than a handwritten custom parser.
2017-03-15 10:39:26 +02:00
Johan Wikman
87d84bc81c Ignore implicit commits 2017-03-15 09:35:15 +02:00
Johan Wikman
35132f3afe Take TrxBoundaryMatcher into use
The code that used to be in query_classifier.cc is now in
trxboundarymatcher.cc.
2017-03-15 09:35:15 +02:00
Johan Wikman
a85ce2e915 Take TrxBoundaryParser into use 2017-03-15 09:35:15 +02:00
Johan Wikman
ddca19767c Compile query_classifier.c as C++
In preparation for some modifications that are easier done using
C++.
2017-03-15 09:35:15 +02:00