Skip to content

Commit 6c8e4fc

Browse files
committed
MDEV-39126: Feedback plugin to use /etc/os-release
Update the feedback plugin to use /etc/os-release for OS discovery, as /etc/lsb-release is becoming obsolete. Maintained backwards compatibility by keeping the old checks as fallbacks. Signed-off-by: Anway Durge <durgeanway@gmail.com>
1 parent b69cb60 commit 6c8e4fc

11 files changed

Lines changed: 227 additions & 58 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#
2+
# MDEV-39126: Feedback plugin to use /etc/os-release
3+
#
4+
SELECT variable_name, variable_value FROM information_schema.feedback WHERE variable_name = 'os';
5+
variable_name variable_value
6+
os MASKED_OS_INFO
7+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
--source include/have_feedback.inc
2+
3+
--echo #
4+
--echo # MDEV-39126: Feedback plugin to use /etc/os-release
5+
--echo #
6+
7+
--replace_column 2 MASKED_OS_INFO
8+
SELECT variable_name, variable_value FROM information_schema.feedback WHERE variable_name = 'os';
9+
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
connection node_2;
2+
connection node_1;
3+
connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3;
4+
connection node_3;
5+
RESET MASTER;
6+
connection node_2;
7+
SET GLOBAL DEBUG_DBUG = "+d,delay_sql_thread_after_release_run_lock";
8+
START SLAVE;
9+
SET DEBUG_SYNC = "now WAIT_FOR sql_thread_run_lock_released";
10+
SET GLOBAL DEBUG_DBUG = "+d,wsrep_async_slave_node_dropped_error";
11+
SET DEBUG_SYNC = "now SIGNAL sql_thread_continue";
12+
SET DEBUG_SYNC = "now WAIT_FOR sql_thread_run_lock_released";
13+
SET GLOBAL DEBUG_DBUG = "-d,wsrep_async_slave_node_dropped_error";
14+
SET DEBUG_SYNC = "now SIGNAL sql_thread_continue";
15+
SET DEBUG_SYNC = "RESET";
16+
SET GLOBAL DEBUG_DBUG = "";
17+
STOP SLAVE;
18+
RESET SLAVE;
19+
connection node_3;
20+
RESET MASTER;
21+
disconnect node_3;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
!include ../galera_2nodes_as_slave.cnf
2+
3+
[mysqld.1]
4+
wsrep_restart_slave=1
5+
6+
[mysqld.2]
7+
wsrep_restart_slave=1
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#
2+
# MDEV-39011: The node running async slave replication hangs in shutdown.
3+
# The problem was in a leaked THD_count on the error path when
4+
# wsrep_restart_slave is set.
5+
#
6+
7+
--source include/galera_cluster.inc
8+
--source include/have_innodb.inc
9+
--source include/have_debug.inc
10+
--source include/have_debug_sync.inc
11+
12+
# node 3 is a native MariaDB server operating as async replication master
13+
--connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3
14+
--connection node_3
15+
RESET MASTER;
16+
17+
# nodes 1 and 2 form a Galera cluster, node 2 operates as a slave for the
18+
# native MariaDB master in node 3
19+
--connection node_2
20+
--disable_query_log
21+
--eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_USER='root', MASTER_PORT=$NODE_MYPORT_3;
22+
--enable_query_log
23+
24+
SET GLOBAL DEBUG_DBUG = "+d,delay_sql_thread_after_release_run_lock";
25+
START SLAVE;
26+
# Wait for the async slave thread to get started
27+
SET DEBUG_SYNC = "now WAIT_FOR sql_thread_run_lock_released";
28+
# Simulate a node dropped error for Wsrep to go to the restart point
29+
SET GLOBAL DEBUG_DBUG = "+d,wsrep_async_slave_node_dropped_error";
30+
SET DEBUG_SYNC = "now SIGNAL sql_thread_continue";
31+
# Now wait again as the execution should follow the error path and repeat
32+
SET DEBUG_SYNC = "now WAIT_FOR sql_thread_run_lock_released";
33+
# Don't follow the error path anymore
34+
SET GLOBAL DEBUG_DBUG = "-d,wsrep_async_slave_node_dropped_error";
35+
SET DEBUG_SYNC = "now SIGNAL sql_thread_continue";
36+
37+
# Cleanup before restart
38+
SET DEBUG_SYNC = "RESET";
39+
SET GLOBAL DEBUG_DBUG = "";
40+
STOP SLAVE;
41+
RESET SLAVE;
42+
43+
# Now try to restart the node: it should not hang in a shutdown
44+
--source include/restart_mysqld.inc
45+
46+
--connection node_3
47+
RESET MASTER;
48+
--disconnect node_3

