433 Commits

Author SHA1 Message Date
Johan Wikman
348143eb6c Remove too aggressive assert 2016-10-19 11:00:26 +03:00
Markus Makela
48b1583830 Add FindJansson.cmake
Added find_package module for CMake which locates the Jansson libraries
and headers. This will make dependency checking easier and prevents build
failures due to missing dependencies.
2016-10-19 09:35:09 +03:00
Johan Wikman
1333da0712 Remove skygw_utils.h
The general purpose stuff in skygw_utils.h was moved to utils.h
and the corresponding implementation from skygw_utils.cc to utils.c.
Includes updated accordingly.

Skygw_utils.h is now only used by log_manager and by mlist, which
is only used by log_manager. Consequently, skygw_utils.h was moved
to server/maxscale.

Utils.h needs a separate overhaul.
2016-10-14 19:50:54 +03:00
Johan Wikman
03dbc6df80 Remove dependency on skygw_utils.h
- STRERROR_BUFLEN moved to cdefs.h and renamed to MXS_STRERROR_BUFLEN.
  Better would be to provide a 'const char* mxs_strerror(int errno)'
  that would have a thread specific buffer for the error message.
- MIN and MAX also moved to defs.h as MXS_MIN and MXS_MAX.
- Now only mlist.h of the headers depend upon skygw_utils.h.
2016-10-14 15:42:02 +03:00
Johan Wikman
bff2cfb7e5 Remove skygw_types.h
Some stuff moved to maxscale/utils.h. Further cleanup still needed.
2016-10-14 14:24:31 +03:00
Johan Wikman
0800bf4a59 Rename skygw_debug.h to debug.h
Also remove unneded includes in debug.h
2016-10-14 13:48:10 +03:00
Johan Wikman
1a978be6b6 Cleanup header files
- All now include maxscale/cdefs.h as the very first file.
- MXS_[BEGIN|END]_DECLS added to all C-headers.
  Strictly speaking not necessary for private headers, but
  does not hurt either.
- Include guards moved to the very top of the file.
- #pragma once added.
2016-10-14 11:54:37 +03:00
Johan Wikman
2fe58ebe5b Move test_utils.h to server/core/test 2016-10-13 22:59:39 +03:00
Johan Wikman
d04cb54b9f maxscale/maxscale_pcre2.h renamed to maxscale/pcre2.h 2016-10-13 22:59:39 +03:00
Johan Wikman
76430e060f maxconfig.h renamed to config.h 2016-10-13 22:59:39 +03:00
Johan Wikman
3a18b64bdd mysql_client_server_protocol.h moved.
Moved to include/maxscale/protocol/mysql.h
2016-10-13 22:59:39 +03:00
Johan Wikman
c433d11b39 Module private headers moved to modules 2016-10-13 22:59:39 +03:00
Markus Makela
1895c04fc6 Fix luafilter build failure
The luafilter included a non-existent header file <maxscale/string.h> when
it needed <string.h>.
2016-10-13 22:33:03 +03:00
Johan Wikman
e41589be10 Move headers from server/include to include/maxscale
- Headers now to be included as <maxscale/xyz.h>
- First step, no cleanup of headers has been made. Only moving
  from one place to another + necessary modifications.
