Bug #113049 MTR test json.array_index fails with a result difference
Submitted: 10 Nov 2023 15:28 Modified: 17 Jan 16:27
Reporter: Laurynas Biveinis (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: JSON Severity:S2 (Serious)
Version:8.0.35, 8.2.0 OS:Any
Assigned to: CPU Architecture:Any

[10 Nov 2023 15:28] Laurynas Biveinis
Description:
$ mtr json.array_index --retry-failure=0
...
[ 50%] json.array_index                          [ fail ]
        Test ended at 2023-11-10 17:26:12

CURRENT_TEST: json.array_index
WARNING: MYSQL_OPT_RECONNECT is deprecated and will be removed in a future version.
WARNING: MYSQL_OPT_RECONNECT is deprecated and will be removed in a future version.
--- /Users/laurynas/vilniusdb/mysql-8.0.35/mysql-test/suite/json/r/array_index.result	2023-10-26 09:13:46
+++ /Users/laurynas/vilniusdb/mysql-8.0.35/_build-release/mysql-test/var/log/array_index.reject	2023-11-10 18:26:12
@@ -1622,11 +1622,11 @@
 where json_overlaps(f1->"$[*]", "[4,3,7]") order by id;
 f1	id
 [0, 5, 7]	0
-[1, 3]	1
 [3, 3, 4, 4, 7]	3
 [5, 6, 7]	5
-[8, 4, 3, 5]	8
+[9, 2, 7]	9
 [9, 2, 7]	9
+[9, 2, 7]	9
 explain select * from t1 force index(i1)
 where json_overlaps(f1->"$[*]", "[4,3,7]") order by id;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra

mysqltest: Result content mismatch

How to repeat:
See above
[13 Nov 2023 9:45] MySQL Verification Team
Hello Laurynas,

Thank you for the report and feedback!
I quickly tried using https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.35-macos13-arm64.tar but not seeing any issues on MacOS(Ventura 13.5.1) and even on OL7(generic binary tarball build) but not observed any issues which is seen in your report. Is there anything I'm missing here? Thank you.

--
./mtr json.array_index --retry-failure=0
Logging: ./mtr  json.array_index --retry-failure=0
MySQL Version 8.0.35
Checking supported features
Using 'all' suites
Collecting tests
Checking leftover processes
Removing old var directory
Creating var directory '/Users/umshastr/Downloads/mysql-8.0.35/mysql-test/var'
Installing system database
Using parallel: 1

==============================================================================
                  TEST NAME                       RESULT  TIME (ms) COMMENT
------------------------------------------------------------------------------
[ 50%] json.array_index                          [ pass ]   2074
[100%] shutdown_report                           [ pass ]       
------------------------------------------------------------------------------
The servers were restarted 0 times
The servers were reinitialized 1 times
Spent 2.074 of 7 seconds executing testcases

Completed: All 2 tests were successful.

regards,
Umesh
[13 Nov 2023 13:38] Laurynas Biveinis
When you test the prebuilt binaries, are they Intel or Apple Silicon or Intel on Apple Silicon through Rosetta 2?

I build from source code using XCode 15.0.1 command line tools. I have tried different CMake option combinations, and they all fail the same:

1) -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Debug -DWITH_DEBUG=ON -DMYSQL_MAINTAINER_MODE=ON -DDOWNLOAD_BOOST=ON -DWITH_BOOST=~/vilniusdb/mysql-boost/ -DWITH_SYSTEM_LIBS=ON -DFORCE_COLORED_OUTPUT=ON
2) -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DBUILD_CONFIG=mysql_release -DCMAKE_BUILD_TYPE=Release -DMYSQL_MAINTAINER_MODE=ON -DDOWNLOAD_BOOST=ON -DWITH_BOOST=~/vilniusdb/mysql-boost/ -DWITH_SYSTEM_LIBS=ON -DFORCE_COLORED_OUTPUT=ON
3) Like 1) but with -DWITH_ASAN=ON -DWITH_ASAN_SCOPE=ON -DWITH_UBSAN=ON
4) -DCMAKE_BUILD_TYPE=Debug -DWITH_DEBUG=ON -DWITH_BOOST=~/vilniusdb/mysql-boost
5) -DCMAKE_BUILD_TYPE=Debug -DWITH_BOOST=~/vilniusdb/mysql-boost
6) -DWITH_BOOST=~/vilniusdb/mysql-boost
7) -DBUILD_CONFIG=mysql_release -DWITH_BOOST=~/vilniusdb/mysql-boost
[16 Nov 2023 10:03] MySQL Verification Team
Thank you, Laurynas.
Verified as described.

Sincerely,
Umesh
[16 Nov 2023 10:38] Laurynas Biveinis
Thank you for verifying. But why the severity of this and sibling bugs has been changed to S7 (Test Cases?) This looks like a silent server miscompilation, I wast thinking S2 at least
[16 Nov 2023 11:21] MySQL Verification Team
Thank you for your feedback.
Usually, during triage this would be corrected but for now changing here.

Sincerely,
Umesh
[17 Nov 2023 16:09] Laurynas Biveinis
Tested a few different compilers.
Failing: XCode 15.0.0, LLVM 15, 16, 17 from Homebrew
Passing: LLVM 14 from Homebrew.
[28 Nov 2023 15:12] Laurynas Biveinis
Exactly the same on 8.2.0, with exactly the same failing/working compiler versions
[28 Nov 2023 15:12] Laurynas Biveinis
Exactly the same on 8.2.0, with exactly the same failing/working compiler versions
[29 Nov 2023 12:20] Tor Didriksen
Posted by developer:
 
Duplicate of
    Bug#36017204 MTR tests for SELECT fail with ICP, MRR, possibly other flags
    
    Recent versions of Clang have changed their implementation of
    std::sort(), and our own 'varlen_sort()' function returns wrong
    results.
    
    The result is that some of our .mtr tests using the MRR strategy are
    failing.
[17 Jan 13:59] Laurynas Biveinis
As I wrote on bug 113046, whose status I cannot change, the fix is not test-only and the bugs are too serious not to have a release notes entry.
[17 Jan 16:14] Tor Didriksen
Posted by developer:
 
yes, and a fix is coming. It affects recent versions of Visual Studio as well.
[17 Jan 16:27] Laurynas Biveinis
I see, thank you Tor!
[17 Jan 16:27] Laurynas Biveinis
I see, thank you Tor!