mysql-test/suite/galera/t/galera_as_slave_replay.cnf

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44
binlog-format=row
55

66
[mysqld.1]
7-
wsrep_restart_slave=1
87
wsrep-debug=1
98

109
[mysqld.2]
11-
wsrep_restart_slave=1
1210
wsrep-debug=1

plugin/feedback/utils.cc

Lines changed: 47 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -266,27 +266,59 @@ int prepare_linux_info()
266266

267267
#ifdef TARGET_OS_LINUX
268268
/*
269-
let's try to find what linux distribution it is
270-
we read *[-_]{release,version} file in /etc.
269+
Let's try to find what Linux distribution it is.
270+
We first check for the modern and portable /etc/os-release:
271271
272-
Either it will be /etc/lsb-release, such as
272+
==> /etc/os-release <==
273+
PRETTY_NAME="Ubuntu 22.04.2 LTS"
274+
275+
If not found, we fall back to /etc/lsb-release:
273276
274277
==> /etc/lsb-release <==
275-
DISTRIB_ID=Ubuntu
276-
DISTRIB_RELEASE=8.04
277-
DISTRIB_CODENAME=hardy
278278
DISTRIB_DESCRIPTION="Ubuntu 8.04.4 LTS"
279279
280-
Or a one-liner with the description (/etc/SuSE-release has more
281-
than one line, but the description is the first, so it can be
282-
treated as a one-liner).
280+
Or a one-liner with the description (/etc/SuSE-release has more
281+
than one line, but the description is the first, so it can be
282+
treated as a one-liner).
283283
284-
We'll read lsb-release first, and if it's not found will search
285-
for other files (*-version *-release *_version *_release)
286-
*/
284+
We'll read os-release first, then lsb-release, and if neither is found
285+
we will search for other files (*-version *-release *_version *_release).
286+
*/
287287
int fd;
288288
have_distribution= false;
289-
if ((fd= my_open("/etc/lsb-release", O_RDONLY, MYF(0))) != -1)
289+
290+
/* 1. First try the modern portable way: /etc/os-release */
291+
if ((fd= my_open("/etc/os-release", O_RDONLY, MYF(0))) != -1)
292+
{
293+
size_t len= my_read(fd, (uchar*)distribution, sizeof(distribution)-1, MYF(0));
294+
my_close(fd, MYF(0));
295+
if (len != (size_t)-1)
296+
{
297+
distribution[len]= 0; // safety
298+
char *found= strstr(distribution, "PRETTY_NAME=");
299+
if (found)
300+
{
301+
have_distribution= true;
302+
char *end= strstr(found, "\n");
303+
if (end == NULL)
304+
end= distribution + len;
305+
found+= 12; // Length of "PRETTY_NAME="
306+
307+
if (*found == '"' && end[-1] == '"')
308+
{
309+
found++;
310+
end--;
311+
}
312+
*end= 0;
313+
314+
char *to= strmov(distribution, "os-release: ");
315+
memmove(to, found, end - found + 1);
316+
}
317+
}
318+
}
319+
320+
/* 2. Fallback to older /etc/lsb-release if os-release is not found */
321+
if (!have_distribution && (fd= my_open("/etc/lsb-release", O_RDONLY, MYF(0))) != -1)
290322
{
291323
/* Cool, LSB-compliant distribution! */
292324
size_t len= my_read(fd, (uchar*)distribution, sizeof(distribution)-1, MYF(0));
@@ -301,7 +333,7 @@ int prepare_linux_info()
301333
char *end= strstr(found, "\n");
302334
if (end == NULL)
303335
end= distribution + len;
304-
found+= 20;
336+
found+= 20; // Length of "DISTRIB_DESCRIPTION="
305337

306338
if (*found == '"' && end[-1] == '"')
307339
{
@@ -316,6 +348,7 @@ int prepare_linux_info()
316348
}
317349
}
318350

