Commit Graph

2608 Commits

Author SHA1 Message Date
2e069fa892 MXS-1632: Take mxb::atomic::add into use
The function now mostly replaces the use of atomic_add_ functions declared
in atomic.h.
2018-09-18 15:21:54 +03:00
37f693fc0a MXS-1632: Filter out inactive servers
The statistics are only returned for active servers.
2018-09-18 15:21:53 +03:00
805840dcdc MXS-1632: Add per-server read-write statistics
The read-write distribution in readwritesplit is now stored in a map
partitioned by the servers that the router has used. Currently, the
statistics for removed servers aren't dropped so some filtering still
needs to be added.
2018-09-18 15:21:53 +03:00
675182e9eb Remove unremoved comment
The comment stated that it should be removed before being merged.
2018-09-18 15:21:53 +03:00
4ba0112668 Deactive some uncrustify settings
This only deactivates some of the more heavy-handed features. All files have
been formatted with the new settings, which seems to have only affected lines
which were not formatted before.
2018-09-14 16:20:13 +03:00
4e41978069 Merge branch '2.2' into develop 2018-09-14 10:41:43 +03:00
c600b8ab92 MXS-2046: Fix double freeing of GWBUF
The response buffer from the master was freed twice.
2018-09-13 20:38:55 +03:00
bee7cc2002 MXS-2046: Fix additional memory leaks
A set of memory leaks were revealed by Valgrind.
2018-09-13 14:27:21 +03:00
a952255c19 MXS-2046: Fix binlogrouter memory leak
The client queries were never freed.
2018-09-13 13:02:31 +03:00
7ec2f77708 Merge branch '2.2' into develop 2018-09-12 23:18:08 +03:00
96a78685bc Fix possible buffer overrun in readwritesplit
If the GWBUF length was larger than the stack buffer length, the code
would write past the buffer.
2018-09-12 22:09:38 +03:00
e15b0e2147 MXS-2041: Fix crash on failed schemarouter session
When the setting up of filters for a session fails, the DCB is closed and
the client DCB's session pointer is set to NULL. This needs to be checked
in the schemarouter before the `m_client->session` pointer is used.

The act of setting the session pointer to NULL should not be necessary as
the session is freed once the reference count drops down to zero. Due to
the fact that changing this would require moderate changes in session code
means that it should not be done in a patch release as the risks are too
high.
2018-09-12 08:44:31 +03:00
d11c78ad80 Format all sources with Uncrustify
Formatted all sources and manually tuned some files to make the code look
neater.
2018-09-10 13:22:49 +03:00
c81173e320 Move C++ code out of C headers
The additions into the server.h header used C++ language which caused C
programs to fail to compile. Moved the implementation of the EMAverage
class into the private Server class in the server.hh header and exposed it
via functions in the server.h header. Also temporarily moved
almost_equal_server_scores into the public server.hh as there is no
service.hh header.
2018-09-10 11:21:06 +03:00
4f6990f90d Fix build failures
Changes to the ChangeMasterOptions made it non-trivial so it cannot be
safely memset anymore. The maxavrocheck was missing the linkage to the
maxscale-common library.
2018-09-10 11:05:43 +03:00
c447e5cf15 Uncrustify maxscale
See script directory for method. The script to run in the top level
MaxScale directory is called maxscale-uncrustify.sh, which uses
another script, list-src, from the same directory (so you need to set
your PATH). The uncrustify version was 0.66.
2018-09-09 22:26:19 +03:00
fa7ec95069 MXS-1777 Tune code for cases with slow, or new servers.
Changes that allow slow or new servers to quickly apply samples towards the
server average. The most important changes are to not ignore the first N samples,
and apply an average to the server as soon as there is one available.
The new ResponseStat::make_valid() will use filter samples to add an average,
if no averages have yet been added, even if the number of  filter samples is less
than the filter limit.
2018-09-09 14:17:40 +03:00
0e5d827f7a Merge branch '2.2' into develop 2018-09-08 18:58:57 +03:00
91acbc0994 MXS-1777 Turn server weights to their inverses, and make them doubles.
The math becomes simpler when the weight is inverted, i.e. a simple multiplication
to get the (inverse) score. Inverse weights are normalized to the range [0..1] where a lower
number is a higher weight,
The enum select_criteria_t is used to provide a std::function that takes the backends
as vector  (rather than the prior pairwise compares) and returns the best backend.
2018-09-05 17:45:28 +03:00
105bd7195f MXS-1777 remove dead code
Dead code.
2018-09-05 17:12:54 +03:00
de6ad542c4 MXS-1777 Refactor selection.
This commit refactors slave selection. The compare is still pair-wise but isolated into a small run_comparison() function. The function get_slave_candidate() is used when new connections are created, which I both moved and modified (had to move due to scoping), so diff is off.
The slave selection for routing:  get_slave_backend() now has the filtering logic from old get_slave_backend() and compare_backends(), the latter of which is removed.

Backend functions mostly take shared_ptr<SRWBackend> in various forms (as is, const ref, in a container). Ideally the shared_ptr would be used only to where it is really needed, and either naked ptrs or references to RWBackend would be used. This refactor does not address that issue, but compounds it by using even deeper shared_ptr structures. Fixing that in a future commit.
2018-09-05 17:12:54 +03:00
d52885d68d MXS-1777 Cosmetic changes based on code reviews. 2018-09-05 17:05:06 +03:00
6351ab9c73 MXS-1777: Initial version of routing based on query response time.
The main piece of code, slave selection (backend_cmp_response_time), uses the available
method of pair-wise comparison of slaves. This will be changed to selection using all
available slaves, along with removal of hard coded values.
2018-09-05 17:05:06 +03:00
1e6509423a MXS-1777: Add an EMAverage to the server struct, and a new slave selection criteria.
This is to support calculating the average from a session, and the slave selection criteria to be able to route based on averages. This commit, like the next one, have TODOs which you should feel free to comment on. Undecided things.
2018-09-05 17:05:06 +03:00
a0ea37b2c5 MXS-2011 Fix documentation and comments
Fix documentation and comment based upon review comments.
2018-09-04 15:54:21 +03:00
65d355c7d7 MXS-2011 Enforce gtid based replication
If secondary masters are defined, MASTER_USE_GTID=Slave_pos must
be specified for the default master.

