6131 Commits

Author SHA1 Message Date
Johan Wikman
6d1265ade1 Length of a packet requires 32 bit. 2016-11-23 13:53:06 +02:00
Johan Wikman
9d3e5a715b Cache: Remove item if putting fails
If an item cannot be put to the database, it is explicitly removed
to ensure that we cannot have the situation that a stale item is
continuously returned because the updating of the value fails for
whatever reason.
2016-11-23 12:15:58 +02:00
Johan Wikman
e9029b183e Cache: Allow entries to be explicitly deleted 2016-11-23 12:15:58 +02:00
Johan Wikman
2ecd5f3340 Prevent stale item from being fetched more than once
If a cached entry becomes stale, then if no extra measures are
taken then every thread hitting that item while it is being fetched
from the server will also refresh it, even though it obviously is
sufficient that one does it.

Now the knowledge that the item is being refreshed is recorded,
so that all other clients are simply returned the stale item. That
way, we'll hit the server once per stale item.
2016-11-23 12:15:58 +02:00
Markus Makela
f4e3ca2c87 Merge branch '2.0.2' into develop 2016-11-23 11:24:34 +02:00
Markus Makela
53413a3260 MXS-929: Add reloading of rules to dbfwfilter
The rules and users are stored in thread-local pointers which removes the
need to hold global locks. This allows greater scalability but causes a
slightly larger memory footprint. Usually the increase in memory
consumption is trivial compared to the benefits in scaling.

Using a per-thread rule and user list allows changes to be applied
immediately without locking on the instance level.

The updating of the rules uses the new functinality described in the
debugcmd.h header. The module registers two functions at startup; one for
reloading rules and one for printing them. These custom functions can be
seen in the `maxadmin list functions` output.
2016-11-23 11:14:31 +02:00
Markus Makela
0a7d1390b6 MXS-929: Add module command calls to maxadmin
The maxadmin interface now supports calls to registered module
functions. It is also capable of listing all the registered functions.
2016-11-23 11:14:31 +02:00
Markus Makela
502eba8b4f Fix OK packet generation
The packet was generated with the wrong number of elements due to usage of
sizeof on an integer where the correct type was an uint8_t.

This only fixes the malformed packets but does not fix the root cause of
the problem. The affected rows and last insert ID are length encoded
integers which should be handled. The current code treats them as one byte
fields.
2016-11-23 10:37:42 +02:00
Johan Wikman
83ffdcf4ed Change defines into inline functions
To prevent bugs caused by pointers having the wrong type (e.g. uint32_t
instead of uint8_t), some macros are changed into inline functions so that
the normal type-checking is performed.

The macros MYSQL_GET_ERRCODE, MYSQL_GET_STMTOK_NPARAM, MYSQL_GET_STMTOK_NATTR,
and MYSQL_GET_NATTR were not changed, because they may be too specific to
be present in a general purpose header in the first place.
2016-11-23 10:14:50 +02:00
Johan Wikman
dcd98900ea Remove dependency on embedded library
The test programs of the query classifier do not need the
embedded library headers.
2016-11-23 10:14:50 +02:00
Markus Makela
1457b88606 Fix transaction tracking
The transaction tracking functionality used the wrong pointer type for
buffer data. This caused the query command comparison to always fail.
2016-11-23 10:11:27 +02:00
Johan Wikman
8572eb34a0 qc_sqlite: Dequote more properly
When a backslash is encountered, the backslash should not be
copied but only the character after that.

For the sake of completeness, a few more characters would have
to be handled explicitly, but as the content of a string will not
affect the statement's classification there is not much point in
doing that.
2016-11-22 19:11:21 +02:00
ekorh475
53637af98f Log monitor script argument values
MXS-843. When a monitor executes an external script in response to
a server event, the execution is logged to the MaxScale main log.
Previously, the log message only contained the script name as given
in the configuration file. Now, the message contains the script name
and argument values as given to the execvp-call.
2016-11-22 14:13:19 +02:00
Johan Wikman
79a03049a1 Enable fetching of stale items
It is now possible to specify that a cache item should be returned
if it exists, even if it is stale.
2016-11-22 11:15:26 +02:00
Markus Makela
15a03375c2 Install correct README file
The README was renamed to README.md which broke installation.
2016-11-22 11:06:18 +02:00
Markus Makela
3b5b616edf MXS-929: Add descriptions to module command arguments
Each argument now has a description describing what it does and what it's
used for.
2016-11-22 10:46:34 +02:00
Markus Makela
4137d58dd5 MXS-929: Implement DCB and SESSION pointer handling
DCBs and SESSIONs can be passed either as raw pointers or as the string
representations of them.

