Commit Graph

5736 Commits

Author SHA1 Message Date
cc54d80a8b Fix memory leaks in maxinfo (modified for 2.0 and develop-branch)
MXS-1009. This commit adds a gwbuf_free after maxinfo_execute() to
free a buffer with an sql-query after it has been processed. Also,
the parse tree in maxinfo_execute_query() is now freed. The tree_free-
function was renamed to maxinfo_tree_free, since it is now globally
available.

This commit has additional changes (in relation to the 1.4.4 branch)
to remove errors caused by differences in the html and sql-sides of
MaxInfo.
2016-11-29 14:11:12 +02:00
0bc68742a6 Do error handling in one big locked action
This is not the optimal way to do error handling but it should solve all
problems that could rise from the multi-threaded model of MaxScale.

By taking a lock at the start of handleError, we'll be able to modify the
dcb error handling flag in a thread-safe manner. This should prevent
double error handling for all DCBs.
2016-11-29 12:07:12 +02:00
f8f400bdfd Only close the errored DCB if it is not in use
It was theoretically possible that a DCB was closed while it was still in
use.
2016-11-29 12:07:12 +02:00
8dae8136aa Add more logging to solve MXS-956
If a DCB is about to be closed but is has already been closed, a message
is logged. This will allow us to figure out exactly where the DCB is
closed.
2016-11-29 12:07:12 +02:00
9362954e82 Add newlines to avrorouter JSON output
JSON does not have a concept of streams and a common way to stream JSON is
to separate each JSON object with a newline. Adding a newline makes it
easier to parse as JSON values do not natively contain newlines.
2016-11-29 00:53:38 +02:00
2fe13719bc MXS-1027: Add Upstart config file
Various older systems use Upstart to control services. MaxScale should
provide both init.d scripts and Upstart configurations for systems that
don't support systemd.
2016-11-28 10:48:54 +02:00
cb93db4647 Make a copy of the client request
If the request isn't copied, the buffer will be freed twice.
2016-11-25 23:19:29 +02:00
1432677406 Fix regression in prepared statement routing
The prepared statements were router according to the real type instead of
being router to the master. This was caused by the change in the route
target function.
2016-11-21 23:05:46 +02:00
afa175c3ab Update 2.0.2 Release Notes (part 2) 2016-11-21 13:03:47 +02:00
1a1c95fd3b Fix memory leak in script execution (MXS-1008) 2016-11-21 12:54:18 +02:00
3b30d5c810 Update 2.0.2 release notes 2016-11-21 10:20:22 +02:00
ef4fe8785f Update ChangeLog 2016-11-21 10:20:22 +02:00
6a68338c72 Update version to 2.0.2 2016-11-21 10:20:22 +02:00
de4ea067cf Fix for MXS-968
This commit adds a free() to null_auth_free_client_data, which plugs
the memory leak in maxinfo.

Also, this commit fixes some segfaults when multiple threads are
running status_row() or variable_row(). The functions use
statically allocated index variables, which often go out-of-bounds
in concurrent use. This fix changes the indexes to thread-specific
variables, with allocating and deallocating. This does seem to slow
the functions down somewhat.
2016-11-18 18:57:57 +02:00
5198c3e456 Run astyle on httpd.c and maxinfo_exec.c 2016-11-18 18:49:21 +02:00
ecb6680e71 MXS-976: qc_sqlite: Force initialization of sqlite3
Sqlite3 performs some lazy initialization, during which it internally
parses some SQL statements of its own. Earlier there was detection code
for noticing that, but it was costly and errorprone.

Now, sqlite3 is forced to perform the initialization at startup so that
we no longer need any detection code.
2016-11-18 16:04:26 +02:00
d640291023 Add crashing test-case
With 2.0.1 or earlier, if a statement contains a trailing NULL,
the statement will inside qc_sqlite.c incorrectly be assumed not
to be the one to be classified with a crash being indirectly the
result.
2016-11-18 16:00:57 +02:00
4e007e87d0 Allow stale master status to be assigned via maxadmin
If a master once had slaves and is in the stale status, it will not retain
this status after a restart. Without storing on-disk information, the
stale master status cannot be deduced by looking at the master
alone. Because of this, the user should be able to manually enable the
stale master status.
2016-11-17 12:30:05 +02:00
5aefd35df9 MXS-969: Detect user variable modifications
With the use_sql_variables_in=master option, readwritesplit should route
all user variable modifications and reads with user variables to the
master.

