8390 Commits

Author SHA1 Message Date
Markus Mäkelä
a3e7fd4f23 MXS-1354: Add utility functions to User class
Added a utility function for checking if an admin user has been
created. Removed unused promote and demote commands which can be replaced
with a call to remove and add.
2017-08-18 10:28:20 +03:00
Markus Mäkelä
158ae75dd2 MXS-1354: Add missing function declaration in adminusers header
The header is generated at configuration time so the changes need to be
done in the .in file.
2017-08-18 10:28:20 +03:00
Markus Mäkelä
3aebe0f91e MXS-1354: Add JSON serialization of users
The users can now be dumped and loaded as JSON objects. This allows easier
parsing and handling of users while still retaining the possibility to
manually edit the output. Added tests for dumping and loading the JSON
form users.

Also fixed a deadlock in Users::remove() where the same lock was acquired
twice and a faulty test case where failed authentication was expected to
work.
2017-08-18 10:28:20 +03:00
Markus Mäkelä
253d6d211f MXS-1354: Allow creation of basic users
The type of the user being created is defined at creation time. This
allows the creation of basic users.

Although the users can be created internally, they cannot yet be created
via maxadmin or the REST API.
2017-08-18 10:28:20 +03:00
Markus Mäkelä
829d8a1224 MXS-1354: Rename enums to better represent their use
Renamed permission types to PERM_BASIC and PERM_ADMIN to better represent
how the permission types are used.
2017-08-18 10:28:20 +03:00
Markus Mäkelä
4a179d973b MXS-1354: Add missing locking to the Users class
The Users class now performs locking when a method is called. This will
prevent concurrent access to the internal map of users.

Added missing const versions of SpinLockGuard.
2017-08-18 10:28:20 +03:00
Markus Mäkelä
a48758a9d8 MXS-1354: Take REST API authorization into use
GET requests are allowed for all users while POST, PATCH, DELETE and PUT
requests are reserved for administrative users.
2017-08-18 10:28:20 +03:00
Markus Mäkelä
06afbd14eb MXS-1354: Add permissions to admin users
The admin users now have a concept of write and read permissions. This
allows restricted read-only access to be granted to users.
2017-08-18 10:28:20 +03:00
Markus Mäkelä
c323f0a551 MXS-1354: Remove external linkage from User class
The User class is no longer declared with external linkage.
2017-08-18 10:28:20 +03:00
Markus Mäkelä
e627740777 MXS-1354: Enable muting of admin interface authentication failures
The warnings generated by the admin interface can now be silenced.
2017-08-18 10:28:20 +03:00
Markus Mäkelä
f0c2843195 MXS-1354: Fix diagnostic output
The tests failed due to changes in the diagnostic output.
2017-08-18 10:28:20 +03:00
Markus Mäkelä
af4e852649 MXS-1354: Take refactored users into use
The refactored interface is now in use. The only module that used it
directly was the CDC protocol module. This should probably be changed so
that it uses the adminusers interface instead of the users interface
directly.
2017-08-18 10:28:20 +03:00
Markus Mäkelä
7e860390df MXS-1354: Refactor user.cc
Made the USERS an opaque object to reduce the amount of exposed
interfaces. Moved the storage of users into a C++ class and exposed that
class via the users interface functions.

Removed unused code and cleaned up the documentation in the header. Added
helper functions for printing the stored users.
2017-08-18 10:28:20 +03:00
Markus Mäkelä
ca4dbf5d0d Refactor readwritesplit connection creation
The connections for a router session can now be done without a constructed
router session. This simplifies the creation of new router session by
removing the need to handle memory allocations.

Readwritesplit router sessions are now created in the static `create`
function which handles the actual creation of the connections and
allocation of the session itself.
2017-08-18 10:27:49 +03:00
Markus Mäkelä
46b7db1d45 Refactor readwritesplit session creation
Moved the initialization of the router session's member variables into the
constructor. Changed two functions that calculated server counts into the
router instance as they don't relate to a particular session.
2017-08-18 10:27:49 +03:00
Markus Mäkelä
ec33eaada1 Make rwsplit_readonly_stress failures faster
The test now stops immediately when an error occurs.
2017-08-18 10:27:28 +03:00
Markus Mäkelä
55c704a3dd Ignore repeated errors
Only the first error for each DCB should invoke the error handler
routine. All other errors for the same DCB should be ignored.

