[groonga-dev,01192] mroongaストレージモード、マルチインデックスでの絞り込み不具合

Back to archive index

b senboku senbo****@gmail*****
2013年 2月 7日 (木) 18:33:09 JST


お世話になっております。仙北と申します。
表題の件について質問させて下さい。


■環境

CentOS 6.3
mroonga 2.10
MySQL 5.1.66


■現象

[1]
以下でテーブルを作成します。

CREATE TABLE `simple_table_test3` (
  `id` int(10) unsigned AUTO_INCREMENT,
  `category_id` int(10) unsigned,
  `title` text,
  `content` text,
  `delete_flg` tinyint(1) unsigned DEFAULT '0',
  `r_date` datetime,
  PRIMARY KEY (`id`),
  KEY `category_id` (`category_id`),
  KEY `delete_flg` (`delete_flg`),
  KEY `category_id_2` (`category_id`,`delete_flg`,`r_date`),
  FULLTEXT KEY `title` (`title`),
  FULLTEXT KEY `content` (`content`)
) ENGINE=mroonga DEFAULT CHARSET=utf8;


デバッグ用のデータとして

insert into simple_table_test3
(category_id,title,content,delete_flg,r_date) values
(4,"title","content",0,NOW());

を20回ぐらい連打します。


category_id=4, delete_flg=0のデータ件数を調べると

mysql> select count(*) from simple_table_test3 where category_id=4 and
delete_flg=0;
+----------+
| count(*) |
+----------+
|       20 |
+----------+

全部同じデータなので
全件ヒットします。


[2]
半分をdelete_flg=1にします。

mysql> update simple_table_test3 set delete_flg=1 where id <= 10;
Query OK, 10 rows affected (0.00 sec)


ここでもう一度category_id=4, delete_flg=0のデータ件数を調べると

mysql> select count(*) from simple_table_test3 where category_id=4 and
delete_flg=0;
+----------+
| count(*) |
+----------+
|        0 |
+----------+

0件になりました。


データ自体はちゃんと入っているようです。

mysql> select id,category_id,delete_flg from simple_table_test3;
+----+-------------+------------+
| id | category_id | delete_flg |
+----+-------------+------------+
|  1 |           4 |          1 |
|  2 |           4 |          1 |
|  3 |           4 |          1 |
|  4 |           4 |          1 |
|  5 |           4 |          1 |
|  6 |           4 |          1 |
|  7 |           4 |          1 |
|  8 |           4 |          1 |
|  9 |           4 |          1 |
| 10 |           4 |          1 |
| 11 |           4 |          0 |
| 12 |           4 |          0 |
| 13 |           4 |          0 |
| 14 |           4 |          0 |
| 15 |           4 |          0 |
| 16 |           4 |          0 |
| 17 |           4 |          0 |
| 18 |           4 |          0 |
| 19 |           4 |          0 |
| 20 |           4 |          0 |
+----+-------------+------------+
20 rows in set (0.00 sec)


[3]
この状態でデータを変えないまま
マルチカラムインデックスを作り直すと

mysql> drop index category_id_2 on simple_table_test3;
mysql> create index category_id_2 on
simple_table_test3(`category_id`,`delete_flg`,`r_date`);

mysql> select count(*) from simple_table_test3 where category_id=4 and
delete_flg=0;
+----------+
| count(*) |
+----------+
|       10 |
+----------+

ちゃんと10件引けます。


ちゃんと引けるようになった状態から
もう一度 delete_flg=0 に戻して
半分を delete_flg=1 にすると

mysql> update simple_table_test3 set delete_flg=0;

mysql> update simple_table_test3 set delete_flg=1 where id <= 10;

mysql> select count(*) from simple_table_test3 where category_id=4 and
delete_flg=0;
+----------+
| count(*) |
+----------+
|        0 |
+----------+

やっぱり引けなくなります。

ちなみにcountの値がおかしいということではなく、
"select * from 〜"としてもデータは引けません。


現象は、最初開発サーバー(mroonga2.07)で発生しまして
別サーバーを作ってmroonga2.10を新規インストールして再検証しても発生、
という経緯です。

ストレージモードで発生します。
ラッパーモードだと今のところ出ていないように見えます。


マルチカラムが原因だとは思うのですが…。


対応策等ありましたらお教え下さい。
また、ストレージモード固有の問題であると考えて良いでしょうか?



groonga-dev メーリングリストの案内
Back to archive index