2016-10-13 16:19:20 +03:00
Johan Wikman
7e058a327f Add test for cache use-rule parsing 2016-10-11 19:56:01 +03:00
Johan Wikman
4a7040c308 MXS-879: Match users properly.
If account wildcards - % - are used, the string is changed
into a pcre regular expressions and compared using that.
2016-10-11 19:55:29 +03:00
Johan Wikman
69cf3cf93a Extend error message when query cannot be parsed 2016-10-11 19:55:29 +03:00
Johan Wikman
56f0edb247 Cache: Add possibility to parse rules from string
To be used in test program.
2016-10-06 14:58:42 +03:00
Markus Makela
e54c40ca7b Merge branch 'pull-102' into develop 2016-10-05 10:00:09 +03:00
Markus Makela
fbf5c331f1 Merge branch '2.0.1' into develop 2016-10-03 15:21:04 +03:00
Johan Wikman
b42231e5d4 storage_rocksdb: Clearer error when db in use 2016-09-30 12:45:02 +03:00
Johan Wikman
45073ebd73 cache: Pick out default db when connecting with database 2016-09-30 11:32:38 +03:00
Johan Wikman
087338910e storage_rocksdb: Store version to database
The storage_rocksdb version is now stored to the database. That will
ensure that should the format (key content, length, etc.) change, we
can will detect whether a database is too old and take action.
2016-09-29 14:06:23 +03:00
Johan Wikman
b9c956dda9 cache: Include the databases in the key
The databases targeted by a query are now included in the key.
That way, two identical queries targeting a different default
database will not clash.
Further, it will mean that queries targeting the same databases
are stored near each other, which is good for the performance.
2016-09-29 11:28:01 +03:00
Johan Wikman
7732070546 cache: Add 'use' rules handling
Currently onyl the user name is matched, eventually it should
probably be possible to indicate the network as well, or only
the network.
2016-09-29 11:26:12 +03:00
Johan Wikman
0478c3cc83 cache: Add table and query matching 2016-09-28 19:38:11 +03:00
Johan Wikman
7f24f12cfc cache: Update documentation and add rule handling
The concept of 'allowed_references' was removed from the
documentation and the code. Now that COM_INIT_DB is tracked,
we will always know what the default database is and hence
we can create a cache key that distinguises between identical
queries targeting different default database (that is not
implemented yet in this change).

The rules for the cache is expressed using a JSON object.
There are two decisions to be made; when to store data to the
cache and when to use data from the cache. The latter is
obviously dependent on the former.

In this change, the 'store' handling is implemented; 'use'
handling will be in a subsequent change.
2016-09-28 19:38:11 +03:00
Johan Wikman
20b57b1577 cache: Remove default db only is use db succeeds 2016-09-28 19:38:11 +03:00
Johan Wikman
a4aa03a1fb cache: Explicitly handle COM_INIT_DB
With this change, the cache will be aware of which default database
is being used. That will remove the need for the cache parameter
'allowed_references' and thus make the cache easier to configure
and manage.
2016-09-23 19:06:14 +03:00
Markus Makela
e618370cdb MXS-875: Fix regexfilter matching
The return values of pcre2_match are now properly handled. A positive
match is a return value which is greater than or equal to zero. This fix
should give a small performance boost to as memory is no longer needlessly
allocated.
2016-09-23 14:43:03 +03:00
Johan Wikman
ac43580ce8 cache: storage_args renamed to storage_options 2016-09-22 14:22:45 +03:00
Johan Wikman
4d1eb6fe85 cache: Process response to COM_QUERY
When a query has been sent to a backend, the response is now
processed to the extent that the cache is capable of figuring
out how many rows are being returned, so that the cache setting
`max_resultset_rows` can be processed.

The code is now also written in such a manner that it should be
insensitive to how a package has been split up into a chain of
GWBUFs.
2016-09-20 10:41:02 +03:00
Johan Wikman
7e2a21de9e Cache: Assume we need to handle one packet at a time 2016-09-20 10:41:02 +03:00
Markus Makela
b60f000a4c Format tpmfilter
The filter is now formatted with the astyle config.
2016-09-15 12:21:54 +03:00
Markus Makela
08d2529312 Merge branch 'develop' into pull-102 2016-09-15 10:26:53 +03:00
Johan Wikman
b138a43ab8 cache: 64KiB is more appropriate default than 64MiB 2016-09-14 14:39:27 +03:00
Johan Wikman
8a12bd6487 Implement parameter handling for cache 2016-09-14 14:11:27 +03:00
Johan Wikman
9790eaaf20 storage_rocksdb explicity dependent on RocksDB 2016-09-13 11:45:03 +03:00
Johan Wikman
2cb6bdcf67 Fix typo on build variable 2016-09-13 11:45:03 +03:00
Johan Wikman
293b125e12 Define namespace function using explicit scope 2016-09-13 11:45:03 +03:00
Johan Wikman
cf86b80584 Link storage_rocksdb with libraries required by RocksDB 2016-09-13 11:45:03 +03:00
Johan Wikman
7fe981c22f Cache: Handle TTL manually
The RocksDB TTL database only honours the TTL when the database
is compacted. If the database is not compacted, stale values will
be returned until the end of time.

Here we utilize the knowledge that the TTL is stored after the
actual value and use the root database for getting the value,
thereby getting access to the timestamp.