The preferred way to pass them is to use the raw pointer types. This
removes the need to convert the pointer to string form and back.
2016-11-22 10:46:34 +02:00
Markus Makela
d68172260d MXS-929: Add mapping function for module commands
The modulecmd_foreach function allows commands to be iterated without having
to manage the locking of the system. This allows the commands to be easily
iterated and gathered into filtered lists without having to build it into
the module command system itself.
2016-11-22 10:46:34 +02:00
Markus Makela
4a142b1ca9 MXS-929: Add errors to the modulecmd system
The modules can now return human-readable error messages to the caller of
the function. The internals of the modulecmd system also use this to
return errors to the users.

The error messages can be retrieved with a common error function which
should make it easy to use in various clients.
2016-11-22 10:46:34 +02:00
Markus Makela
4603e71987 MXS-929: Add domain function registration
A module can register a function to a domain. These function can then be
called by external actors enabling the modules to expand their
functionality beyond the module API. Each module should use its own domain
e.g the library name.

Currently, the functions do not return results. The possible next step
would be to alter the function entry point to return a result set of
sorts. This would allow the modules to convey structured information to
the client information which would handle the formatting of the result.

Although this sounds good, it is not required for the implementation of
MXS-929.
2016-11-22 10:46:34 +02:00
Johan Wikman
bddcee6f7e Add space between literal and string macro 2016-11-22 10:40:58 +02:00
Markus Makela
0c128e6598 Convert README into Markdown
Converting the README into Markdown format makes it a lot easier to
comprehent. Also cleaned up the formatting.
2016-11-22 10:38:42 +02:00
Johan Wikman
4dbb68cbfe Compile gateway.c as C++
When C and C++ are mixed in a project, main() should be compiled
as C++ to ensure that all C++ static initializations are performed
properly. That may not be strictly true anymore, depending on the
used compiler and environment, but better to do that to be on the
safe side.
2016-11-22 09:12:36 +02:00
Johan Wikman
97b039689f Disable write-ahead log
Since it's a cache, we do not need to retain the data from one
MaxScale invocation to the next. Consequently, we can turn off
write ahead logging completely if we simply wipe the RocksDB
database at each startup. In addition, the location of the
cache directory can now be specified explicitly, so it can be
placed, for instance, on a RAM disk.
2016-11-22 08:44:00 +02:00
Markus Makela
1432677406 Fix regression in prepared statement routing
The prepared statements were router according to the real type instead of
being router to the master. This was caused by the change in the route
target function.
2016-11-21 23:05:46 +02:00
Johan Wikman
afa175c3ab Update 2.0.2 Release Notes (part 2) 2016-11-21 13:03:47 +02:00
ekorh475
1a1c95fd3b Fix memory leak in script execution (MXS-1008) 2016-11-21 12:54:18 +02:00
Johan Wikman
9e4ee0323d Merge branch '2.0' into develop 2016-11-21 12:23:30 +02:00
Johan Wikman
3b30d5c810 Update 2.0.2 release notes 2016-11-21 10:20:22 +02:00
Johan Wikman
ef4fe8785f Update ChangeLog 2016-11-21 10:20:22 +02:00
Johan Wikman
6a68338c72 Update version to 2.0.2 2016-11-21 10:20:22 +02:00
Markus Makela
7ef1086040 Add case label block indentation to astylerc
Blocks after case labels are now indented.
2016-11-18 20:27:06 +02:00
Markus Makela
0aee4ac020 Differentiate active and inactive servers in services
The code that checked whether a server was added to a service did not
check whether the server reference was active. This caused problems when
an old server was added again to a service that once had used it.
2016-11-18 20:27:06 +02:00
ekorh475
de4ea067cf Fix for MXS-968
This commit adds a free() to null_auth_free_client_data, which plugs
the memory leak in maxinfo.

