2025 Commits

Author SHA1 Message Date
Markus Makela
aa4ed2d28d Only add DCBs to the list that arean't in the list
Listeners are added to the list multiple times due to how DCBs are removed
from the list.  This requires that an additional check is made so that we
are sure a DCB will not be added to the list twice.
2016-12-08 17:29:43 +02:00
Johan Wikman
777ea3ef43 Make config_truth_value() const correct 2016-12-08 14:58:48 +02:00
Markus Makela
d42ef8ed13 Combine and rename session statement functions
There was no real need to have two separate functions for getting the
stored buffer and the target server. Combining them into one allows it to
be handled in a nicer way.
2016-12-08 10:07:48 +02:00
Markus Makela
6f7f8cae39 Add storing of statements to session
Statements can now be stored in the session object. This enables the
retrieval of these statements at a later time. These will be used by
readwritesplit to reroute failed reads to backup slaves.
2016-12-06 20:27:51 +02:00
Markus Makela
4ae85dc754 Merge branch '2.0' into develop 2016-12-05 21:19:59 +02:00
Markus Makela
21098e0a26 MXS-1045: Delete default SIGCHLD handler
If the default signal handler is not deleted for the original parent
process, the forked daemon process never receives the signals.
2016-12-05 15:03:21 +02:00
Markus Makela
6d7e419ed4 Improve --config-check mode
The configuration checking now detects bad router options. This allows for
better coverage of the configuration with only the --config-check flag.
2016-12-05 13:18:20 +02:00
Markus Makela
9df3f154cf Detect duplicate objects
Creating a monitor or a listener twice is now detected and the proper
error is printed.
2016-12-03 11:31:18 +02:00
Markus Makela
a4bc575353 Remove direct freeing of sessions
Sessions are now always freed by releasing the last reference to it.
2016-12-02 15:19:44 +02:00
Markus Makela
adbd666991 Change module command parameter types
This commit introduces safe session references that can be handled without
holding locks. This allows the safe searching of sessions with the unique
ID of the session.

Remove the use of raw pointers passed as strings. Change the comments of
the argument types and add more details to the parsing function
documentation.
2016-12-02 14:26:56 +02:00
Johan Wikman
a6df875495 Make filter const correct and use snake case
CamelCase is still in use with the printing functions.
2016-12-01 15:20:34 +02:00
Markus Makela
ac0f975f9c MXS-1033: Fix crash on 'maxadmin list clients'
When the client connections were listed, the DCB state was not
inspected. Only DCBs in the polling state should be printed as they are
guaranteed to be in a valid state.
2016-11-30 23:10:24 +02:00
Markus Makela
b3e31a3da2 Add creation and destruction of monitors to maxadmin
Maxadmin can now create and destroy monitors. The created monitors are not
started as they would be useless without added servers and configuration
parameters.
2016-11-30 12:43:50 +02:00
Markus Makela
55f1bbfce6 Fix monitor alteration and serialization
When the monitor credentials were being written with snprintf, the source
and destination overlapped.

The serialization didn't add a 'type=monitor' line into the configuration.
2016-11-30 12:41:43 +02:00
Markus Makela
4c4bd24a40 Allow module specific monitor parameters to be altered
Module specific parameters can now be altered at runtime. This allows both
the removal and addition of arbitrary monitor parameters.
2016-11-30 12:41:43 +02:00
Markus Makela
7b8497df7a Make sure listener DCBs are removed cleanly from the list
As listener DCBs can be added and removed from the polling system multiple
times, the DCBs need to be reset to a clean state when they are removed.
2016-11-30 10:28:24 +02:00
Markus Makela
42eb8add5d Lock listeners when adding or removing them from epoll
Locking the listener DCB when adding or removing it from epoll will
prevent cases where only a part of the threads have the listener in epoll.
2016-11-30 10:28:23 +02:00
Markus Makela
0689b3df39 Improve the polling statistics
The statistics of the polling system no longer match the implementation it
measures. Modified the statistics to better represent the new system by
calculating the number of epoll events each thread receives.
2016-11-30 10:28:23 +02:00
Markus Makela
1b09faf2e4 Fix crash on debug logging
The debug logging for persistent connections caused a crash if a
non-backend DCB was processed.
2016-11-30 10:28:23 +02:00
Markus Makela
7cbbc6f8f7 Add a mechanism to synchronize persistent pool counts
The polling system now has a concept of messages. This can be used to send
a synchronous message to the polling system which waits for all threads to
process the message before returning.