In practice this appears to happen when epoll return two different types
of error events for the same DCB.
2017-08-18 10:27:28 +03:00
Markus Mäkelä
f80cde2af1 Fix bug519
The test attempted to copy the generated CSV file from the MaxScale server
when in fact it was on the master server. Removed HEAVY label from the
test as it takes about 10 seconds to run.
2017-08-18 10:27:28 +03:00
Markus Mäkelä
727b4baa86 Fix application and exemption of masking rules to users
The applies_to and exempted values were only evaluated if both of them
were present.
2017-08-18 10:27:28 +03:00
Markus Mäkelä
19bae79784 Allow redirection of stdout/strerr
Added a debug option that allows stdout and stderr to be redirected to a
file. This helps with the use of ASAN which prints all of its findings to
stderr.
2017-08-18 10:27:28 +03:00
Markus Mäkelä
6c5ae24dff Fix out-of-bounds reads with LOAD DATA LOCAL INFILE
When a LOAD DATA LOCAL INFILE is done, the last packet is an empty packet
which does not contain the command byte. Some parts of the MySQL protocol
modules expected that a command is always present. The proper way to
handle this is to use the mxs_mysql_get_command function which does bounds
checking.
2017-08-18 10:27:28 +03:00
Markus Mäkelä
d723201d22 Add missing list terminator in debugcmd.c
The pingoptions list of commands was not terminated by an EMPTY_OPTION
value.
2017-08-17 15:05:19 +03:00
Markus Mäkelä
6bdd959f6c Reset client DCB pointer after closing it
The client DCB was not reset in one of the cases where it was closed.

Also fixed use of overlapping memory addresses in strcpy.
2017-08-17 15:04:37 +03:00
Markus Mäkelä
71ca174313 Reset master DCB pointer if it is closed
If the master DBC is closed, the pointer should be set to NULL as it is
used to check whether the connection is still valid.
2017-08-17 15:04:37 +03:00
Markus Mäkelä
d3a77b64c0 Fix response counter discrepancy on retried read
When a read was successfully retried, the original expected response was
not decremented from the reponse counter. This caused one extra response
to be expected for successfully retried reads which caused a hang after a
retried read.
2017-08-17 15:02:16 +03:00
Markus Mäkelä
fb9b027842 Enable optional use of ASAN
AdressSanitizer is a lightweight memory error detector that instruments at
compile time instead of at execution time. This allows serious memory
errors to be detected without the cost of slowing down the whole program
that often happens when Valgrind is used. It is also easier to enable for
test runs as it is a simple compiler flag.
2017-08-17 15:02:16 +03:00
Johan Wikman
8bd234a442 MXS-1337 Manual array manipulation replaced with std::vector 2017-08-17 09:21:52 +03:00
Johan Wikman
0630410bb2 Remove "unsupported" tests that are no longer unsupported 2017-08-17 09:21:52 +03:00
Johan Wikman
384633fc69 MXS-1247 Add all server window function tests 2017-08-17 09:21:52 +03:00
Esa Korhonen
2784858495 A few PAM cleanups
Print header found message only if libraries also found.
Change header guards to pragma once.
Check return value of store_client_password().
2017-08-16 13:47:29 +03:00
Markus Mäkelä
db8ad7efa8 Fix MXS-1323 regression
The check for session command count on failed session command was inverted
so that only session command failures would be routed to the client.
2017-08-16 13:27:39 +03:00
Markus Mäkelä
24bec67d90 Fix prepared_statement test
The test did not synchronize the slaves before doing a read that depended
on replication being in sync. It also didn't clear the previous value from
the buffer used to store the test form results which caused a misleading
error message.
2017-08-16 13:26:46 +03:00
Markus Mäkelä
2430f1b6b1 Fix message about journal_max_age default value
The monitor and parameter names were the wrong way around and the message
stated the value was in milliseconds when in fact it is in seconds.
2017-08-16 13:26:46 +03:00
Markus Mäkelä
5a5ab1fb26 Fix routing of stored queries in error handler
When a session command was executed and the last slave that was executing
dies, readwritesplit would route any pending queries before closing the
slave connection. This could cause a hang if the routing logic decided to
pick the failed server as the target of the stored query.