Also, this commit fixes some segfaults when multiple threads are
running status_row() or variable_row(). The functions use
statically allocated index variables, which often go out-of-bounds
in concurrent use. This fix changes the indexes to thread-specific
variables, with allocating and deallocating. This does seem to slow
the functions down somewhat.
2016-11-18 18:57:57 +02:00
ekorh475
5198c3e456 Run astyle on httpd.c and maxinfo_exec.c 2016-11-18 18:49:21 +02:00
Johan Wikman
ecb6680e71 MXS-976: qc_sqlite: Force initialization of sqlite3
Sqlite3 performs some lazy initialization, during which it internally
parses some SQL statements of its own. Earlier there was detection code
for noticing that, but it was costly and errorprone.

Now, sqlite3 is forced to perform the initialization at startup so that
we no longer need any detection code.
2016-11-18 16:04:26 +02:00
Johan Wikman
d640291023 Add crashing test-case
With 2.0.1 or earlier, if a statement contains a trailing NULL,
the statement will inside qc_sqlite.c incorrectly be assumed not
to be the one to be classified with a crash being indirectly the
result.
2016-11-18 16:00:57 +02:00
Markus Makela
a018e732eb Make the dbfwfilter rule check a separate utility
The code for the utility is now stored in a separate file. This also
removes the need to include testing headers from other directories.

Also added a function to reload rules that uses the newly modified rule
parsing mechanism. This can be used later on to update the rules at
runtime.
2016-11-18 08:59:52 +02:00
Markus Makela
8ae76e3ced Clean up dbfwfilter
Removed unused functions, made function names more consistent.
2016-11-18 08:53:43 +02:00
Markus Makela
696d103ed0 Allow servers to be removed from multiple objects
Since servers can be added to multiple objects, it only makes sense to be
able to remove them from multiple objects.
2016-11-17 12:37:50 +02:00
Markus Makela
ae339f174c Allow servers to be added to multiple objects at one time
The maxadmin interface to add servers to objects now allows a maximum of
11 objects to be listed. This will make it simpler to add a server to both
a monitor and a service in one command.
2016-11-17 12:37:50 +02:00
Markus Makela
b08e481137 Fix memory leak on reactivation of old server
If a destroyed server was reactivated, it would leak memory.
2016-11-17 12:37:50 +02:00
Markus Makela
042491ac07 Rename dbfwfilter objects to more descriptive ones
The object names in the dbfwfilter weren't very descriptive and were not
that easy to comprehend. The same goes for function names which had
somewhat cryptic names.
2016-11-17 12:36:44 +02:00
Markus Makela
72622bc92f MXS-977: Move common diagnostic code to the core
Almost all monitors printed the same diagnostic output inside the
modules. This should be a part of the core, not the modules themselves.
2016-11-17 12:36:44 +02:00
Markus Makela
4e007e87d0 Allow stale master status to be assigned via maxadmin
If a master once had slaves and is in the stale status, it will not retain
this status after a restart. Without storing on-disk information, the
stale master status cannot be deduced by looking at the master
alone. Because of this, the user should be able to manually enable the
stale master status.
2016-11-17 12:30:05 +02:00
MassimilianoPinto
cd31b2c2c3 Merge branch 'develop' into binlog_server_wait_data 2016-11-16 15:08:17 +01:00
MassimilianoPinto
3b7eec8655 The hole is created only with BLR_EVENT_DONE master_event_state
This fix allows the gap detection and the writing of an IGNORABLE event
only if master_event_state == BLR_EVENT_DONE.

Note: The hole is not being created if the event is bigger than 16MB
2016-11-16 15:06:24 +01:00
Johan Wikman
27247bea4e Now use maxscale_shutdown()
shutdown_server() has been renamed to maxscale_shutdown().
2016-11-16 15:35:32 +02:00
Markus Makela
5aefd35df9 MXS-969: Detect user variable modifications
With the use_sql_variables_in=master option, readwritesplit should route
all user variable modifications and reads with user variables to the
master.

Previously, the modification of user variables was grouped into generic
system variables which caused all modifications to system variables to go
to the master only. The router requires a finer grained distiction between
normal system variable modifications and user variable modifications.

With the improvements to the query classifier, readwritesplit now properly
routes all user variable operations to the master and other system
variable modifications to all servers.
2016-11-16 15:26:06 +02:00
Johan Wikman
59ee5a78c9 MXS-969: Report user var modifications properly
User variable modifications are now reported as QUERY_TYPE_USERVAR_WRITE
and not as QUERY_TYPE_GSYSVAR_WRITE as earlier.
2016-11-16 15:26:06 +02:00