Currently this is used to flush unused DCBs when server persistent
statistics are reported.
2016-11-30 10:28:23 +02:00
Markus Makela
5aa791d16e Move persistent connections to thread specific lists
Making the lists of persistent DCBs thread specific is both a bug fix and
a performance enhancement. There was a small window where a non-owner
thread could receive events for a DCB. By partitioning the DCBs into
thread specific lists, this is avoided by removing the possibility of DCBs
moving between threads.
2016-11-30 10:28:23 +02:00
Markus Makela
bcbff604b0 Properly store errno on listener epoll errors
When an epoll error occurs for a listener, the errno variable must be
stored in another variable while the listener is removed from all of the
epoll instances.
2016-11-30 10:28:23 +02:00
Markus Makela
32b0f6a607 Iterate using the correct list
The `thread.next` pointer refers to active DCBs in the current thread's
list and the `memdata.next` pointer refers to DCBs about to be freed. The
latter was mixed up with the former due to some changes in the naming.
2016-11-30 10:28:23 +02:00
Markus Makela
5411180a50 Fix DCB validity checks
The DCB was always assumed to be non-NULL.
2016-11-30 10:28:23 +02:00
Markus Makela
b09bf56127 Add missing NULL pointer check to DCB list handling
The thread specific list removal function didn't check whether the last
item was NULL before proceeding to alter the latest tail pointer.
2016-11-30 10:28:23 +02:00
Markus Makela
43f248927e Move thread related members of DCB into a substructure
The `thread` structure of a DCB now contains all the members that relate
to thread ownership of the DCB.
2016-11-30 10:28:23 +02:00
Markus Makela
2efa862944 Remove listmanager code
The code prevented scaling by imposing global spinlocks for the DCBs and
SESSIONs. Removing this list means that a thread-local list must be taken
into use to replace it.
2016-11-30 10:28:23 +02:00
Markus Makela
e53b9585dd Add mapping function for DCBs
The dcb_foreach allows a function to be mapped to all DCBs in
MaxScale. This allows the list of DCBs to be iterated in a safe manner
without having to worry about internal locking of the DCB mechanism.
2016-11-30 10:28:23 +02:00
Markus Makela
fce87f8c8e Add listeners to all epoll instances
Adding the listener DCBs to all epoll instances allows all threads to
accept new connections. This should increate MaxScale's responsiveness.
2016-11-30 10:28:23 +02:00
Markus Makela
5067f3594a Adapt session timeout checks to a per thread model
Each thread will now check their own list of DCBs for timed out sessions.
2016-11-30 10:28:23 +02:00
Markus Makela
30927455ef Add each DCB to the owning thread's list
Each DCB needs to be added to the owning thread's list so that they can be
iterated through. As sessions always have a client DCB, the sessions don't
need to be added to a similar per thread list.

This change fixes a problem with dcb_hangup_foreach that the removal of
the list manager introduced. Now the hangup events are properly injected
for the DCBs that connect to the server in question.
2016-11-30 10:28:23 +02:00
Markus Makela
abc0681248 Temporarily disable listmanager debug checks
Since the listmanager code isn't used, the debug assertions will always
fail. They should be disabled until the listmanager code can converted to
the per-thread model.
2016-11-30 10:28:22 +02:00
Markus Makela
51842333d7 Temporarily take out the listmanager from use
The listmanager code uses a global spinlock which might cause problems
with multiple threads.
2016-11-30 10:28:22 +02:00
Markus Makela
68d3fc1092 Remove the DCB write queue locking
Since only one thread can append to the DCBs write queue at a time, there
is no need to lock it.
2016-11-30 10:28:22 +02:00
Markus Makela
076b810c1e Create thread specific zombie queues
Because each thread has their own epoll file descriptor and only one
thread can process a DCB, it makes sense to move to a per thread zombie
queue. This removes one of the last restrictions on scalability.
2016-11-30 10:28:22 +02:00
Markus Makela
f77f78360e Insert fake events under a lock
The thread-specific spinlock needs to be acquired before a fake event is
inserted from a non-polling thread. The usual situation is when a monitor
thread inserts a hangup event for a DCB.

