Skip to content

Commit b07a36e

Browse files
committed
Merge 10.11 into 11.4
2 parents 75c868b + 88d34d5 commit b07a36e

43 files changed

Lines changed: 627 additions & 141 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

client/mysql.cc

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1458,13 +1458,25 @@ int main(int argc,char *argv[])
14581458
if (verbose)
14591459
tee_fprintf(stdout, "Reading history-file %s\n",histfile);
14601460
read_history(histfile);
1461-
if (!(histfile_tmp= (char*) my_malloc(PSI_NOT_INSTRUMENTED,
1462-
strlen(histfile) + 5, MYF(MY_WME))))
14631461
{
1464-
fprintf(stderr, "Couldn't allocate memory for temp histfile!\n");
1465-
exit(1);
1462+
/* Extra space for the suffix appended to histfile:
1463+
"." - separator (sizeof = 2, includes NUL)
1464+
+ PID - up to 20 digits (ULONG_MAX = 18446744073709551615)
1465+
+ ".TMP"- extension (sizeof = 5, includes NUL, doubles
1466+
as the string NUL terminator)
1467+
sizeof(".") and sizeof(".TMP") each carry a NUL, so the sum
1468+
over-allocates by one byte, which is intentional. */
1469+
size_t hlen= strlen(histfile) + sizeof(".") + 20 + sizeof(".TMP");
1470+
if (!(histfile_tmp= (char*) my_malloc(PSI_NOT_INSTRUMENTED, hlen, MYF(MY_WME))))
1471+
{
1472+
fprintf(stderr, "Couldn't allocate memory for temp histfile!\n");
1473+
exit(1);
1474+
}
1475+
/* Include PID in name to avoid rename collision when concurrent sessions exit. */
1476+
/* pid_t is signed but getpid() always returns a non-negative value (POSIX). */
1477+
snprintf(histfile_tmp, hlen, "%s.%lu.TMP", histfile,
1478+
(unsigned long) getpid());
14661479
}
1467-
sprintf(histfile_tmp, "%s.TMP", histfile);
14681480
}
14691481
}
14701482

extra/mariabackup/xtrabackup.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5536,7 +5536,7 @@ static bool xtrabackup_backup_func()
55365536

