Bug #87190 Test main.group_by is unstable
Submitted: 26 Jul 2017 3:07 Modified: 1 Feb 2018 5:10
Reporter: Laurynas Biveinis (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:Tests: Server Severity:S3 (Non-critical)
Version:8.0.2,8.0.4 OS:Any
Assigned to: CPU Architecture:Any
Tags: mtr

[26 Jul 2017 3:07] Laurynas Biveinis
Description:
main.group_by                            w2 [ fail ]
        Test ended at 2017-07-24 09:42:08

CURRENT_TEST: main.group_by
--- /mnt/workspace/mysql-5.7-param/BUILD_TYPE/debug/Host/debian-jessie-64bit/mysql-test/r/group_by.result	2017-07-24 08:54:26.820898000 +0300
+++ /mnt/workspace/mysql-5.7-param/BUILD_TYPE/debug/Host/debian-jessie-64bit/build/mysql-test/var/2/log/group_by.reject	2017-07-24 12:42:07.820515578 +0300
@@ -1721,7 +1721,7 @@
 Note	1003	/* select#1 */ select `test`.`t2`.`a` AS `a`,sum(`test`.`t2`.`b`) AS `SUM(b)` from `test`.`t2` group by `test`.`t2`.`a` limit 2
 EXPLAIN SELECT a, SUM(b) FROM t2 IGNORE INDEX (a) GROUP BY a LIMIT 2;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
-1	SIMPLE	t2	NULL	ALL	a	NULL	NULL	NULL	4	100.00	Using temporary
+1	SIMPLE	t2	NULL	ALL	a	NULL	NULL	NULL	5	100.00	Using temporary
 Warnings:
 Note	1003	/* select#1 */ select `test`.`t2`.`a` AS `a`,sum(`test`.`t2`.`b`) AS `SUM(b)` from `test`.`t2` IGNORE INDEX (`a`) group by `test`.`t2`.`a` limit 2
 ANALYZE TABLE t2;

mysqltest: Result content mismatch

How to repeat:
Repeats pretty much deterministically on the first run on my Mac, debug/ASan 8.0.2 server build. Otherwise is seen sooner or later with MTR --repeat and side load.
[1 Aug 2017 7:38] MySQL Verification Team
Hello Laurynas,

Thank you for the report.
I could not repeat the issue at my end(Sierra MacOS, Ubuntu 16.04.02/16.10/17.04, Debian 8 and OL7), anything else required(cmake, os etc details) to trigger the issue? Please let me know.

I have built 8.0.2 w/ and w/o -DWITH_ASAN=ON 

cmake . -DENABLE_DOWNLOADS=1 -DWITH_BOOST=./boost/ -DWITH_DEBUG=ON

Thanks,
Umesh
[2 Aug 2017 3:36] Laurynas Biveinis
I am re-testing this from a clean state and for some reason cannot repeat it anymore myself. It is possible I have previously used patched 8.0.2 instead of a clean mysql-8.0.2, invalidating this report. I will re-open if it reoccurs.
[2 Aug 2017 14:41] Laurynas Biveinis
It is repeatable with stock MySQL 8.0.2 - cmake options -DBUILD_CONFIG=mysql_release -DWITH_DEBUG=ON -DWITH_ASAN=ON -DWITH_BOOST=... -DWITH_OPENSSL=/path/to/homebrew/OpenSSL -DWITH_ZLIB=system -DWITH_LZ4=system -DENABLE_DOWNLOADS=ON on macOS 10.12.6, XCode 8.3.3.

The reduced bit of the testcase is

CREATE TABLE t2 (a INT, b INT, KEY(a));
INSERT INTO t2 VALUES (1, 1), (2, 2), (3,3), (4,4);
EXPLAIN SELECT a, SUM(b) FROM t2 IGNORE INDEX (a) GROUP BY a LIMIT 2;

DROP TABLE t2;

Put it in e.g. foo.test, then

$ ./mtr --debug-server foo --repeat=1000
...
CREATE TABLE t2 (a INT, b INT, KEY(a));
INSERT INTO t2 VALUES (1, 1), (2, 2), (3,3), (4,4);
EXPLAIN SELECT a, SUM(b) FROM t2 IGNORE INDEX (a) GROUP BY a LIMIT 2;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t2	NULL	ALL	a	NULL	NULL	NULL	4	100.00	Using temporary
Warnings:
Note	1003	/* select#1 */ select `test`.`t2`.`a` AS `a`,sum(`test`.`t2`.`b`) AS `SUM(b)` from `test`.`t2` IGNORE INDEX (`a`) group by `test`.`t2`.`a` limit 2
DROP TABLE t2;
main.foo                                 [ pass ]    284
CREATE TABLE t2 (a INT, b INT, KEY(a));
INSERT INTO t2 VALUES (1, 1), (2, 2), (3,3), (4,4);
EXPLAIN SELECT a, SUM(b) FROM t2 IGNORE INDEX (a) GROUP BY a LIMIT 2;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t2	NULL	ALL	a	NULL	NULL	NULL	5	100.00	Using temporary
Warnings:
Note	1003	/* select#1 */ select `test`.`t2`.`a` AS `a`,sum(`test`.`t2`.`b`) AS `SUM(b)` from `test`.`t2` IGNORE INDEX (`a`) group by `test`.`t2`.`a` limit 2
DROP TABLE t2;
main.foo                                 [ pass ]    257
^Cmysql-test-run: *** ERROR: Got ^C signal

Observe rows in EXPLAIN output varying between 4 and 5. Or, record either output, then wait for it to fail wit h a large --repeat.
[3 Aug 2017 8:13] MySQL Verification Team
Thank you Laurynas, with the provided cmake I'm able to see the reported inconsistency.

../cmake-3.8.1/bin/cmake . -DBUILD_CONFIG=mysql_release -DWITH_DEBUG=ON -DWITH_ASAN=ON -DWITH_BOOST=./boost/  -DWITH_ZLIB=system  -DENABLE_DOWNLOADS=ON

make

umshastr:mysql-test umshastr$ clang --version
Apple LLVM version 8.1.0 (clang-802.0.42)
Target: x86_64-apple-darwin16.7.0
Thread model: posix

umshastr:mysql-test umshastr$ ./mtr --debug-server foo --repeat=1000
Logging: ./mtr  --debug-server foo --repeat=1000
MySQL Version 8.0.2
Checking supported features...
 - SSL connections supported
 - binaries are debug compiled
Collecting tests...
Removing old var directory...
Creating var directory '/Users/umshastr/Downloads/mysql-8.0.2-dmr/mysql-test/var'...
Installing system database...
Using parallel: 1

==============================================================================

TEST                                      RESULT   TIME (ms) or COMMENT
--------------------------------------------------------------------------

worker[1] Using MTR_BUILD_THREAD 300, with reserved ports 13000..13009
CREATE TABLE t2 (a INT, b INT, KEY(a));
INSERT INTO t2 VALUES (1, 1), (2, 2), (3,3), (4,4);
EXPLAIN SELECT a, SUM(b) FROM t2 IGNORE INDEX (a) GROUP BY a LIMIT 2;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t2	NULL	ALL	a	NULL	NULL	NULL	5	100.00	Using temporary
Warnings:
Note	1003	/* select#1 */ select `test`.`t2`.`a` AS `a`,sum(`test`.`t2`.`b`) AS `SUM(b)` from `test`.`t2` IGNORE INDEX (`a`) group by `test`.`t2`.`a` limit 2
DROP TABLE t2;
main.foo                                 [ pass ]    220
CREATE TABLE t2 (a INT, b INT, KEY(a));
INSERT INTO t2 VALUES (1, 1), (2, 2), (3,3), (4,4);
EXPLAIN SELECT a, SUM(b) FROM t2 IGNORE INDEX (a) GROUP BY a LIMIT 2;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t2	NULL	ALL	a	NULL	NULL	NULL	5	100.00	Using temporary
Warnings:
Note	1003	/* select#1 */ select `test`.`t2`.`a` AS `a`,sum(`test`.`t2`.`b`) AS `SUM(b)` from `test`.`t2` IGNORE INDEX (`a`) group by `test`.`t2`.`a` limit 2
DROP TABLE t2;
main.foo                                 [ pass ]    186
CREATE TABLE t2 (a INT, b INT, KEY(a));
INSERT INTO t2 VALUES (1, 1), (2, 2), (3,3), (4,4);
EXPLAIN SELECT a, SUM(b) FROM t2 IGNORE INDEX (a) GROUP BY a LIMIT 2;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t2	NULL	ALL	a	NULL	NULL	NULL	4	100.00	Using temporary
Warnings:
Note	1003	/* select#1 */ select `test`.`t2`.`a` AS `a`,sum(`test`.`t2`.`b`) AS `SUM(b)` from `test`.`t2` IGNORE INDEX (`a`) group by `test`.`t2`.`a` limit 2
DROP TABLE t2;
main.foo                                 [ pass ]    253
[1 Feb 2018 5:10] Laurynas Biveinis
Seen on 8.0.4