351+
319352
/* if not an LSB-compliant distribution */
320353
for (uint i= 0; !have_distribution && i < array_elements(masks); i++)
321354
{

sql/mysqld.cc

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6070,11 +6070,7 @@ int mysqld_main(int argc, char **argv)
60706070
my_free(user);
60716071

60726072
#ifdef WITH_WSREP
6073-
/* Stop wsrep threads in case they are running. */
6074-
if (wsrep_running_threads > 0)
6075-
{
6076-
wsrep_shutdown_replication();
6077-
}
6073+
wsrep_shutdown();
60786074
/* Release threads if they are waiting in WSREP_SYNC_WAIT_UPTO_GTID */
60796075
wsrep_gtid_server.signal_waiters(0, true);
60806076
#endif

sql/slave.cc

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5740,6 +5740,15 @@ pthread_handler_t handle_slave_sql(void *arg)
57405740
DBUG_ASSERT(debug_sync_service);
57415741
DBUG_ASSERT(!debug_sync_set_action(current_thd, STRING_WITH_LEN(act)));
57425742
};);
5743+
#ifdef WITH_WSREP
5744+
DBUG_EXECUTE_IF("wsrep_async_slave_node_dropped_error",
5745+
if (WSREP(thd))
5746+
{
5747+
wsrep_node_dropped= TRUE;
5748+
goto err_before_start;
5749+
}
5750+
);
5751+
#endif /* WITH_WSREP */
57435752
#endif
57445753

57455754
rli->parallel.reset();
@@ -5913,8 +5922,8 @@ pthread_handler_t handle_slave_sql(void *arg)
59135922
mysql_mutex_unlock(&rli->data_lock);
59145923
#ifdef WITH_WSREP
59155924
wsrep_open(thd);
5916-
if (WSREP_ON_)
5917-
wsrep_wait_ready(thd);
5925+
if (WSREP_ON_ && !wsrep_wait_ready(thd))
5926+
goto err;
59185927
if (wsrep_before_command(thd))
59195928
{
59205929
WSREP_WARN("Slave SQL wsrep_before_command() failed");
@@ -6137,21 +6146,25 @@ pthread_handler_t handle_slave_sql(void *arg)
61376146
*/
61386147
if (WSREP(thd) && wsrep_node_dropped && wsrep_restart_slave)
61396148
{
6140-
if (wsrep_ready_get())
6141-
{
6142-
WSREP_INFO("Slave error due to node temporarily non-primary"
6143-
"SQL slave will continue");
61446149
wsrep_node_dropped= FALSE;
61456150
mysql_mutex_unlock(&rli->run_lock);
6146-
goto wsrep_restart_point;
6147-
}
6148-
else
6149-
{
61506151
WSREP_INFO("Slave error due to node going non-primary");
61516152
WSREP_INFO("wsrep_restart_slave was set and therefore slave will be "
61526153
"automatically restarted when node joins back to cluster");
6153-
wsrep_restart_slave_activated= TRUE;
6154-
}
6154+
if (wsrep_wait_ready(thd))
6155+
{
6156+
wsrep_close(thd);
6157+
delete serial_rgi;
6158+
if (thd_initialized)
6159+
server_threads.erase(thd);
6160+
delete thd;
6161+
goto wsrep_restart_point;
6162+
}
6163+
else
6164+
{
6165+
/* The node is being shutdown. Fallthrough. */
6166+
mysql_mutex_lock(&rli->run_lock);
6167+
}
61556168
}
61566169
wsrep_close(thd);
61576170
#endif /* WITH_WSREP */

0 commit comments

Comments
 (0)