55375537
/* get current checkpoint_lsn */
55385538
{
5539-
log_sys.latch.wr_lock(SRW_LOCK_CALL);
5539+
log_sys.latch.wr_lock();
55405540
mysql_mutex_lock(&recv_sys.mutex);
55415541
dberr_t err = recv_sys.find_checkpoint();
55425542
log_sys.latch.wr_unlock();

mysql-test/main/mdev-33070.cnf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
!include include/default_my.cnf
2+
3+
[mysqld.1]
4+
extra-port= @ENV.MASTER_EXTRA_PORT
5+
6+
[ENV]
7+
MASTER_EXTRA_PORT= @OPT.port

mysql-test/main/mdev-33070.opt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--thread-handling=pool-of-threads --loose-thread-pool-mode=generic --thread-pool-size=1 --thread-pool-max-threads=3 --thread-pool-oversubscribe=1 --thread-pool-stall-limit=10000 --thread-pool-dedicated-listener

mysql-test/main/mdev-33070.result

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# MDEV-33070 Thread pool starvation at oversubscribe threshold
2+
CREATE TABLE t1 (a INT);
3+
connect c1, localhost, root,,;
4+
connect c2, localhost, root,,;
5+
connect c3, localhost, root,,;
6+
connect extra_con, 127.0.0.1, root,,test,$MASTER_EXTRA_PORT,;
7+
connection c1;
8+
SELECT SLEEP(1000);
9+
connection extra_con;
10+
connection c2;
11+
SELECT SLEEP(1000);
12+
connection extra_con;
13+
connection c3;
14+
INSERT INTO t1 VALUES (1);
15+
connection extra_con;
16+
KILL QUERY c1_id;
17+
SELECT COUNT(*) = 1 FROM t1;
18+
COUNT(*) = 1
19+
1
20+
connection c1;
21+
disconnect c1;
22+
connection extra_con;
23+
KILL QUERY c2_id;
24+
connection c2;
25+
disconnect c2;
26+
connection c3;
27+
disconnect c3;
28+
connection extra_con;
29+
SELECT COUNT(*) = 1 FROM t1;
30+
COUNT(*) = 1
31+
1
32+
disconnect extra_con;
33+
connection default;
34+
DROP TABLE t1;
35+
# End of MDEV-33070 tests

mysql-test/main/mdev-33070.test

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
--source include/not_embedded.inc
2+
--source include/have_pool_of_threads.inc
3+
4+
--echo # MDEV-33070 Thread pool starvation at oversubscribe threshold
5+
6+
# The server is started with a single thread group, a dedicated listener,
7+
# one worker thread, and thread_pool_oversubscribe=1.
8+
#
9+
# c1 and c2 run long queries and occupy the one worker plus the one allowed
10+
# oversubscribe slot. c3 submits a trivial INSERT which the listener can only
11+
# enqueue, because it is sent only after both c1 and c2 are confirmed running.
12+
#
13+
# Before the fix, after c1 was killed the worker stayed at the oversubscribe
14+
# threshold and went to sleep instead of dequeuing c3. Because
15+
# thread_pool_dedicated_listener=ON, only the worker can drain the queue, so if
16+
# c3 is still pending while c1 and c2 run and completes only after c1 is
17+
# killed, then the worker resumed dequeuing.
18+
19+
CREATE TABLE t1 (a INT);
20+
21+
--connect (c1, localhost, root,,)
22+
--connect (c2, localhost, root,,)
23+
--connect (c3, localhost, root,,)
24+
--connect (extra_con, 127.0.0.1, root,,test,$MASTER_EXTRA_PORT,)
25+
26+
--connection c1
27+
--let $c1_id= `SELECT CONNECTION_ID()`
28+
--send SELECT SLEEP(1000)
29+
30+
--connection extra_con
31+
let $wait_condition=
32+
SELECT COUNT(*) > 0 FROM INFORMATION_SCHEMA.PROCESSLIST
33+
WHERE STATE='User sleep' AND ID=$c1_id;
34+
--source include/wait_condition.inc
35+
36+
--connection c2
37+
--let $c2_id= `SELECT CONNECTION_ID()`
38+
--send SELECT SLEEP(1000)
39+
40+
--connection extra_con
41+
let $wait_condition=
42+
SELECT COUNT(*) > 0 FROM INFORMATION_SCHEMA.PROCESSLIST
43+
WHERE STATE='User sleep' AND ID=$c2_id;
44+
--source include/wait_condition.inc
45+
46+
--connection c3
47+
--send INSERT INTO t1 VALUES (1)
48+
49+
--connection extra_con
50+
--replace_result $c1_id c1_id
51+
eval KILL QUERY $c1_id;
52+
53+
let $wait_timeout= 10;
54+
let $wait_condition=
55+
SELECT COUNT(*) = 1 FROM t1;
56+
--source include/wait_condition.inc
57+
SELECT COUNT(*) = 1 FROM t1;
58+
59+
--connection c1
60+
--error 0,ER_QUERY_INTERRUPTED,ER_STATEMENT_TIMEOUT
61+
--reap
62+
--disconnect c1
63+
64+
--connection extra_con
65+
--replace_result $c2_id c2_id
66+
eval KILL QUERY $c2_id;
67+
68+
--connection c2
69+
--error 0,ER_QUERY_INTERRUPTED
70+
--reap
71+
--disconnect c2
72+
73+
--connection c3
74+
--reap
75+
--disconnect c3
76+
77+
--connection extra_con
78+
SELECT COUNT(*) = 1 FROM t1;
79+
--disconnect extra_con
80+
81+
--connection default
82+
DROP TABLE t1;
83+
--echo # End of MDEV-33070 tests

mysql-test/main/sp-error.result

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1571,7 +1571,12 @@ declare continue handler for 0 set @x=0;
15711571
end$$
15721572
ERROR HY000: Incorrect CONDITION value: '0'
15731573
set @old_recursion_depth = @@max_sp_recursion_depth;
1574-
set @@max_sp_recursion_depth = 255;
1574+
set @l = 255;
1575+
SELECT IF(global_value like 'MSAN%', 20,
1576+
IF(global_value LIKE 'ASAN%', 200, 255)) INTO @l
1577+
FROM information_schema.system_variables
1578+
WHERE variable_name='have_sanitizer' AND version() LIKE '%debug%';
1579+
set @@max_sp_recursion_depth = @l;
15751580
create procedure p1(a int)
15761581
begin
15771582
declare continue handler for 1436 -- ER_STACK_OVERRUN_NEED_MORE

mysql-test/main/sp-error.test

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2230,10 +2230,17 @@ delimiter ;$$
22302230

22312231
#
22322232
# Bug#15192: "fatal errors" are caught by handlers in stored procedures
2233-
#
2233+
# MDEV-39109 - lower limits for debug sanitizers.
22342234

22352235
set @old_recursion_depth = @@max_sp_recursion_depth;
2236-
set @@max_sp_recursion_depth = 255;
2236+
set @l = 255;
2237+
--disable_warnings
2238+
SELECT IF(global_value like 'MSAN%', 20,
2239+
IF(global_value LIKE 'ASAN%', 200, 255)) INTO @l
2240+
FROM information_schema.system_variables
2241+
WHERE variable_name='have_sanitizer' AND version() LIKE '%debug%';
2242+
--enable_warnings
2243+
set @@max_sp_recursion_depth = @l;
22372244
delimiter |;
22382245
create procedure p1(a int)
22392246
begin
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

0 commit comments

Comments
 (0)