Commit Graph

5339 Commits

Author SHA1 Message Date
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
a1d4f25392 Remove erroneous include 2017-09-07 16:56:19 +03:00
cae0e658fb Handle failures in dcb_connect properly
When something fails inside dcb_connect we rewind the situation
properly, without calling any of the close functions intended for
shutting down a properly created DCB. That way they can be simplified
and once the reference counting is taken into use it is sufficient to
call dcb_dec_ref(dcb) instead of dcb_free_all_memory().
2017-09-07 16:03:17 +03:00
9da1439b0e Rename session_link_dcb to session_link_backend_dcb
Reduce risk for confusion.
2017-09-07 15:51:48 +03:00
80815e0f54 Change session_link_dcb to void
The function attempted to detect use of freed memory, which is a
futile excersize.
2017-09-07 15:04:35 +03:00
44db97215f Deliver fake events for the current dcb immediately
If a fake event is added to the current dcb, we arrange things so
that it is delivered immediately when the handling of the event(s)
during which the fake event was added, has been performed.

Otherwise the event is delivered via the event loop.
2017-09-07 13:48:07 +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
699b3909f7 Set current_dcb to NULL if the current DCB is deleted 2017-09-06 13:45:39 +03:00
c542010e67 Fix internal test failures
The adminusers test did not properly initialize all subsystems in
MaxScale. The polling and DCB tests weren't updated with the changes to
the DCB closing.
2017-09-06 13:20:28 +03: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
3770b4da95 Name read/fake queue consistently
Now dcb_readqueue and dvb_fakequeue are named readq and fakeq
respectively, to be consistent with the naming of the write
and delay queue.
2017-09-06 11:30:24 +03: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
24044a7376 Add dcb functions
dcb_readq_append()
dcb_readq_prepend()
dcb_readq_set()
dcb_readq_has()
dcb_readq_release()
dcb_readq_get()
dcb_readq_length()

No code but for DCB code itself should directly manipulate the
internals of a DCB. Thesse functions will be taken into use in
protocol modules.
2017-09-06 11:12:32 +03:00
186ee31abf Fix setting of this_thread.current_dcb
Also in the case of fake events, the current dcb must be set.
2017-09-05 16:04:59 +03:00
d3f4723c81 Do not report events for closed dcb
Before each event handler is called, it is checked whether the
dcb has been closed. If it has been, then the event handler is
not called.

The check has to be made before each event handler, because any
event handler can close the dcb.
2017-09-05 13:20:22 +03:00
d931787e2e Use _exit when daemonizing the process
The original process should use _exit if the forking of the child process
is successful. This makes sure that the exit handlers are called only when
the daemon process exits.
2017-09-04 17:56:34 +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
2da7a93473 Destroy workers after services
The workers need to be destroyed only after services have been
to ensure that they are around in case the destruction of services
involves the closing of dcbs.
2017-09-04 16:01:42 +03:00
2f0292fd68 Relax dcb_close assert
If the current worker id is -1, we do not insist that the dcb
is closed by the owning thread. That will happen only for dcbs
that are created before the workers have been started and hence
it is also ok to close them after the workers have exited.
2017-09-04 16:00:27 +03:00
b43ab674e3 Add dcb_close_in_owning_thread(DCB*);
Allows a DCB to be closed by a thread other than the owning
thread.
2017-09-04 13:41:16 +03:00
ccbff0f6d4 Allow debugging of dcb event handling
Using DCB_LOG_EVENT_HANDLING is defined, a notice will be
logged for each event when it is handled.
2017-09-04 11:29:18 +03:00
1a468049b8 Overwrite dcb thread id at final close 2017-09-04 11:09:48 +03: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
18cb61f7de Delay closing in dcb_close
If a dcb being closed is the dcb for which events are currently being
processed, the dcb is not closed immediately but only after all events
have been delivered.
2017-09-01 11:03:23 +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
d7b04fc451 Add static storage to anonymous unit/thread structures
Without static, CentOS6 complains about non-local variable
using anonymous type.
2017-08-31 12:45:16 +03: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