Other, less common cases are when session timeouts have been enabled and
the DCB needs to be closed. Here it is better to insert a fake hangup
event instead of directly closing the DCB from an external thread.
2016-11-30 10:28:22 +02:00
Markus Makela
8efdaa1ea6 Move fake events to a thread-specific queue
The fake poll events are now stored in thread specific queues. This
removes the need for the poll event queue.
2016-11-30 10:28:22 +02:00
Markus Makela
b79210c760 Create thread specific epoll instances
Having a unique epoll instance for each thread allows a lot of the locking
from poll.c to be removed. The downside to this is that each session can
have only one thread processing events for it which might reduce
performance with very low client counts.
2016-11-30 10:28:22 +02:00
Markus Makela
07c602d81c Add creation and destruction of monitors
Monitors can now be created and destroyed at runtime. The configurations
for new monitors are persisted to disk.
2016-11-29 15:04:19 +02:00
Markus Makela
4ff4e69592 Add stopping and starting of listeners to maxadmin
Listeners can now be stopped and started individually.
2016-11-29 15:04:19 +02:00
ekorh475
38e4a5902f MXS-576 Check for negative values for config settings
Previously, negative values were allowed for persistpoolmax and
persistmaxtime. Now they cause an error. Also, monitor_interval
allowed negative (or zero) values, which were then implicitly cast to
unsigned, causing unintended behaviour. Now this causes a warning
and the default value is used.
2016-11-29 14:53:27 +02:00
ekorh475
9ede657a9b Change error message when permissions on .secrets are wrong
If the user running MaxScale could open the .secrets-file and the
file permissions were anything other than owner:read, the
secrets_readkeys() would fail with error message
"Ignoring secrets file <path>, invalid permissions." Now the
message is more accurate in stating the expected permissions.
2016-11-29 14:52:30 +02:00
Markus Makela
c01430e3fc Fix module commands with no arguments
Passing zero as the argument count would lead to a malloc for zero
bytes which would always cause a failure.
2016-11-29 14:19:08 +02:00
Markus Makela
3ba8525063 Remove old .gitignore files
The files were used to deal with old Makefile builds.
2016-11-28 14:37:26 +02:00
Markus Makela
691989ff04 Split the service header into internal and external parts
The service header in include/maxscale/ contains the public part of the
service API. These functions can be safely used by the modules.

The internal header located in service/core/maxscale/ is used by the core
to initialize MaxScale at startup or to provide other services in a more
controlled way (the config_runtime, for example).
2016-11-28 14:37:26 +02:00
Markus Makela
88677946f8 Add destruction of listeners
The listeners aren't really destroyed and are only stopped. Further
changes are required so that they won't be started again once they have
been destroyed.
2016-11-28 14:37:26 +02:00
Markus Makela
6ea4e50f2c Clean up service.h
Most of the service header functions now contain the relevant
documentation. Cleaned up small parts of it and renamed functions to be
more consistent.
2016-11-28 14:37:26 +02:00
Markus Makela
e31afa28e4 Serialize created listeners to disk
The created listeners are now stored to disk like created servers
are. This allows them to be used even after a restart.

Currently, the listeners cannot be deleted and need to be manually
removed.
2016-11-24 15:22:55 +02:00
Markus Makela
dd63253261 Fix internal test suite failures
The server test used the wrong name.

MySQL users test loaded multiple modules in one function call and wasn't
appropriate for an internal test suite test as it requires a working
installation.

The cache filter didn't set the library paths before trying to load
modules.

The binlogrouter was missing a NULL check which caused a crash.
2016-11-24 15:22:55 +02:00
Johan Wikman
265aacaf15 GWBUF_DATA(...) explicitly returns uint8_t* 2016-11-24 13:31:29 +02:00