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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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).
- 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.
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.
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.
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).
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.
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.
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.
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.