Commit Graph

4766 Commits

Author SHA1 Message Date
6067c21c1b MXS-1346: Use the filter template in dbfwfilter
The dbfwfilter now uses the MaxScale filter template. Also fixed up some
of the filter template documentation.
2017-09-08 09:31:37 +03:00
fc1435d0c2 MXS-1346: Hide DbfwSession internals
The DbfwSession now only exposes the necessary methods with the exception
of the DOWNSTREAM and UPSTREAM structures. These will be handled when the
session implements the filter template.
2017-09-08 09:31:37 +03:00
dc7b25d0fe MXS-1346: Make Dbfw a proper class
The Dbfw class now only exposes the necessary methods which are required.
2017-09-08 09:31:37 +03:00
cf2e8d8b34 MXS-1346: Add DbfwSession method implementations
Added the implementation of the DbfwSession methods.
2017-09-08 09:31:36 +03:00
f5401c5244 MXS-1346: Rename dbfwfilter instance and session
Renamed the structures to C++ naming style and added initial declarations
for DbfwSession methods.

The DbfwSession methods are not yet fully implemented which is why parts
of the class are still public. The intention is to use the filter template
when the session class is sufficiently refactored.
2017-09-08 09:31:36 +03:00
fa6f155d29 MXS-1346: Make Rule methods const
Most of the methods can be const functions.
2017-09-08 09:31:36 +03:00
3648b5e702 MXS-1346: Clean up dbfwfilter.cc
Remove redundant code, move assignments to struct constructors, organize
variable declarations, use standard library functions.
2017-09-08 09:31:36 +03:00
4c4ea94319 MXS-1346: Clean up unused code
Removed the rule type enum and replaced it with a string description of
the type. Moved the rule type and name strings as private to the Rule
class. Replaced the need_full_parsing of the base class with a simple
constant.

Removed the unused array of rule names as well and the STRLINK structure
and the functions that use it.
2017-09-08 09:31:36 +03:00
594956178d MXS-1346: Implement LimitQueriesRule::matches_query
Moved the code into the LimitQueriesRule class and cleaned it up. Renamed
the QUERYSPEED struct and added simple constructor.
2017-09-08 09:31:36 +03:00
890f860650 MXS-1346: Refactor column, function and function usage rules
The rule matching implementations are now done in the ColumnsRule,
FunctionRule and FunctionUsageRule classes. The query_matches function now
also takes the session as its first parameter to relay session related
information to the rule. This will be needed by the LimitQueriesRule
class.
2017-09-08 09:31:36 +03:00
eb884aeb6e MXS-1346: Rename users.cc to user.cc
user.cc better describes the contents of the file as it defines the User
class.
2017-09-08 09:31:36 +03:00
1d11a12dcf MXS-1346: Move matching implementation into classes
Added the implementations of the query_matches method for the RegexRule,
WhereClauseRule and WildCardRule classes and moved the query matching code
into these functions.
2017-09-08 09:31:36 +03:00
f5d7919dbb MXS-1346: Add classes for all rule types
Added class declarations for all rule types. The matching functionality
for each class still needs to be implemented.
2017-09-08 09:31:36 +03:00
c55c46ac0c MXS-1346: Move rule matching into the User class
The User class now only exposes the `match` method which can be used to
check if any of the rules for a user match a query. Further cleanup is
required once individual rule classes have been implemented.
2017-09-08 09:31:36 +03:00
f7b978b2a2 MXS-1346: Make User more like a class
The User class now handles the appending of the rules by itself and it
also provides a method for accessing the name instead of exposing the name
itself.

