Skip to content

Commit

Permalink
Merge branch '23.02' into 23.08
Browse files Browse the repository at this point in the history
  • Loading branch information
markus456 committed Dec 31, 2024
2 parents e624b77 + 80ce7df commit 988bf08
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 29 deletions.
11 changes: 5 additions & 6 deletions Documentation/Getting-Started/Configuration-Guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -1378,13 +1378,12 @@ the MaxScale log.
- **Type**: [size](#size)
- **Mandatory**: No
- **Dynamic**: Yes
- **Default**: `16Mi`
- **Default**: `65536`

High water mark for network write buffer. When the size of the outbound network
buffer in MaxScale for a single connection exceeds this value, network traffic
throtting for that connection is started. The parameter accepts
[size type values](#sizes). The default value is 65536 bytes (was 16777216 bytes
before 22.08.4).
throtting for that connection is started. The parameter accepts [size type
values](#sizes). The default value was 16777216 bytes before 22.08.4.

More specifically, if the client side write queue is above this value, it will
block traffic coming from backend servers. If the backend side write queue is
Expand All @@ -1403,12 +1402,12 @@ MaxScale 23.02 and earlier, also `writeq_low_water` had to be non-zero.
- **Type**: [size](#size)
- **Mandatory**: No
- **Dynamic**: Yes
- **Default**: `8Ki`
- **Default**: `1024`

Low water mark for network write buffer. Once the traffic throttling is enabled,
it will only be disabled when the network write buffer is below
`writeq_low_water` bytes. The parameter accepts [size type values](#sizes). The
default value is 1024 bytes (was 8192 bytes before 22.08.4).
default value was 8192 bytes before 22.08.4.

The value of `writeq_high_water` must always be greater than the value of
`writeq_low_water`.
Expand Down
2 changes: 1 addition & 1 deletion maxutils/maxsimd/src/impl/simd_multistmt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ MXS_AVX2_FUNC bool is_multi_stmt_impl(std::string_view sql, maxsimd::Markers* pM
{
case IS_ESCAPE:
++read_ptr;
/* fallthrough */
[[fallthrough]];
case IS_SPACE:
case IS_SEMICOLON:
++read_ptr;
Expand Down
6 changes: 4 additions & 2 deletions server/core/utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -558,8 +558,9 @@ int connect_socket(const char* host, int port, sockaddr_storage* addr)
mxb::WatchdogNotifier::Workaround workaround(mxs::RoutingWorker::get_current());
int so;
size_t sz;
bool is_unix_socket = host[0] == '/';

if (host[0] == '/')
if (is_unix_socket)
{
so = open_unix_socket(MXS_SOCKET_NETWORK, (struct sockaddr_un*)addr, host);
sz = sizeof(sockaddr_un);
Expand All @@ -572,7 +573,8 @@ int connect_socket(const char* host, int port, sockaddr_storage* addr)

if (so != -1)
{
if (::connect(so, (struct sockaddr*)addr, sz) == -1 && errno != EINPROGRESS)
if (::connect(so, (struct sockaddr*)addr, sz) == -1
&& ((is_unix_socket && errno != EAGAIN) || (!is_unix_socket && errno != EINPROGRESS)))
{
MXB_ERROR("Failed to connect backend server [%s]:%d due to: %d, %s.",
host, port, errno, mxb_strerror(errno));
Expand Down
20 changes: 0 additions & 20 deletions server/modules/protocol/MariaDB/mariadb_backend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2650,26 +2650,6 @@ MariaDBBackendConnection::StateMachineRes MariaDBBackendConnection::authenticate
void MariaDBBackendConnection::store_delayed_packet(GWBUF&& buffer)
{
uint8_t cmd = mxs_mysql_get_command(buffer);

if (cmd == MXS_COM_STMT_CLOSE && !m_delayed_packets.empty())
{
// This'll ignore MARIADB_PS_DIRECT_EXEC_ID which could also be handled by popping
// the last command if it's a COM_STMT_PREPARE. This is unlikely to happen as no
// connector is known to behave like this.
uint32_t ps_id = mxs_mysql_extract_ps_id(buffer);
auto it = std::find_if(m_delayed_packets.begin(), m_delayed_packets.end(), [&](const auto& buf){
return buf.id() == ps_id;
});

if (it != m_delayed_packets.end())
{
MXB_INFO("COM_STMT_CLOSE refers to COM_STMT_PREPARE with ID %u that is "
"queued for execution, removing both from the queue.", ps_id);
m_delayed_packets.erase(it);
return;
}
}

m_delayed_packets.emplace_back(std::move(buffer));

MXB_INFO("Storing %s while in state '%s', %lu packet(s) queued: %s",
Expand Down
3 changes: 3 additions & 0 deletions system-test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -991,6 +991,9 @@ add_test_executable(mxs5356_get_lock.cc mxs5356_get_lock mxs5356_get_lock LABELS
# MXS-5415: retry_failed_reads is not affected by delayed_retry_timeout
add_test_executable(mxs5415_retry_failed_reads_timeout.cc mxs5415_retry_failed_reads_timeout mxs5415_retry_failed_reads_timeout LABELS REPL_BACKEND readwritesplit)

# MXS-5432: Executing prepared statements too fast may stall query execution
add_test_executable(mxs5432_queued_ps.cc mxs5432_queued_ps mxs5432_queued_ps LABELS REPL_BACKEND readwritesplit)

############################################
# END: Normal tests #
############################################
Expand Down
25 changes: 25 additions & 0 deletions system-test/cnf/maxscale.cnf.template.mxs5432_queued_ps
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[maxscale]
threads=###threads###
log_info=1

###server###

[Monitor]
type=monitor
module=mariadbmon
servers=server1,server2
user=maxskysql
password=skysql
monitor_interval=1s

[Router]
type=service
router=readwritesplit
servers=server1,server2
user=maxservice
password=maxservice

[Listener]
type=listener
service=Router
port=4006
44 changes: 44 additions & 0 deletions system-test/mxs5432_queued_ps.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright (c) 2024 MariaDB plc
*
* Use of this software is governed by the Business Source License included
* in the LICENSE.TXT file and at www.mariadb.com/bsl11.
*
* Change Date: 2027-04-10
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2 or later of the General
* Public License.
*/

#include <maxtest/testconnections.hh>

void test_main(TestConnections& test)
{
auto c = test.maxscale->rwsplit();
test.expect(c.connect(), "Failed to connect: %s", c.error());
auto master_id = c.field("SELECT @@server_id, @@last_insert_id");

for (int i = 0; i < 10; i++)
{
std::string slow_query = "SET @a=(SELECT SLEEP(CASE @@server_id WHEN " + master_id
+ " THEN 0 ELSE 1 END))";
test.expect(c.query(slow_query), "Failed to execute SET: %s", c.error());

for (int j = 0; j < 10; j++)
{
MYSQL_STMT* stmt = c.stmt();
std::string ps_query = "SELECT 1";
test.expect(mysql_stmt_prepare(stmt, ps_query.c_str(), ps_query.length()) == 0,
"Prepare of '%s' failed: %s", ps_query.c_str(), mysql_stmt_error(stmt));
mysql_stmt_close(stmt);
}

test.expect(c.query("SELECT @@server_id"), "Failed to execute SELECT: %s", c.error());
}
}

int main(int argc, char** argv)
{
return TestConnections().run_test(argc, argv, test_main);
}

0 comments on commit 988bf08

Please sign in to comment.