If MASTER_USE_GTID is specified, only Slave_pos is allowed as
value.
2018-09-04 15:54:21 +03:00
f5b73cf106 MXS-2011 Fix terminology and names
The variable storing the configuration index renamed from
'current_config' to 'config_index'.

In the code the same terminology is used as in the documentation.
"Default" is is used for referring to the default connections
(earlier "primary" was used) and the secondary connections are
referred to as "secondary" (earlier "alternative" was also used).
2018-09-04 15:54:21 +03:00
a70885a541 MXS-2011 Allow configurations to be modified
- When specifying a configuration, if it already exists use
  the existing configuration as the default, thus allowing you
  to change only a specific configuration value.
- When specifying a new alternative configuration, use the
  primary (aka first) configuration as the base.
- If MASTER_HOST is changed on the primary (first, nameless)
  configuration, then all configurations are erased.
- At "SLAVE START", always start from the first configuration.
2018-09-04 15:54:21 +03:00
d293424f11 MXS-2011 Stop passing around unneeded arguments 2018-09-04 15:54:21 +03:00
9c06a60b48 MXS-2011 Immediately validate the connection name
And convert it to an index. This is subsequently needed when
connections configs can be updated and not just added.
2018-09-04 15:54:21 +03:00
4789f3f193 MXS-2011 Change invalid asserts
With multiple configs, we can no longer assert that the config
of the primary, aka first, config is identical with the one
being used.
2018-09-04 15:54:21 +03:00
812d80e403 MXS-2011 Use alternative servers
If the replication fails using the current config, we retry
immediately using another config, without waiting anything at
all.

Only when we have unsuccessfully tried with all servers, will
we wait a while before starting again.
2018-09-04 15:54:21 +03:00
ae28f8189b MXS-2011 Change return value of blr_check_connect_retry
0 cannot be used to indicate failure as 0 will be the waiting
period if we switch to an alternative server.

Also fix some minor issues; failure to initialize all members
and inverted success-check.
2018-09-04 15:54:21 +03:00
9826458700 MXS-2011 Log complaint from master
If the replication is terminated, the error message sent by
the master is written to the log.
2018-09-04 15:54:21 +03:00
76fbe72454 MXS-2011 Fix rebase bug 2018-09-04 15:54:21 +03:00
9ff0eab539 MXS-2011 First read config, then apply it
Separating the reading of the config from the process of
applying it allows us to use configs around and later apply
them (e.g. when we decide its time to switch master server).
2018-09-04 15:54:21 +03:00
5f809e5066 MXS-2011 Store settings from config object
Also store settings of alternative configs as well.
2018-09-04 15:54:21 +03:00
dec81594c1 MXS-2011 Assert that configurations are identical
At save time, assert that the configuration as dispersed around
blr and as stored in the config object are identical.

Later its the state from the config object that will be saved.
2018-09-04 15:54:21 +03:00
0c3fcfe302 MXS-2011 Allow alternative connections to be specified
Alternative masters can now be specified like

  CHANGE MASTER TO ...
  CHANGE MASTER ":2" TO ...
  CHANGE MASTER ":3" TO ...

Now only the data is stored, but it is neither used nor
saved.
2018-09-04 15:54:21 +03:00
93dc75a011 MXS-2011 Introduce blr_file_read_master_config()
One function for writing, another for reading the config.
No code changes; just moving code around.
2018-09-04 15:54:21 +03:00
a43f2ce8fb MXS-2011 Store current CHANGE MASTER config in router 2018-09-04 15:54:21 +03:00
d036668ffa MXS-2011 Rename blr.h to blr.hh
Now contains C++ elements.
2018-09-04 15:54:21 +03:00
ce18d13133 MXS-2011 Pick out the connection name if it is provided
Yet not used for anything.
2018-09-04 15:54:21 +03:00
8f1d807f1b MXS-2011 Remove "CHANGE MASTER" when testing
The blr_handle_change_master() will receive the string without
"CHANGE MASTER" when running BLR.
2018-09-04 15:54:21 +03:00
1aad1ae7d7 MXS-2011 Introduce blr_apply_change_master()
This function applies a change master config. Currently is
used from blr_handle_change_master(), and subsequently will
be used when BLR switches to an alternative master.
2018-09-04 15:54:21 +03:00
8f26e3cbaf MXS-2011 Take ChangeMasterConfig into use 2018-09-04 15:54:21 +03:00
2ba0b4dda9 MXS-2011 Declare variables at the point where they are needed
Also change explicit allocation into vector.
2018-09-04 15:54:21 +03:00
883a3a6fe1 MXS-2010 Introduce ChangeMasterConfig
This type will be used for storing the configuration
specified with CHANGE MASTER at a point where it has been
verified, to the extent possible, that the provided options
are valid.
2018-09-04 15:54:21 +03:00
adb7bb8e8a MXS-2011 Lock router only when needed 2018-09-04 15:54:21 +03:00
0e1d2ec1ec MXS-2011 First check, then change
By slightly re-arranging things, we do not need to revert
the situation if some parameters are not acceptable, but
can simply return.
2018-09-04 15:54:21 +03:00