Skip to content

Commit

Permalink
Merge branch '23.08' into 24.02
Browse files Browse the repository at this point in the history
  • Loading branch information
markus456 committed Dec 31, 2024
2 parents f775c1d + 988bf08 commit bfe5186
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 28 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 @@ -1391,13 +1391,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
throttling 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 @@ -1416,12 +1415,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
7 changes: 5 additions & 2 deletions server/core/server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1495,7 +1495,9 @@ int Server::connect_socket(sockaddr_storage* addr)
int so = -1;
size_t sz;
auto host = address();
if (host[0] == '/')
bool is_unix_socket = host[0] == '/';

if (is_unix_socket)
{
so = open_unix_socket(MxsSocketType::CONNECT, (sockaddr_un*)addr, host);
sz = sizeof(sockaddr_un);
Expand All @@ -1519,7 +1521,8 @@ int Server::connect_socket(sockaddr_storage* addr)

if (so != -1)
{
if (::connect(so, (sockaddr*)addr, sz) == -1 && errno != EINPROGRESS)
if (::connect(so, (sockaddr*)addr, sz) == -1
&& ((is_unix_socket && errno != EAGAIN) || (!is_unix_socket && errno != EINPROGRESS)))
{
MXB_ERROR("Failed to connect backend server %s ([%s]:%d). Error %d: %s.",
name(), 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 @@ -2645,26 +2645,6 @@ MariaDBBackendConnection::StateMachineRes MariaDBBackendConnection::authenticate
void MariaDBBackendConnection::store_delayed_packet(GWBUF&& buffer)
{
uint8_t cmd = mariadb::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 @@ -1003,6 +1003,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 bfe5186

Please sign in to comment.