[MDEV-2758] LP:608744 - RQG: assertion "idx >= 1 && idx <= queue->elements" in queue_remove() Created: 2010-07-22  Updated: 2015-02-02  Resolved: 2012-10-04

Status: Closed
Project: MariaDB Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Philip Stoev (Inactive) Assignee: Timour Katchaounov (Inactive)
Resolution: Fixed Votes: 0
Labels: Launchpad

Attachments: XML File LPexportBug608744.xml    

 Description   

The query from the test below asserts as follows:

mysqld: queues.c:268: queue_remove: Assertion `idx >= 1 && idx <= queue->elements' failed.

backtrace:

  1. 2010-07-22T16:14:54 #8 0x00133de8 in __assert_fail () from /lib/libc.so.6
  2. 2010-07-22T16:14:54 #9 0x08735e48 in queue_remove (queue=0x0, idx=0) at queues.c:268
  3. 2010-07-22T16:14:54 #10 0x08239d26 in subselect_rowid_merge_engine::partial_match (this=0xb6c32b30) at item_subselect.cc:5059
  4. 2010-07-22T16:14:54 #11 0x08238f94 in subselect_partial_match_engine::exec (this=0xb6c32b30) at item_subselect.cc:4684
  5. 2010-07-22T16:14:54 #12 0x0822f9e3 in Item_subselect::exec (this=0x99b14f28) at item_subselect.cc:481
  6. 2010-07-22T16:14:54 #13 0x0822fbdc in Item_in_subselect::exec (this=0x99b14f28) at item_subselect.cc:578
  7. 2010-07-22T16:14:54 #14 0x08231444 in Item_in_subselect::val_bool (this=0x99b14f28) at item_subselect.cc:1246
  8. 2010-07-22T16:14:54 #15 0x081cf35a in Item::val_bool_result (this=0x99b14f28) at item.h:783
  9. 2010-07-22T16:14:54 #16 0x081fa9cf in Item_in_optimizer::val_int (this=0x99b249f0) at item_cmpfunc.cc:1873
  10. 2010-07-22T16:14:54 #17 0x081cf2fc in Item::val_int_result (this=0x99b249f0) at item.h:779
  11. 2010-07-22T16:14:54 #18 0x081cb196 in Item_cache_int::cache_value (this=0xb6ce65e8) at item.cc:7712
  12. 2010-07-22T16:14:54 #19 0x081d2f4c in Item_cache_wrapper::cache (this=0xb6ce6588) at item.cc:6725
  13. 2010-07-22T16:14:54 #20 0x081c8e09 in Item_cache_wrapper::val_bool (this=0xb6ce6588) at item.cc:6889
  14. 2010-07-22T16:14:54 #21 0x081f6d89 in Item_func_not::val_int (this=0x99b15040) at item_cmpfunc.cc:287
  15. 2010-07-22T16:14:54 #22 0x081b8ec6 in Item::val_bool (this=0x99b15040) at item.cc:187
  16. 2010-07-22T16:14:54 #23 0x0820274f in Item_cond_or::val_int (this=0x99b26058) at item_cmpfunc.cc:4566
  17. 2010-07-22T16:14:54 #24 0x0823a465 in Item_func_trig_cond::val_int (this=0x99b261b8) at item_cmpfunc.h:444
  18. 2010-07-22T16:14:54 #25 0x081b8ec6 in Item::val_bool (this=0x99b261b8) at item.cc:187
  19. 2010-07-22T16:14:54 #26 0x08202669 in Item_cond_and::val_int (this=0xb6ce5928) at item_cmpfunc.cc:4548
  20. 2010-07-22T16:14:54 #27 0x0831dc3e in evaluate_join_record (join=0xb6cdbb20, join_tab=0x99b25b48, error=0) at sql_select.cc:13197
  21. 2010-07-22T16:14:54 #28 0x0831d9fd in sub_select (join=0xb6cdbb20, join_tab=0x99b25b48, end_of_records=false) at sql_select.cc:13142
  22. 2010-07-22T16:14:54 #29 0x0831df08 in evaluate_join_record (join=0xb6cdbb20, join_tab=0x99b25988, error=0) at sql_select.cc:13294
  23. 2010-07-22T16:14:54 #30 0x0831d8af in sub_select (join=0xb6cdbb20, join_tab=0x99b25988, end_of_records=false) at sql_select.cc:13103
  24. 2010-07-22T16:14:54 #31 0x0831ccae in do_select (join=0xb6cdbb20, fields=0x0, table=0xb6ce97b0, procedure=0x0) at sql_select.cc:12649
  25. 2010-07-22T16:14:54 #32 0x083014b1 in JOIN::exec (this=0xb6cdbb20) at sql_select.cc:1933
  26. 2010-07-22T16:14:54 #33 0x08303802 in mysql_select (thd=0xbbb6fc0, rref_pointer_array=0xbbb8a34, tables=0xb6c23c80, wild_num=0, fields=..., conds=0x99b156c8, og_num=3,
  27. 2010-07-22T16:14:54 order=0x99b24538, group=0x99b15778, having=0x0, proc_param=0x0, select_options=2147764736, result=0x99b245e0, unit=0xbbb8698, select_lex=0xbbb8930)
  28. 2010-07-22T16:14:54 at sql_select.cc:2556
  29. 2010-07-22T16:14:54 #34 0x082fbecf in handle_select (thd=0xbbb6fc0, lex=0xbbb863c, result=0x99b245e0, setup_tables_done_option=0) at sql_select.cc:276
  30. 2010-07-22T16:14:54 #35 0x0829a5f0 in execute_sqlcom_select (thd=0xbbb6fc0, all_tables=0xb6c23c80) at sql_parse.cc:5081
  31. 2010-07-22T16:14:54 #36 0x08290fd0 in mysql_execute_command (thd=0xbbb6fc0) at sql_parse.cc:2265
  32. 2010-07-22T16:14:54 #37 0x0829c7d1 in mysql_parse (thd=0xbbb6fc0,
  33. 2010-07-22T16:14:54 inBuf=0xb6c23108 "SELECT table1 . `col_int_key` AS field1 , table2 . `col_time_key` AS field2 FROM ( C AS table1 LEFT JOIN C AS table2 ON (table2 . `col_varchar_nokey` = table1 . `col_varchar_key` ) ) WHERE ( ( table2 . `col_varchar_nokey` , table1 . `col_varchar_key` ) NOT IN ( SELECT DISTINCT SUBQUERY1_t1 . `col_varchar_key` AS SUBQUERY1_field1 , SUBQUERY1_t2 . `col_varchar_nokey` AS SUBQUERY1_field2 FROM ( CC AS SUBQUERY1_t1 LEFT JOIN ( CC AS SUBQUERY1_t2 INNER JOIN CC AS SUBQUERY1_t3 ON (SUBQUERY1_t3 . `col_varchar_nokey` = SUBQUERY1_t2 . `col_varchar_key` ) ) ON (SUBQUERY1_t3 . `pk` = SUBQUERY1_t2 . `pk` ) ) WHERE SUBQUERY1_t2 . `col_varchar_nokey` >= SUBQUERY1_t3 . `col_varchar_key` ) ) OR ( table1 . `col_int_nokey` <> table1 . `col_int_key` AND table1 . `col_int_nokey` < table1 . `col_int_key` ) GROUP BY field1, field2 ORDER BY table1 . `col_time_key`", length=864, found_semicolon=0x99eff230)
  34. 2010-07-22T16:14:54 at sql_parse.cc:6027
  35. 2010-07-22T16:14:54 #38 0x0828ea02 in dispatch_command (command=COM_QUERY, thd=0xbbb6fc0,
  36. 2010-07-22T16:14:54 packet=0xbbe3261 " SELECT table1 . `col_int_key` AS field1 , table2 . `col_time_key` AS field2 FROM ( C AS table1 LEFT JOIN C AS table2 ON (table2 . `col_varchar_nokey` = table1 . `col_varchar_key` ) ) WHERE ( ( table2 . `col_varchar_nokey` , table1 . `col_varchar_key` ) NOT IN ( SELECT DISTINCT SUBQUERY1_t1 . `col_varchar_key` AS SUBQUERY1_field1 , SUBQUERY1_t2 . `col_varchar_nokey` AS SUBQUERY1_field2 FROM ( CC AS SUBQUERY1_t1 LEFT JOIN ( CC AS SUBQUERY1_t2 INNER JOIN CC AS SUBQUERY1_t3 ON (SUBQUERY1_t3 . `col_varchar_nokey` = SUBQUERY1_t2 . `col_varchar_key` ) ) ON (SUBQUERY1_t3 . `pk` = SUBQUERY1_t2 . `pk` ) ) WHERE SUBQUERY1_t2 . `col_varchar_nokey` >= SUBQUERY1_t3 . `col_varchar_key` ) ) OR ( table1 . `col_int_nokey` <> table1 . `col_int_key` AND table1 . `col_int_nokey` < table1 . `col_int_key` ) GROUP BY field1, field2 ORDER BY table1 . `col_time_key` ", packet_length=867) at sql_parse.cc:1184
  37. 2010-07-22T16:14:54 #39 0x0828dea8 in do_command (thd=0xbbb6fc0) at sql_parse.cc:890
  38. 2010-07-22T16:14:54 #40 0x0828b008 in handle_one_connection (arg=0xbbb6fc0) at sql_connect.cc:1153
  39. 2010-07-22T16:14:54 #41 0x00a08919 in start_thread () from /lib/libpthread.so.0
  40. 2010-07-22T16:14:54 #42 0x001ede5e in clone () from /lib/libc.so.6
  41. 2010-07-22T16:14:54 #5 0x009b8424 in __kernel_vsyscall ()


 Comments   
Comment by Philip Stoev (Inactive) [ 2010-07-22 ]

Re: RQG: assertion "idx >= 1 && idx <= queue->elements" in queue_remove()
Test case:

CREATE TABLE `CC` (
`pk` int(11) NOT NULL AUTO_INCREMENT,
`col_int_key` int(11) DEFAULT NULL,
`col_time_key` time DEFAULT NULL,
`col_varchar_key` varchar(1) DEFAULT NULL,
`col_varchar_nokey` varchar(1) DEFAULT NULL,
PRIMARY KEY (`pk`),
KEY `col_varchar_key` (`col_varchar_key`,`col_int_key`)
);

INSERT INTO `CC` VALUES (11,9,'19:48:31','r','r');
INSERT INTO `CC` VALUES (12,9,'00:00:00','a','a');
INSERT INTO `CC` VALUES (13,186,'19:53:05','m','m');
INSERT INTO `CC` VALUES (14,NULL,'19:18:56','y','y');
INSERT INTO `CC` VALUES (15,2,'10:55:12','j','j');
INSERT INTO `CC` VALUES (16,3,'00:25:00','d','d');
INSERT INTO `CC` VALUES (17,0,'12:35:47','z','z');
INSERT INTO `CC` VALUES (18,133,'19:53:03','e','e');
INSERT INTO `CC` VALUES (19,1,'17:53:30','h','h');
INSERT INTO `CC` VALUES (20,8,'11:35:49','b','b');
CREATE TABLE `C` (
`pk` int(11) NOT NULL AUTO_INCREMENT,
`col_int_key` int(11) DEFAULT NULL,
`col_time_key` time DEFAULT NULL,
`col_varchar_key` varchar(1) DEFAULT NULL,
`col_varchar_nokey` varchar(1) DEFAULT NULL,
PRIMARY KEY (`pk`),
KEY `col_varchar_key` (`col_varchar_key`,`col_int_key`)
) ENGINE=MyISAM AUTO_INCREMENT=21 DEFAULT CHARSET=latin1;
INSERT INTO `C` VALUES (20,2,'18:38:59','d','d');
SELECT table2 .`col_time_key`
FROM C table1 LEFT JOIN C table2 ON table1 .`col_varchar_key`
WHERE ( table2 .`col_varchar_nokey` , table1 .`col_varchar_key` ) NOT IN (
SELECT SUBQUERY1_t1 .`col_varchar_key` , SUBQUERY1_t2 .`col_varchar_nokey`
FROM CC SUBQUERY1_t1 JOIN CC SUBQUERY1_t2 ON SUBQUERY1_t2 .`pk` ) OR table1 .`col_int_key` ;

Comment by Timour Katchaounov (Inactive) [ 2010-08-29 ]

Re: RQG: assertion "idx >= 1 && idx <= queue->elements" in queue_remove()
The bug is a result of the following change by Monty:

Revision Id: monty@askmonty.org-20100716073301-gstby2062nqd42qv
Timestamp: Fri 2010-07-16 10:33:01 +0300
Comment:
Improved speed of thr_alarm from O(N) to O(1). thr_alarm is used to handle timeouts and kill of connections.
Fixed compiler warnings.
queues.h and queues.c are now based on the UNIREG code and thus made BSD.
Fix code to use new queue() interface. This mostly affects how you access elements in the queue.
If USE_NET_CLEAR is not set, don't clear connection from unexpected characters. This should give a speed up when doing a lot of fast queries.
Fixed some code in ma_ft_boolean_search.c that had not made it from myisam/ft_boolean_search.c

The bug is due to the lack of proper tests for the new feature, thus testing the change by Monty didn't
detect that it breaks some new code.

Comment by Rasmus Johansson (Inactive) [ 2010-10-26 ]

Launchpad bug id: 608744

Generated at Thu Feb 08 06:44:01 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.