Previously, the modification of user variables was grouped into generic
system variables which caused all modifications to system variables to go
to the master only. The router requires a finer grained distiction between
normal system variable modifications and user variable modifications.

With the improvements to the query classifier, readwritesplit now properly
routes all user variable operations to the master and other system
variable modifications to all servers.
2016-11-16 15:26:06 +02:00
59ee5a78c9 MXS-969: Report user var modifications properly
User variable modifications are now reported as QUERY_TYPE_USERVAR_WRITE
and not as QUERY_TYPE_GSYSVAR_WRITE as earlier.
2016-11-16 15:26:06 +02:00
b594bdc42a MXS-975: Remove hard limit on listen backlog
The listen() backlog is now set to INT_MAX which should guarantee that the
internal limit is always higher than the system limit. This means that the
length of the queue always follows /proc/sys/net/ipv4/tcp_max_syn_backlog.
2016-11-16 15:25:10 +02:00
a7c21eee88 Always treat master failures as fatal errors
When a connection to the master fails, readwritesplit should always treat
it the same way. Previously, if a connection to the master was lost but it
hadn't lost the master status, the failure would be treated like a slave
server failure.
2016-11-15 22:18:26 +02:00
7ddb4d8e5a Treat connection_timeout as an integer for reload_config
The connection_timeout parameter was treated as a boolean which caused
errors when the configuration was reloaded.
2016-11-14 16:35:03 +02:00
da129025eb Use common backend closing function
The backend references now use a common closing function so that all
variables are reset to proper states. The stored queries weren't always
freed and they would leak memory if left open.
2016-11-14 16:14:20 +02:00
ba4ab9d35f Remove sorting of backends with qsort
The backends are no longer sorted with qsort. This removes the possibility
of stale backend references.
2016-11-14 15:01:41 +02:00
0e641108d4 Merge pull request #112 from JindongChen/save-time-on-wildcard-domain-name
Save time when domain name contains wildcard '%'
2016-11-11 18:24:30 +02:00
8edd0d3bae Save time when domain name contains wildcard '%' 2016-11-11 23:40:55 +08:00
7ef8b187b5 Do hangups only after server states have been updated
The hangup code was refactored into a common function which should only be
used after the server states have been updated. This will remove erroneus
connections to already failed servers.
2016-11-09 23:21:54 +02:00
b12a87ef04 Fix false error message in readwritesplit
The error message for failure to find master wasn't included in the new
master error logging.
2016-11-09 23:21:53 +02:00
8d893b4e56 Reassing master reference after sorting backends
The master reference used by the readwritesplit sessions needs to be
reassigned if slave reconnection occurs. This happens because the
reference refers to a certain place in the backend reference array
instead of the actual backend reference and those places are mixed
when the array is sorted.
2016-11-09 23:21:47 +02:00
7f500feb9d MXS-710: Fix regression
MaxScale would crash if two or more listeners used the same service and
one of the listeners failed to start.
2016-11-09 06:44:37 +02:00
5d930585f9 Use TLS for connector connections
The monitors and services didn't use TLS when they connected to the
backend servers. Since there has been no proof of instability, TLS should
be enabled.
2016-11-08 15:21:58 +02:00
83f3245f75 Improve master routing failure error logging
The error logging is now more detailed and tells why the connection is
being closed. This should help the user figure out what is happening when
write fails and the connection is closed.
2016-11-06 10:25:56 +02:00
263688d3af Use proper server status macros in readwritesplit
Some of the master server status checks didn't check whether the server
was actually running. The macros in server.h should always be used instead
of manually inspecting the server status.
2016-11-06 07:03:07 +02:00
3d4a7179c7 Prevent active readwritesplit sessions from connecting to a master
If a readwritesplit session is active, it should never connect to a new
master. This will lead to unexpected results as the session states aren't
consistent.
2016-11-05 11:31:06 +02:00
c30d0dfc9d Add more error logging to DCB handling
If an illegal DCB close is done with a backend DCB, it will log the server
where it was connected. This allows us to know whether the DCB was
connected to a master or a slave.

