Skip to content

Commit 835df42

Browse files
committed
Merge branch '10.11' into bb-10.11-release
2 parents 8978a52 + b66db0f commit 835df42

7 files changed

Lines changed: 84 additions & 164 deletions

File tree

mysql-test/main/merge.result

Lines changed: 5 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -3968,73 +3968,18 @@ a
39683968
5
39693969
DROP TABLE t1;
39703970
#
3971-
# End of 10.11 tests
3972-
#
3973-
#
3974-
# MDEV-30088 Assertion `cond_selectivity <= 1.0' failed in get_range_limit_read_cost
3975-
#
3976-
CREATE TABLE t1 (a TIMESTAMP, KEY(a)) ENGINE=MRG_MyISAM;
3977-
explain SELECT a, COUNT(*) FROM t1 WHERE a >= '2000-01-01 00:00:00' GROUP BY a;
3978-
id select_type table type possible_keys key key_len ref rows Extra
3979-
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
3980-
SELECT a, COUNT(*) FROM t1 WHERE a >= '2000-01-01 00:00:00' GROUP BY a;
3981-
a COUNT(*)
3982-
DROP TABLE t1;
3971+
# MDEV-39494 UBSAN failure
39833972
#
3984-
# MDEV-30525: Assertion `ranges > 0' fails in IO_AND_CPU_COST handler::keyread_time
3973+
# This test was ported down from 11.x and was originally implemented under MDEV-30525.
3974+
# Under 10.11, this scenario results in a divide-by-zero failure because there are zero
3975+
# table records available.
39853976
#
39863977
CREATE TABLE t1 (a INT, KEY(a)) ENGINE=MyISAM;
39873978
CREATE TABLE t2 (a INT, KEY(a)) ENGINE=MyISAM;
39883979
CREATE TABLE tm (a INT, KEY(a)) ENGINE=MRG_MyISAM UNION=(t1,t2);
39893980
SELECT DISTINCT a FROM tm WHERE a > 50;
39903981
a
39913982
DROP TABLE tm, t1, t2;
3992-
# Testcase 2:
3993-
CREATE TABLE t1 (a INT, KEY(a)) ENGINE=MyISAM;
3994-
CREATE TABLE t2 (a INT, KEY(a)) ENGINE=MyISAM;
3995-
CREATE TABLE tm (a INT, KEY(a)) ENGINE=MERGE UNION = (t1, t2) INSERT_METHOD=FIRST;
3996-
ANALYZE TABLE tm PERSISTENT FOR ALL;
3997-
Table Op Msg_type Msg_text
3998-
test.tm analyze status Engine-independent statistics collected
3999-
test.tm analyze note The storage engine for the table doesn't support analyze
4000-
SELECT DISTINCT a FROM (SELECT * FROM tm WHERE a iS NOT NULL) AS sq;
4001-
a
4002-
DROP TABLE tm, t1, t2;
4003-
#
4004-
# MDEV-30568 Assertion `cond_selectivity <= 1.000000001' failed in get_range_limit_read_cost
4005-
#
4006-
CREATE TABLE t1 (f INT, KEY(f)) ENGINE=MyISAM;
4007-
CREATE TABLE t2 (f INT, KEY(f)) ENGINE=MyISAM;
4008-
CREATE TABLE tm (f INT, KEY(f)) ENGINE=MERGE UNION = (t1, t2);
4009-
SELECT DISTINCT f FROM tm WHERE f IN (47, 126, 97, 48, 73, 0);
4010-
f
4011-
DROP TABLE tm, t1, t2;
4012-
#
4013-
# MDEV-30786 SIGFPE in cost_group_min_max on EXP
4014-
#
4015-
SET use_stat_tables='preferably';
4016-
CREATE TABLE t1 (a INT,b INT,KEY i1 (a),KEY i2 (b)) ENGINE=MRG_MyISAM;
4017-
ANALYZE LOCAL TABLE t1;
4018-
Table Op Msg_type Msg_text
4019-
test.t1 analyze status Engine-independent statistics collected
4020-
test.t1 analyze note The storage engine for the table doesn't support analyze
4021-
EXPLAIN SELECT DISTINCT a FROM t1;
4022-
id select_type table type possible_keys key key_len ref rows Extra
4023-
1 SIMPLE t1 range NULL i1 5 NULL 1 Using index for group-by
4024-
drop table t1;
4025-
set use_stat_tables=default;
4026-
#
4027-
# End of 11.0 tests
4028-
#
4029-
#
4030-
# MDEV-29174: UPDATE of view that uses MERGE table
4031-
#
4032-
CREATE TABLE t1 (a int) ENGINE=MERGE;
4033-
CREATE VIEW v1 AS SELECT a FROM t1;
4034-
UPDATE v1 SET a=0;
4035-
DROP VIEW v1;
4036-
DROP TABLE t1;
4037-
# End of 11.1 tests
40383983
#
40393984
# MDEV-38474 Double free or corruption, ASAN heap-use-after-free in st_join_table::cleanup
40403985
#
@@ -4061,5 +4006,5 @@ UPDATE t1 STRAIGHT_JOIN t2 SET a = 89 WHERE 9 IN (SELECT c FROM t3 WHERE c IN (S
40614006
ERROR HY000: You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column
40624007
DROP TABLE t1, t2, t3, t4;
40634008
#
4064-
# End of 11.4 tests
4009+
# End of 10.11 tests
40654010
#

mysql-test/main/merge.test

Lines changed: 6 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -2903,69 +2903,19 @@ EXECUTE nested;
29032903
DROP TABLE t1;
29042904

29052905
--echo #
2906-
--echo # End of 10.11 tests
2907-
--echo #
2908-
2909-
--echo #
2910-
--echo # MDEV-30088 Assertion `cond_selectivity <= 1.0' failed in get_range_limit_read_cost
2911-
--echo #
2912-
2913-
CREATE TABLE t1 (a TIMESTAMP, KEY(a)) ENGINE=MRG_MyISAM;
2914-
explain SELECT a, COUNT(*) FROM t1 WHERE a >= '2000-01-01 00:00:00' GROUP BY a;
2915-
SELECT a, COUNT(*) FROM t1 WHERE a >= '2000-01-01 00:00:00' GROUP BY a;
2916-
DROP TABLE t1;
2917-
2906+
--echo # MDEV-39494 UBSAN failure
29182907
--echo #
2919-
--echo # MDEV-30525: Assertion `ranges > 0' fails in IO_AND_CPU_COST handler::keyread_time
2908+
--echo # This test was ported down from 11.x and was originally implemented under MDEV-30525.
2909+
--echo # Under 10.11, this scenario results in a divide-by-zero failure because there are zero
2910+
--echo # table records available.
29202911
--echo #
29212912
CREATE TABLE t1 (a INT, KEY(a)) ENGINE=MyISAM;
29222913
CREATE TABLE t2 (a INT, KEY(a)) ENGINE=MyISAM;
29232914
CREATE TABLE tm (a INT, KEY(a)) ENGINE=MRG_MyISAM UNION=(t1,t2);
2915+
# Must have zero records to produce UBSAN failure on divide-by-zero.
29242916
SELECT DISTINCT a FROM tm WHERE a > 50;
29252917
DROP TABLE tm, t1, t2;
29262918

2927-
--echo # Testcase 2:
2928-
CREATE TABLE t1 (a INT, KEY(a)) ENGINE=MyISAM;
2929-
CREATE TABLE t2 (a INT, KEY(a)) ENGINE=MyISAM;
2930-
CREATE TABLE tm (a INT, KEY(a)) ENGINE=MERGE UNION = (t1, t2) INSERT_METHOD=FIRST;
2931-
ANALYZE TABLE tm PERSISTENT FOR ALL;
2932-
SELECT DISTINCT a FROM (SELECT * FROM tm WHERE a iS NOT NULL) AS sq;
2933-
DROP TABLE tm, t1, t2;
2934-
2935-
--echo #
2936-
--echo # MDEV-30568 Assertion `cond_selectivity <= 1.000000001' failed in get_range_limit_read_cost
2937-
--echo #
2938-
CREATE TABLE t1 (f INT, KEY(f)) ENGINE=MyISAM;
2939-
CREATE TABLE t2 (f INT, KEY(f)) ENGINE=MyISAM;
2940-
CREATE TABLE tm (f INT, KEY(f)) ENGINE=MERGE UNION = (t1, t2);
2941-
SELECT DISTINCT f FROM tm WHERE f IN (47, 126, 97, 48, 73, 0);
2942-
DROP TABLE tm, t1, t2;
2943-
2944-
--echo #
2945-
--echo # MDEV-30786 SIGFPE in cost_group_min_max on EXP
2946-
--echo #
2947-
SET use_stat_tables='preferably';
2948-
CREATE TABLE t1 (a INT,b INT,KEY i1 (a),KEY i2 (b)) ENGINE=MRG_MyISAM;
2949-
ANALYZE LOCAL TABLE t1;
2950-
EXPLAIN SELECT DISTINCT a FROM t1;
2951-
drop table t1;
2952-
set use_stat_tables=default;
2953-
2954-
--echo #
2955-
--echo # End of 11.0 tests
2956-
--echo #
2957-
--echo #
2958-
--echo # MDEV-29174: UPDATE of view that uses MERGE table
2959-
--echo #
2960-
2961-
CREATE TABLE t1 (a int) ENGINE=MERGE;
2962-
CREATE VIEW v1 AS SELECT a FROM t1;
2963-
UPDATE v1 SET a=0;
2964-
DROP VIEW v1;
2965-
DROP TABLE t1;
2966-
2967-
--echo # End of 11.1 tests
2968-
29692919
--echo #
29702920
--echo # MDEV-38474 Double free or corruption, ASAN heap-use-after-free in st_join_table::cleanup
29712921
--echo #
@@ -2997,6 +2947,5 @@ UPDATE t1 STRAIGHT_JOIN t2 SET a = 89 WHERE 9 IN (SELECT c FROM t3 WHERE c IN (S
29972947
DROP TABLE t1, t2, t3, t4;
29982948

29992949
--echo #
3000-
--echo # End of 11.4 tests
2950+
--echo # End of 10.11 tests
30012951
--echo #
3002-

sql/opt_range.cc

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15071,8 +15071,16 @@ void cost_group_min_max(TABLE* table, KEY *index_info, uint used_key_parts,
1507115071
keys_per_group= (table_records / 10) + 1;
1507215072
num_groups= (table_records / keys_per_group) + 1;
1507315073

15074-
/* Apply the selectivity of the quick select for group prefixes. */
15075-
if (range_tree && (quick_prefix_records != HA_POS_ERROR))
15074+
DBUG_ASSERT(keys_per_group > 0);
15075+
DBUG_ASSERT(num_groups > 0);
15076+
15077+
/*
15078+
Apply the selectivity of the quick select for group prefixes.
15079+
15080+
If there are no records in the table, then there's nothing to select so
15081+
let num_groups continue to be 1 as set above.
15082+
*/
15083+
if (range_tree && (quick_prefix_records != HA_POS_ERROR) && table_records > 0)
1507615084
{
1507715085
quick_prefix_selectivity= (double) quick_prefix_records /
1507815086
(double) table_records;

storage/innobase/buf/buf0flu.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1966,6 +1966,7 @@ inline void log_t::write_checkpoint(lsn_t checkpoint, lsn_t end_lsn) noexcept
19661966
static void log_checkpoint_low(lsn_t oldest_lsn, lsn_t end_lsn) noexcept
19671967
{
19681968
ut_ad(!srv_read_only_mode);
1969+
ut_ad(!recv_no_log_write);
19691970
ut_ad(log_sys.latch_have_wr());
19701971
ut_ad(oldest_lsn <= end_lsn);
19711972
ut_ad(end_lsn == log_sys.get_lsn());
@@ -2550,6 +2551,11 @@ static void buf_flush_page_cleaner() noexcept
25502551
{
25512552
if (recv_recovery_is_on())
25522553
continue;
2554+
#ifdef WITH_WSREP
2555+
extern Atomic_relaxed<bool> wsrep_sst_disable_writes;
2556+
if (UNIV_UNLIKELY(wsrep_sst_disable_writes))
2557+
continue; /* See sst_disable_innodb_writes() */
2558+
#endif
25532559
IF_DBUG(if (log_sys.last_checkpoint_lsn &&
25542560
srv_shutdown_state < SRV_SHUTDOWN_CLEANUP &&
25552561
(_db_keyword_(nullptr, "ib_log_checkpoint_avoid", 1) ||

storage/innobase/fts/fts0opt.cc

Lines changed: 38 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,6 @@ Completed 2011/7/10 Sunny and Jimmy Yang
3737
#include "zlib.h"
3838
#include "fts0opt.h"
3939
#include "fts0vlc.h"
40-
#include "wsrep.h"
41-
42-
#ifdef WITH_WSREP
43-
extern Atomic_relaxed<bool> wsrep_sst_disable_writes;
44-
#else
45-
constexpr bool wsrep_sst_disable_writes= false;
46-
#endif
4740

4841
/** The FTS optimize thread's work queue. */
4942
ib_wqueue_t* fts_optimize_wq;
@@ -52,7 +45,7 @@ static void timer_callback(void*);
5245
static tpool::timer* timer;
5346

5447
static tpool::task_group task_group(1);
55-
static tpool::task task(fts_optimize_callback,0, &task_group);
48+
static tpool::waitable_task task(fts_optimize_callback,0, &task_group);
5649

5750
/** FTS optimize thread, for MDL acquisition */
5851
static THD *fts_opt_thd;
@@ -230,7 +223,7 @@ ulong fts_num_word_optimize;
230223
char fts_enable_diag_print;
231224

232225
/** ZLib compressed block size.*/
233-
static ulint FTS_ZIP_BLOCK_SIZE = 1024;
226+
static constexpr ulint FTS_ZIP_BLOCK_SIZE = 1024;
234227

235228
/** The amount of time optimizing in a single pass, in seconds. */
236229
static ulint fts_optimize_time_limit;
@@ -2831,6 +2824,10 @@ static void fts_optimize_callback(void *)
28312824
static ulint n_tables = ib_vector_size(fts_slots);
28322825

28332826
while (!done && srv_shutdown_state <= SRV_SHUTDOWN_INITIATED) {
2827+
#ifdef WITH_WSREP
2828+
ut_d(extern Atomic_relaxed<bool> wsrep_sst_disable_writes);
2829+
ut_ad(!wsrep_sst_disable_writes);
2830+
#endif
28342831
/* If there is no message in the queue and we have tables
28352832
to optimize then optimize the tables. */
28362833

@@ -2841,17 +2838,6 @@ static void fts_optimize_callback(void *)
28412838

28422839
/* The queue is empty but we have tables
28432840
to optimize. */
2844-
if (UNIV_UNLIKELY(wsrep_sst_disable_writes)) {
2845-
retry_later:
2846-
if (fts_is_sync_needed()) {
2847-
fts_need_sync = true;
2848-
}
2849-
if (n_tables) {
2850-
timer->set_time(5000, 0);
2851-
}
2852-
return;
2853-
}
2854-
28552841
fts_slot_t* slot = static_cast<fts_slot_t*>(
28562842
ib_vector_get(fts_slots, current));
28572843

@@ -2872,7 +2858,13 @@ static void fts_optimize_callback(void *)
28722858
(ib_wqueue_nowait(fts_optimize_wq));
28732859
/* Timeout ? */
28742860
if (!msg) {
2875-
goto retry_later;
2861+
if (fts_is_sync_needed()) {
2862+
fts_need_sync = true;
2863+
}
2864+
if (n_tables) {
2865+
timer->set_time(5000, 0);
2866+
}
2867+
return;
28762868
}
28772869

28782870
switch (msg->type) {
@@ -2898,11 +2890,6 @@ static void fts_optimize_callback(void *)
28982890
break;
28992891

29002892
case FTS_MSG_SYNC_TABLE:
2901-
if (UNIV_UNLIKELY(wsrep_sst_disable_writes)) {
2902-
add_msg(msg);
2903-
goto retry_later;
2904-
}
2905-
29062893
DBUG_EXECUTE_IF(
29072894
"fts_instrument_msg_sync_sleep",
29082895
std::this_thread::sleep_for(
@@ -2945,11 +2932,8 @@ static void fts_optimize_callback(void *)
29452932
ib::info() << "FTS optimize thread exiting.";
29462933
}
29472934

2948-
/**********************************************************************//**
2949-
Startup the optimize thread and create the work queue. */
2950-
void
2951-
fts_optimize_init(void)
2952-
/*===================*/
2935+
/** Startup the optimize task and create the work queue. */
2936+
void fts_optimize_init()
29532937
{
29542938
mem_heap_t* heap;
29552939
ib_alloc_t* heap_alloc;
@@ -2993,9 +2977,8 @@ fts_optimize_init(void)
29932977
last_check_sync_time = time(NULL);
29942978
}
29952979

2996-
/** Shutdown fts optimize thread. */
2997-
void
2998-
fts_optimize_shutdown()
2980+
/** Shut down the fts optimize thread. */
2981+
void fts_optimize_shutdown()
29992982
{
30002983
ut_ad(!srv_read_only_mode);
30012984

@@ -3004,7 +2987,7 @@ fts_optimize_shutdown()
30042987
dict_sys.freeze(SRW_LOCK_CALL);
30052988
mysql_mutex_lock(&fts_optimize_wq->mutex);
30062989
/* Tells FTS optimizer system that we are exiting from
3007-
optimizer thread, message send their after will not be
2990+
optimizer thread, messages sent thereafter will not be
30082991
processed */
30092992
fts_opt_start_shutdown = true;
30102993
dict_sys.unfreeze();
@@ -3034,6 +3017,26 @@ fts_optimize_shutdown()
30343017
timer = NULL;
30353018
}
30363019

3020+
#ifdef WITH_WSREP
3021+
/** Pause the optimize subsystem. */
3022+
void fts_optimize_pause()
3023+
{
3024+
ut_ad(!srv_read_only_mode);
3025+
/* Prevent fts_optimize_callback() from being scheduled. */
3026+
timer->disarm();
3027+
/* Wait for any current fts_optimize_callback() to finish. */
3028+
task.wait();
3029+
}
3030+
3031+
/** Resume after fts_optimize_stop() */
3032+
void fts_optimize_resume()
3033+
{
3034+
/* Schedule fts_optimize_callback() immediately.
3035+
It will reschedule itself via the timer when needed. */
3036+
srv_thread_pool->submit_task(&task);
3037+
}
3038+
#endif
3039+
30373040
/** Sync the table during commit phase
30383041
@param[in] table table to be synced */
30393042
void fts_sync_during_ddl(dict_table_t* table)

storage/innobase/handler/ha_innodb.cc

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1779,9 +1779,10 @@ static void sst_disable_innodb_writes()
17791779
fil_crypt_set_thread_cnt(0);
17801780
srv_n_fil_crypt_threads= old_count;
17811781

1782-
wsrep_sst_disable_writes= true;
17831782
dict_stats_shutdown();
1783+
fts_optimize_pause();
17841784
purge_sys.stop();
1785+
17851786
/* We are holding a global MDL thanks to FLUSH TABLES WITH READ LOCK.
17861787

17871788
That will prevent any writes from arriving into InnoDB, but it will
@@ -1793,10 +1794,12 @@ static void sst_disable_innodb_writes()
17931794
possible during the snapshot, and to guarantee that no crash
17941795
recovery will be necessary when starting up on the snapshot. */
17951796
log_make_checkpoint();
1797+
wsrep_sst_disable_writes= true;
17961798
/* If any FILE_MODIFY records were written by the checkpoint, an
17971799
extra write of a FILE_CHECKPOINT record could still be invoked by
1798-
buf_flush_page_cleaner(). Let us prevent that by invoking another
1799-
checkpoint (which will write the FILE_CHECKPOINT record). */
1800+
buf_flush_page_cleaner(). Let us ensure that the page cleaner
1801+
is idle and will observe our above assignment (not write anything
1802+
further to the log). */
18001803
log_make_checkpoint();
18011804
ut_d(recv_no_log_write= true);
18021805
/* If this were not a no-op, an assertion would fail due to
@@ -1811,6 +1814,8 @@ static void sst_enable_innodb_writes()
18111814
dict_stats_start();
18121815
purge_sys.resume();
18131816
wsrep_sst_disable_writes= false;
1817+
/* Allow fts_optimize_callback() to assert that the flag is clear. */
1818+
fts_optimize_resume();
18141819
const uint old_count= srv_n_fil_crypt_threads;
18151820
srv_n_fil_crypt_threads= 0;
18161821
fil_crypt_set_thread_cnt(old_count);

0 commit comments

Comments
 (0)