The rules matching is still done externally to the User class and moving
it into the User class depends on other changes being made first.
2017-09-08 09:31:36 +03:00
ee88ae67f8 MXS-1346: Make dbfwfilter objects non-copyable
The User and Rule classes should not be copied.
2017-09-08 09:31:35 +03:00
eee32a4e21 MXS-1346: Split dbfwfilter declarations into multiple headers
The core declarations of the dbfwfilter are in dbfwfilter.hh, the rules in
rules.hh and the users in users.hh. The implementation of the rules is in
rules.cc.
2017-09-08 09:31:35 +03:00
0d8284f82e MXS-1346: Make permission rules a class
The default rule is of the type that always matches any query and the Rule
base class should reflect this.
2017-09-08 09:31:35 +03:00
b7f922bf6d MXS-1346: Move query parsing and query type matching into Rule
The Rule base class now checks whether the query needs to be fully parsed
and if the type of the query matches the rule.

Also added a base rule matching method that should be extended by the rule
types to do their matching. Currently no rule type uses it.
2017-09-08 09:31:35 +03:00
824962d59a MXS-1346: Use std::unordered_map for storing user definitions
The users are now stored in a unordered_map which removes the need for the
use of HASHTABLE. Altered all functions to use a shared_ptr of a User
instead of a raw pointer. Made parsing of rules exception-safe.
2017-09-08 09:31:35 +03:00
17e7097b00 MXS-1346: Store the rules of a user in a RuleList
Removed the RULEBOOK struct and replaced it with a RuleList container.
2017-09-08 09:31:35 +03:00
adc7b033e1 MXS-1346: Refactor DBFW_USER
Renamed DBFW_USER to User, added constructors and destructors and changed
use of char* to std::string.
2017-09-08 09:31:35 +03:00
da406d9749 MXS-1346: Store rules in a list
The rules are now stored in a list instead of a linked list of
rules. Parts of the code still use raw pointers to the Rule class instead
of shared pointers.
2017-09-08 09:31:35 +03:00
ddecc1f8c8 MXS-1346: Group thread-local variables
The thread-local variables are now grouped in a single struct.
2017-09-08 09:31:35 +03:00
6d1074e0dd MXS-1346: Rename RULE struct
Renamed to struct Rule and added constructor.
2017-09-08 09:31:35 +03:00
f2f281c9f1 MXS-1346: Simplify value lists
All value lists in the dbfwfilter rule grammar followed the same general
rules; they allowed virtually all types to be given. The minor differences
aren't large enough to warrant use of multiple list types.
2017-09-08 09:31:35 +03:00
d3893f2e83 MXS-1346: Refactor dbfwfilter user template creation
The user templates now use ValueList instead of STRLINK to store the
string values and they are stored as a list of shared pointers.

Minor cleanups to the user creation related grammar rules.
2017-09-08 09:31:35 +03:00
f28ba678ac MXS-1346: Refactor dbfwfilter rule creation
The rules are now created when all the information has been gathered. This
way of parsing is better suited to parsing objects and allows the
dbfwfilter rules to be eventually refactored into C++ classes.