Added more debug assertions to readwritesplit code. The DCBs should never
enter the DCB_STATE_DISCONNECTED.

Removed useless debug log messages. The messages usually just flood the
logs with no use to the developers.
2016-11-05 11:28:18 +02:00
87e94f6bc6 Fix debug assertion on packet length in blr_master.c
A debug assertion failed due to a NULL buffer but a non-zero packet
length. This was caused by a missing reset of the packet length after
freeing the buffers.
2016-11-04 10:53:21 +02:00
8f6c1bdd5b Add more error messages for unexpected situations
Some error messages were logged at INFO level and some had conditions that
prevent the logging. Removed these restrictions that an error situation is
always logged.
2016-11-03 10:16:46 +02:00
3870b81244 Prevent unintentional reconnections to the master server
If a master_failure_mode was set to error_on_write, a reconnection to the
old master would happen after the following events:

- Master server fails and the connection is closed
- The master server recovers
- A slave fails and the connection is closed
- A replacement for the slave is searched

If these events took place, the master would be taken back into use with
an inconsistent session state.
2016-11-02 19:55:36 +02:00
572d466fad Fix read-only mode error handling in readwritesplit
In read-only modes, readwritesplit would always continue even if an active
statement execution was in progress.
2016-11-02 12:12:36 +02:00
37a2c8cecf Use new function name in blr_slave
The blr_file_use_binlog function no longer exists and blr_file_append
should be used instead.
2016-11-01 10:28:15 +02:00
7dd498f0b9 MXS-958: a new binlog file is created after CHANGE MASTER if there is… … no pending transaction
Binlog server is already configured: if there is no pending transaction
a new binlog file is created after CHANGE MASTER.

If as START SLAVE is issued replication starts as usuale.

If maxscale is restarted the replication starts using the new created
file.
2016-10-31 15:20:51 +01:00
69b8cef95c MXS-958: the specified binlog file is created in $binlogdir while configuring binlog server for the first time
While configuring binlog server for the first time, master.ini not
existent, the specified MASTER_LOG_FILE is created in the $binlogdir.

If START SLAVE command is not issued the replication can start after
restarting maxscale as the binlog file exists.
2016-10-31 15:14:23 +01:00
7b4561e3f4 Fix COM_CHANGE_USER handling in MySQLBackend
When a COM_CHANGE_USER statement was executed, the new user credentials
were copied after the authentication message was sent. This caused the
COM_CHANGE_USER to always succeed the first time as it used the current
credentials. The user credentials would always lag behind by one.
2016-10-31 14:56:20 +02:00
6835fe4db9 Use pre-2.1 freeing functions
The binlogrouter code used the new MXS_FREE macro from the 2.1 version.
2016-10-31 14:56:20 +02:00
5ca0c730a1 MXS-960: In BRL, accept passwords with "," in them.
strtok_r replaced with a function that ignores delims that appear
within any of the MySQL quotes.
2016-10-31 11:54:15 +02:00
01f3b35fad MXS-961: error in replication stream and checksum calculation
When checksum is in use and there is an error in replication stream
master connection the blr_terminate_master_replication has no effect.

MXS-961: The checksum detection calls
blr_master_delayed_connect(router); and connection is scheduled again.

The fix will break the main loop as soon as the error indicator byte is
seen and no other computation will be done (such as checksum)
2016-10-31 10:18:22 +02:00
0f68fa6028 Removing error messages while executing RESET SLAVE
Removing error messages while executing RESET SLAVE
2016-10-28 18:40:18 +03:00
1388686fb7 MXS-957: Fix temporary table detection
Temporary tables which were created from joins with other temporary tables
weren't properly detected as CREATE TEMPORARY TABLE statements.
2016-10-26 17:36:48 +03:00
367d4407db Fix build failures when using C++11
Some parts of the code weren't C++11 compatible and the build would fail
with newer compilers.
2016-10-24 12:47:05 +03:00