Making UNION causes error:
Can not read response from server. Expected to read 4 bytes, read 0 bytes before connection was unexpectedly lost.
MySQL server just shuts down during query execution.
The query is next:
WITH inner_table AS (
...Some complex query...
)
(SELECT 'name' AS field, inner_table.name as value, COUNT(*) as cnt FROM inner_table
WHERE inner_table.site_url IN ("http://somesite.pro") AND inner_table.hold = "different"
GROUP BY value ORDER BY cnt DESC, value LIMIT 100 OFFSET 0)
UNION
(SELECT 'site_url' AS field, inner_table.site_url as value, COUNT(*) as cnt FROM inner_table
WHERE inner_table.name IN ("Some name","Another name")
AND inner_table.hold = "different"
GROUP BY value ORDER BY cnt DESC, value LIMIT 100 OFFSET 0)
Both result queries are empty (and they must be).
If I switch UNION queries – no error, ok:
(SELECT 'site_url' AS field, inner_table.site_url as value, COUNT(*) as cnt FROM inner_table
WHERE inner_table.name IN ("Some name","Another name")
AND inner_table.hold = "different"
GROUP BY value ORDER BY cnt DESC, value LIMIT 100 OFFSET 0)
UNION
(SELECT 'name' AS field, inner_table.name as value, COUNT(*) as cnt FROM inner_table
WHERE inner_table.site_url IN ("http://somesite.pro") AND inner_table.hold = "different"
GROUP BY value ORDER BY cnt DESC, value LIMIT 100 OFFSET 0)
Error stack:
08:07:30 UTC – mysqld got signal 11 ;
2024-06-05T08:07:30.738869360Z Most likely, you have hit a bug, but this error can also be caused by malfunctioning hardware.
2024-06-05T08:07:30.738871665Z Thread pointer: 0x7fe8a4000f80
2024-06-05T08:07:30.738873848Z Attempting backtrace. You can use the following information to find out
2024-06-05T08:07:30.738875996Z where mysqld died. If you see no messages after this, something went
2024-06-05T08:07:30.738878011Z terribly wrong…
2024-06-05T08:07:30.738936962Z stack_bottom = 7fe9145f5d90 thread_stack 0x100000
2024-06-05T08:07:30.751991930Z /usr/sbin/mysqld(my_print_stacktrace(unsigned char const*, unsigned long)+0x3d) [0x560be3a9457d]
2024-06-05T08:07:30.752009782Z /usr/sbin/mysqld(print_fatal_signal(int)+0x303) [0x560be2b11453]
…
MYSQL_VERSION=8.0.28-1debian10
Could anyone help how to solve this problem?