It's still worthwhile using the TTL database as that'll give
us compaction and the removal of stale items.
2016-09-13 11:45:03 +03:00
Johan Wikman
a96d215aa0 Make it possible to include internal RocksDB headers
The RocksDB storage will need to refer to some internal
RocksDB files.
2016-09-13 11:45:03 +03:00
Johan Wikman
a76c05e8db MXS-797 Add initial version of RocksDB storage
RocksDB is cloned from github and version v4.9 (latest at the time of
this writing) is checked out.

RocksDB can only be compiled as C++11, which means that RocksDB and hence
storage_rocksdb can be built only if the GCC version is >= 4.7.

The actual storage implementation is quite straightforward.

- The key is a SHA512 of the entire query. That will be changed so that
  the database/table name is stored in the beginning of the key unhashed
  as that will cause cached items from the same table to be stored
  together. Assumption is that if you access something from a particular
  table, chances are you will access something else as well.
- When the SO is loaded, the initialization function will created a
  subdirectory storage_rocksdb under the MaxScale cache directory.
- For each instance, the RocksDB cache is created into a directory
  whose name is the same as the cache filter name in the configuration
  file, under that directory.
- The storage API's get and put functions are then mapped directly on
  top of RockDB's equivalent functions.
2016-09-13 11:45:03 +03:00
Markus Makela
0c55385525 Merge branch 'develop' of git://github.com/dongyoungy/MaxScale into pull-102
Merged and fixed merge problems.
2016-09-13 10:47:05 +03:00
Markus Makela
cbf3ae0f8f Move gatekeeper and ccrfilter into the core
The filters should be a part of the core package.
2016-09-12 15:55:27 +03:00
Markus Makela
0d157b16f8 Fix luafilter build failure
The createInstance used the old signature.
2016-09-12 06:50:07 +03:00
Johan Wikman
c05f6b394f Change 0 to NULL 2016-08-29 10:02:37 +03:00
Johan Wikman
9a6a528a3f MXS-797 Add initial version of cache filter
The cache filter consists of two separate components; the cache
itself that evaluates whether a particular query is subject to
caching and the actual cache storage. The storage is loaded at
runtime by the cache filter. Currently using a custom mechanism;
once the new plugin loading macros/mechanism is in place, I'll see
if that can be used.

There are a few open questions/issues.

- Can a GWBUF delivered to the filter contain more MySQL packets
  than one? If yes, then some queueing mechanism needs to be
  introduced. Currently the code is written so that the packets
  are processes in a loop, which will not work.
- Currently, the storage API is synchronous. That may work with a
  storage built upon RocksDB, that writes asynchronously to disk,
  but not with memcached that can be (and in MaxScale's case
  would have to be) used asynchronously.

  Reading may be problematic with RocksDB as values are returned
  synchronously. So that will stall the thread being used. However,
  as RocksDB uses in-memory caching and it is possible to arrange
  so that e.g. selects targeting the same table are stored together,
  it is not obvious what the impact would be.

  So as not to block the MaxScale worker threads, there'd have to
  be a separate thread-pool for RocksDB access and then arrange
  the data to be moved across.

  But initially, the inteface is synchronous.
- How is the cache configured? The original requirement mentions
  all sorts of parameters - database name, table name, column name,
  presence of WHERE clause, regexp, date/time of query, user -
  but it's not alltogether clear exactly how they should be specified
  and how they should interract. So initially all selects will
  be subject to caching with a TTL.
2016-08-29 10:00:42 +03:00
Johan Wikman
85b3d7c465 Make the instance name available to filters
The section name of a filter in the MaxScale configuration
file is unique for each filter. Hence, by providing that name
to the filter instance creation function, it is possible to
act differently depending on which particular instance is
being created.

Case in point.

There can be multiple cache filters defined in the MaxScale
configuration file, each with a different set of rules, ttl
and even backing store.

Each cache will be backed by a separate storage that e.g.
in the case of RocksDB will correspond to a particular path.

In other words, for each cache instance corresponding to a
particular cache definition in the MaxScale configuration file,
we need to be able to create a unique path.

If the filter section name (in the MaxScale configuration file)
that anyways needs to be unique, is provided to the filter, then
that name can be used when forming the unique path.

The alternative is to require the DBA to provide some unique
parameter for each cache definition, which adds configuration
overhead and is errorprone.

Furthermore, by providing the name to filters, also error
messages can be customized for a particular section when
appropriate.
2016-08-29 09:33:34 +03:00