This fixes the MXS-1323 related regression in the develop branch.
2017-08-16 13:26:46 +03:00
Johan Wikman
523e7ed445 MXS-1247 Add initial support for window functions
This commit will be followed by more tests.
2017-08-16 13:04:21 +03:00
Johan Wikman
27ef5c3048 MXS-1247 Set the server version explicitly 2017-08-16 12:59:35 +03:00
Johan Wikman
2593961405 Merge branch '2.1' into develop 2017-08-16 12:58:35 +03:00
Johan Wikman
af53c24106 Update version to 2.1.7 2017-08-16 12:38:34 +03:00
Johan Wikman
4034931013 MXS-1247 Update mkopcodeh.tcl of sqlite3
With sqlite3 3110100, which is used in MaxScale, the the generation
of the used op-codes could sometime generate code that did not define
all opcodes. That resulted then in a compilation error like:

.../sqlite-bld-3110100/sqlite3.c: In function 'sqlite3VdbeExec':
.../sqlite-bld-3110100/sqlite3.c:75427:6: error: 'OP_Real' undeclared
                                          (first use in this function)
 case OP_Real: {            /* same as TK_FLOAT, out2 */
      ^

The reason seems to be that if a particular op-code was not used, the
generation stopped at that point:

    #define OP_Explain       160
    #define OP_NotUsed_161   161

With mkopcodeh.tcl from sqlite3 version 3200000, the generated code
looks like

    #define OP_NotUsed_161   161
    #define OP_Real          162 /* same as TK_FLOAT,
                                    synopsis: r[P2]=P4       */

and the code compiles.

Thus, mkopcodeh.tsl is updated from the newer sqlite3 version.
2017-08-16 10:17:27 +03:00
Johan Wikman
de7004cb95 Merge branch '2.1' into develop 2017-08-15 10:31:30 +03:00
geaaru
3485a32731 Fix compilation errors/warning with gcc-5.4.0 (#137)
Warning are like this:
 error: ‘delimiter’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
2017-08-15 09:56:22 +03:00
Johan Wikman
49ba1f8fa0 MXS-1360 Add 'thread_stack_size' configuration value
Using the 'thread_stack_size' configuration value, the stack size
of the worker threads can be adjusted.
2017-08-14 15:31:00 +03:00
Johan Wikman
e9b2a560b8 MXS-1360 Make it possible to specify thread stack size
It is now possible to specify the thread stack size to be used,
when a new thread is created. This will subsequently be used
for allowing the stack size to be specified for worker threads.
2017-08-14 15:24:16 +03:00
MassimilianoPinto
bdb0f7d8d7 Binlog server: error message was truncated due to error size computation.
Binlog server: error message was truncated due to error size
computation.
2017-08-14 13:41:04 +02:00
Johan Wikman
c662bea983 MXS-1359 Turn recursion into iteration
In case of very large compound selects or an INSERT with many
values, qc_sqlite could run out of stack space. To deal with
that, the critical recursion is turned into an iteration.
2017-08-14 13:29:19 +03:00
Johan Wikman
4798810f76 Merge branch '2.1' into develop 2017-08-14 10:36:34 +03:00
Johan Wikman
7021041804 Update 2.1.6 release date 2017-08-14 10:06:27 +03:00
Markus Mäkelä
9d3772a67e MXS-1262: Minor improvements to monitor journals
Moved 4 byte get/set into utils header. The byte packing functions in
maxscale/protocol/mysql.h should be migrated to the utils directory where
they can also be used by non-mysql code.

The temporary files are now generated with mkstemp. This will prevent
conflicts with multiple monitors operating on the same temporary journal
even though it is impossible in practice.

Added missing error messages to a couple of the functions.
2017-08-11 11:35:13 +03:00
Markus Mäkelä
b768d3ca76 MXS-1356: Allow tee filter to be disabled at runtime
Disabling the tee filter at runtime is desirable for cases where the
branched service is not always needed. Migrations and pre-production
setups are one where changes to the branched service are expected and
splitting the queries would result in an error.
2017-08-11 04:09:08 +03:00
Markus Mäkelä
53bf21f785 MXS-1262: Use monitor journals in all monitors
All monitors now persist the state of the server in a monitor journal
file.

Moved the removal of stale journals into the core and removed them from
the monitor journal interface.
2017-08-11 04:09:08 +03:00