The current code still uses structs to define the rules but it makes the
migration to classes easier.
2017-09-08 09:31:35 +03:00
4a4f4baba6 MXS-1346: Convert rule name to std::string
The rule name is now a std::string.
2017-09-08 09:31:35 +03:00
41b12cf7c8 MXS-1346: Use a different style for grammar files
The BISON files now use a different style for declaring non-terminal
symbols.
2017-09-08 09:31:35 +03:00
1e90b3623b MXS-1346: Disallow convoluted rule names
The rule names could have punctuation in them which caused unnecessary
complexity. Keeping the identifiers simple makes it easier to process.
2017-09-08 09:31:35 +03:00
b9302f11cc MXS-1346: Minor cleanup of grammar rules
Cleaned up the grammar rules by splitting long lines at roughly 80
characters and removed the redundant code for the columnlist type.
2017-09-08 09:31:35 +03:00
e0c2af45c7 Handle AuthSwitchRequest responses to COM_CHANGE_USER
The COM_CHANGE_USER that is sent as a part of the reset process for a
persistent connection did not expect a AuthSwitchRequest packet to be sent
as that implies that the server did not take the authentication fast
path. In this case, an error message needs to be logged stating that the
server requested a different authentication plugin than was expected.
2017-09-07 09:51:23 +03:00
c239477630 MXS-1387: checking slave connection in COM_BINLOG_DUMP phase
MXS-1387: checking slave connection in COM_BINLOG_DUMP phase
2017-09-06 15:09:50 +02:00
795722506b MXS-1387: check if MariaDB 10 Slave has GTID request set.
MXS-1387: check if the connecting MariaDB 10 Slave has the GTID request
set and return error code which stops replication.
2017-09-06 11:13:15 +02:00
84300c6d97 Do not manipulate read queue directly
Protocol modules should not manupulate the read queue directly,
but always access it via the functions created for that purpose.
2017-09-06 11:21:47 +03:00
642232e26b Fix COM_CHANGE_USER unknown response handling
The response handling logic did not always take the last packet for
inspection when a COM_CHANGE_USER was executed. The OK packet will always
be the last one since the COM_CHANGE_USER is the last command that was
sent.
2017-09-04 17:45:30 +03:00
ff94a39038 Binlog server: fix closing slave connections called by MySQL admin connection
Binlog server: fix closing slave connections called by MySQL admin
connection
2017-09-04 15:23:24 +02:00
4c5f0d184c Binlog server: force fake Client DCB close in errorReply
Binlog server: force fake Client DCB close in errorReply. This fixes an
issue when START SLAVE, with new config, is called after a previous one
with errors.
2017-09-04 15:23:24 +02:00
0a1608d90d Log proper message in errorReply when master state is BLRM_SLAVE_STOPPED
Log proper message in errorReply when master state is BLRM_SLAVE_STOPPED
2017-09-01 16:48:20 +02:00
85f395394b Connection retry limit minor changes
Connection retry limit minor changes
2017-09-01 13:52:40 +02:00
9230420872 The blr_master_close() is now called in the main worker thread.
The blr_master_close() is now called in the main worker thread by:
blr_stop_slave() and blr_stop_start_master()
2017-09-01 11:49:27 +02:00
22ceac6676 Update alter server help text
Added `persistpoolmax` and `persistmaxtime` to the help output of `show
servers`.
2017-09-01 12:06:44 +03:00
7cef722282 Handle unexpected responses to COM_CHANGE_USER
When an unexpected response to a COM_CHANGE_USER is received, it is now
processes and discarded instead of treated as an error. This will allow
further analysis of the situation in addition to possibly solving some of
the problems that the persistent connections have.

Added extra info level logging to relevant parts of the code that deal
with the COM_CHANGE_USER reply processing. This information should allow
tracking of the response state for debugging purposes.
2017-09-01 11:28:21 +03:00
63c803a818 MXS-1379: Route conflicting queries to current shard
All conflicting queries are routed to the shard which contains the
currently active database.
2017-09-01 11:28:21 +03:00
cfe06a563e Remove saving/updating GTID repo when maxscale starts
Remove saving/updating GTID repo when maxscale starts.
The repo update slows down the maxscale startup.
The saving was added in order populate GTID repo with current file but
it costs extra time to event validation routine when current binlog has
many events and it has a big size.
2017-08-31 17:27:52 +02:00
e1efb91ea5 MXS-1156: MASTER_CONNECT_RETRY is a new option for CHANGE MASTER TO
MXS-1156: MASTER_CONNECT_RETRY is a new option for CHANGE MASTER TO.

The ‘connect_retry’, ‘master_retry_count’ options are now in use for
both service and
router_options.
2017-08-31 11:01:03 +02:00
42833386f5 MXS-1156: added configuration entry point for connection retry parameters.
MXS-1156: added configuration entry points for connection retry
parameters.

Variable names have been also changed.
2017-08-31 11:01:03 +02:00
c91187d4de MXS-1156: added limit to master connect retry
MXS-1156: added limit to master connect retry
2017-08-31 11:01:03 +02:00
3c7a0014a9 MXS-1156: Store master_heartbeat_period in master.ini
MXS-1156: Store master_heartbeat_period in master.ini
2017-08-31 11:01:03 +02:00