Bug #80789 | "Select" query gives empty result depending on index or spacing in query | ||
---|---|---|---|
Submitted: | 18 Mar 2016 10:22 | Modified: | 4 May 2016 11:50 |
Reporter: | Pavlo Kaidalov | Email Updates: | |
Status: | No Feedback | Impact on me: | |
Category: | MySQL Server: Optimizer | Severity: | S1 (Critical) |
Version: | 5.6.27-29, 5.7.11 | OS: | CentOS (x86_64) |
Assigned to: | CPU Architecture: | Any | |
Tags: | analyze, cache, empty, intersect, query, result, SELECT, wrong |
[18 Mar 2016 10:22]
Pavlo Kaidalov
[21 Mar 2016 17:12]
MySQL Verification Team
Thank you for the bug report. Please provide the test case of your example (create table, insert data, queries, actual result and expected one). Thanks.
[3 Apr 2016 10:04]
Rodrigo Costa
It also affects me. The odd thing is when you run an affected statement, some times the result comes ok and in the majority of times, it comes wrong.... Really important issue...i had to downgrade my mysql instalation to 5.6.25....will not update mysql on production enviroment anymore....
[3 Apr 2016 11:33]
MySQL Verification Team
Hi, 1. can we see a table structure for table1 ? 2. is query cache enabled on the affected server? 2.1 if yes, does 'reset query cache; flush query cache;' fix problem ? 3. does 'flush tables;' also fix it?
[4 Apr 2016 11:12]
Rodrigo Costa
i have downgraded to 5.6.25 and yet the problem keep occurring...so today (in dispear) i downgraded to 5.6.19 (my last know working version)
[4 Apr 2016 11:15]
Rodrigo Costa
my config: query_cache_limit = 1048576 query_cache_min_res_unit = 4096 query_cache_size = 1048576 query_cache_type = OFF query_cache_wlock_invalidate = OFF i think it is related to cache yes, because executing the query that generated the issue, 98% of times we got the wrong result, but in 2% the result is right.
[5 May 2016 1:00]
Bugs System
No feedback was provided for this bug for over a month, so it is being suspended automatically. If you are able to provide the information that was originally requested, please do so and change the status of the bug back to "Open".
[13 Nov 2017 20:25]
Michel Rotta
Same problem on a 5.7 server. The ANALYZE solve the problem. The answer is some thing like: empty set (0.00s) warning 25860. With a very important number of warning. This arrive with a mysql client and the PhpPDO (PHP 7.1) driver, but not with a client Sql.
[6 Jun 2019 21:10]
Kendal Miller
I'm seeing this in mysql 5.6.33 ``` mysql> mysql> show create table users \G *************************** 1. row *************************** Table: users Create Table: CREATE TABLE `users` ( `id` int(11) NOT NULL AUTO_INCREMENT, `first_name` varchar(50) NOT NULL, `last_name` varchar(50) NOT NULL, `active` tinyint(1) NOT NULL DEFAULT '1', `system_account` tinyint(1) NOT NULL DEFAULT '0', `email` varchar(255) NOT NULL, `user_type` varchar(20) NOT NULL, `created_at` datetime DEFAULT NULL, `updated_at` datetime DEFAULT NULL, `sermo_employee` tinyint(1) DEFAULT '0', `eula_date` datetime DEFAULT NULL, `eula_rejected_date` datetime DEFAULT NULL, `reset_password_token` varchar(255) DEFAULT NULL, `reset_password_sent_at` datetime DEFAULT NULL, `remember_created_at` datetime DEFAULT NULL, `sign_in_count` int(11) DEFAULT '0', `current_sign_in_at` datetime DEFAULT NULL, `last_sign_in_at` datetime DEFAULT NULL, `current_sign_in_ip` varchar(255) DEFAULT NULL, `last_sign_in_ip` varchar(255) DEFAULT NULL, `failed_attempts` int(11) DEFAULT '0', `unlock_token` varchar(255) DEFAULT NULL, `locked_at` datetime DEFAULT NULL, `login_token` varchar(255) DEFAULT NULL, `dea_attempt` int(11) DEFAULT '0', `primary_role` varchar(255) DEFAULT NULL, `uuid` varchar(255) DEFAULT NULL, `client_identifier` varchar(255) DEFAULT NULL, `otp_secret_key` varchar(255) DEFAULT NULL, `second_factor_attempts_count` int(11) DEFAULT '0', `mobile_phone` varchar(15) DEFAULT NULL, `master_group_staff_master_group_id` int(11) DEFAULT NULL, `call_center` varchar(255) DEFAULT NULL, `pat_enabled` tinyint(1) NOT NULL DEFAULT '1', `about_me` text, `avatar_file_name` varchar(255) DEFAULT NULL, `avatar_content_type` varchar(255) DEFAULT NULL, `avatar_file_size` int(11) DEFAULT NULL, `avatar_updated_at` datetime DEFAULT NULL, `browser_notifications_enabled` tinyint(1) DEFAULT NULL, `profile_setup_completed_at` datetime DEFAULT NULL, `profile_setup_skip_count` int(11) DEFAULT '0', `profile_setup_last_skipped_at` datetime DEFAULT NULL, `last_synced_at` datetime DEFAULT NULL, `activity_based_on_transition_in_cares` tinyint(1) NOT NULL DEFAULT '0', `county` varchar(255) DEFAULT NULL, `state` varchar(2) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `index_users_on_email` (`email`), UNIQUE KEY `index_users_on_reset_password_token` (`reset_password_token`), UNIQUE KEY `index_users_on_unlock_token` (`unlock_token`), UNIQUE KEY `index_users_on_uuid` (`uuid`), UNIQUE KEY `index_users_on_otp_secret_key` (`otp_secret_key`), KEY `index_users_on_active` (`active`), KEY `index_users_on_created_at` (`created_at`), KEY `index_users_on_first_name` (`first_name`), KEY `index_users_on_last_name` (`last_name`), KEY `index_users_on_sermo_employee` (`sermo_employee`), KEY `index_users_on_user_type` (`user_type`), KEY `index_users_on_client_identifier` (`client_identifier`), KEY `users_master_group_staff_master_group_id_fk` (`master_group_staff_master_group_id`), KEY `index_users_on_last_synced_at` (`last_synced_at`) USING BTREE, FULLTEXT KEY `index_users_on_first_name_and_last_name` (`first_name`,`last_name`), CONSTRAINT `users_master_group_staff_master_group_id_fk` FOREIGN KEY (`master_group_staff_master_group_id`) REFERENCES `master_groups` (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=38498 DEFAULT CHARSET=utf8 1 row in set (0.00 sec) ``` Restarting mysql will fix it. `analyze table users` will fix it. Disabling index_merge will fix it. ``` mysql> SET SESSION optimizer_switch="index_merge_intersection=on"; Query OK, 0 rows affected (0.00 sec) mysql> SELECT SQL_NO_CACHE count(`users`.`id`) FROM `users` WHERE `users`.`user_type` = 'master_group_staff' AND `users`.`master_group_staff_master_group_id` = 35; +---------------------+ | count(`users`.`id`) | +---------------------+ | 0 | +---------------------+ 1 row in set (0.00 sec) mysql> explain SELECT SQL_NO_CACHE count(`users`.`id`) FROM `users` WHERE `users`.`user_type` = 'master_group_staff' AND `users`.`master_group_staff_master_group_id` = 35; +----+-------------+-------+-------------+----------------------------------------------------------------------+----------------------------------------------------------------------+---------+------+------+-----------------------------------------------------------------------------------------------------------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+-------------+-------+-------------+----------------------------------------------------------------------+----------------------------------------------------------------------+---------+------+------+-----------------------------------------------------------------------------------------------------------------+ | 1 | SIMPLE | users | index_merge | index_users_on_user_type,users_master_group_staff_master_group_id_fk | users_master_group_staff_master_group_id_fk,index_users_on_user_type | 5,62 | NULL | 5 | Using intersect(users_master_group_staff_master_group_id_fk,index_users_on_user_type); Using where; Using index | +----+-------------+-------+-------------+----------------------------------------------------------------------+----------------------------------------------------------------------+---------+------+------+-----------------------------------------------------------------------------------------------------------------+ 1 row in set (0.00 sec) mysql> SET SESSION optimizer_switch="index_merge_intersection=off"; Query OK, 0 rows affected (0.00 sec) mysql> explain SELECT SQL_NO_CACHE count(`users`.`id`) FROM `users` WHERE `users`.`user_type` = 'master_group_staff' AND `users`.`master_group_staff_master_group_id` = 35; +----+-------------+-------+------+----------------------------------------------------------------------+---------------------------------------------+---------+-------+------+-------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+-------------+-------+------+----------------------------------------------------------------------+---------------------------------------------+---------+-------+------+-------------+ | 1 | SIMPLE | users | ref | index_users_on_user_type,users_master_group_staff_master_group_id_fk | users_master_group_staff_master_group_id_fk | 5 | const | 38 | Using where | +----+-------------+-------+------+----------------------------------------------------------------------+---------------------------------------------+---------+-------+------+-------------+ 1 row in set (0.00 sec) ```