<div><pre style="word-wrap:break-word;white-space:pre-wrap">いつもお世話になっております。宮下と申します。

Mroongaにてデータの挿入時およびインデックスをオフラインで作成するときに
以下のエラーがgroonga.logに出力されました。
この事象について、自分なりの対策を講じたのですが
・これがサポートされる方法なのか?
・さらに良い方法はないか?(Mroonga経由でGroongaにテーブル作成時のflagを渡せないか?)
について、もしご存知であれば教えていただけますと幸いです。
また、インデックステーブルは「TABLE_PAT_KEY」で作成されているのに、なぜエラーログには「[hash]」と出力されるのか?
こちらについても、もしご存じでしたら教えていただけますと幸いです。

groonga.log:
|e|af56e700|[hash][key][put] total key size is over: &lt;t1&gt;: max=<a href="tel:4294967295" target="_blank">4294967295</a>: current=<a href="tel:4294966695" target="_blank">4294966695</a>: new key size=1179

対策:
1)mroonga_command(&#39;schema&#39;)を使用して、対象のテーブル作成コマンドを記録
2)mroonga_commandを使ってテーブル削除
3)1で記録しておいたtable_createコマンドの内容に「KEY_LARGE」を追加してテーブル作成
4)alter table ... disable/enable keysでインデックスを再構築


以下は詳細を記載しております。必要に応じてご覧ください。
よろしくお願いいたします。


groonga.log詳細:
2017-09-26 01:10:12.221752|e|af56e700|[hash][key][put] total key size is over: &lt;t1&gt;: max=<a href="tel:4294967295" target="_blank">4294967295</a>: current=<a href="tel:4294966695" target="_blank">4294966695</a>: new key size=1179
2017-09-26 01:10:12.366788|e|af56e700|/usr/loca/groonga/lib/libgroonga.so.0(+0x222f81) [0x7fba3c822f81]
2017-09-26 01:10:12.366849|e|af56e700|/usr/loca/groonga/lib/libgroonga.so.0(+0x223549) [0x7fba3c823549]
2017-09-26 01:10:12.366872|e|af56e700|/usr/loca/groonga/lib/libgroonga.so.0(+0x225a2a) [0x7fba3c825a2a]
2017-09-26 01:10:12.366882|e|af56e700|/usr/loca/groonga/lib/libgroonga.so.0(grn_hash_add+0x974) [0x7fba3c826523]
2017-09-26 01:10:12.366890|e|af56e700|/usr/loca/groonga/lib/libgroonga.so.0(grn_table_add+0x7f9) [0x7fba3c6cb9d9]
2017-09-26 01:10:12.366898|e|af56e700|/usr/local/mysql/lib/plugin/ha_mroonga.so(_ZN10ha_mroonga23wrapper_write_row_indexEPh+0x3a6) [0x7fb9fb5b3e34]
2017-09-26 01:10:12.366907|e|af56e700|/usr/local/mysql/lib/plugin/ha_mroonga.so(_ZN10ha_mroonga17wrapper_write_rowEPh+0x25a) [0x7fb9fb5b3a5e]
2017-09-26 01:10:12.366915|e|af56e700|/usr/local/mysql/lib/plugin/ha_mroonga.so(_ZN10ha_mroonga9write_rowEPh+0xbd) [0x7fb9fb5b674f]
2017-09-26 01:10:12.366923|e|af56e700|/usr/local/mysql/bin/mysqld(_ZN7handler12ha_write_rowEPh+0x15d) [0x64e23d]
2017-09-26 01:10:12.366931|e|af56e700|/usr/local/mysql/bin/mysqld(_Z12write_recordP3THDP5TABLEP9COPY_INFOS4_+0xc13) [0x7c3c6d]
2017-09-26 01:10:12.366939|e|af56e700|/usr/local/mysql/bin/mysqld(_Z12mysql_insertP3THDP10TABLE_LISTR4ListI4ItemERS3_IS5_ES6_S6_15enum_duplicatesb+0x1006) [0x7c1a74]
2017-09-26 01:10:12.366947|e|af56e700|/usr/local/mysql/bin/mysqld(_Z21mysql_execute_commandP3THD+0x2e19) [0x7e48b9]
2017-09-26 01:10:12.366955|e|af56e700|/usr/local/mysql/bin/mysqld(_Z11mysql_parseP3THDPcjP12Parser_state+0x428) [0x7ec536]
2017-09-26 01:10:12.366963|e|af56e700|/usr/local/mysql/bin/mysqld(_Z16dispatch_command19enum_server_commandP3THDPcj+0xc94) [0x7df6e8]
2017-09-26 01:10:12.366971|e|af56e700|/usr/local/mysql/bin/mysqld(_Z10do_commandP3THD+0x340) [0x7de812]
2017-09-26 01:10:12.366979|e|af56e700|/usr/local/mysql/bin/mysqld(_Z24do_handle_one_connectionP3THD+0x1be) [0x7a57ed]

発生状況:
対象のテーブルに対して総ファイルサイズ870MB(420万行)のデータを10万行ずつに分けてbulk insertしたところ
740MB~760MBあたり(360万行~370万行)でstdout or stderrに以下が出力された。併せて、groonga.logに上記エラーが出力された。
※順不同。実際には同じ内容が連続して出力されていた。
---
Warning (Code 1026): failed to add a new record into groonga: key=&lt;&amp;&gt;
Warning (Code 1026): failed to add a new record into groonga: key=&lt;&#39;&gt;
Warning (Code 1026): failed to add a new record into groonga: key=&lt;&gt;
Warning (Code 1026): failed to add a new record into groonga: key=&lt;L&gt;
Warning (Code 1026): failed to add a new record into groonga: key=&lt;V&gt;
Warning (Code 1026): failed to add a new record into groonga: key=&lt;[&gt;
Warning (Code 1026): failed to add a new record into groonga: key=&lt;]&gt;
Warning (Code 1026): failed to add a new record into groonga: key=&lt;c&gt;
Warning (Code 1026): failed to add a new record into groonga: key=&lt;f&gt;
Warning (Code 1026): failed to add a new record into groonga: key=&lt;m&gt;
Warning (Code 1026): failed to add a new record into groonga: key=&lt;q&gt;
Warning (Code 1026): failed to add a new record into groonga: key=&lt;�
&gt;
Warning (Code 1026): failed to add a new record into groonga: key=&lt;ヲ&gt;
Warning (Code 1026): failed to add a new record into groonga: key=&lt;ヲ&gt;
Warning (Code 1026): failed to add a new record into groonga: key=&lt;ェ&gt;
Warning (Code 1026): failed to add a new record into groonga: key=&lt;ォ&gt;
Warning (Code 1026): failed to add a new record into groonga: key=&lt;ョ&gt;
Warning (Code 1026): failed to add a new record into groonga: key=&lt;ケ&gt;
Warning (Code 1026): failed to add a new record into groonga: key=&lt;ニ&gt;
Warning (Code 1026): failed to add a new record into groonga: key=&lt;ノ
&gt;
Warning (Code 1026): failed to add a new record into groonga: key=&lt;ヤ&gt;
Warning (Code 1026): failed to add a new record into groonga: key=&lt;ヨ&gt;
Warning (Code 1026): failed to add a new record into groonga: key=&lt;ン&gt;
Warning (Code 1026): failed to add a new record into groonga: key=&lt;゙&gt;

---

影響:
上記エラー移行にインデックス作成の対象とされた行については、インデックスが正常に作成されていない可能性がある。

システム環境:
CentOS6.5, MySQL-5.6.17, Groonga-7.0.5, Mroonga-7.05

テーブル定義(ラッパーモード):
CREATE TABLE `t1` (
  `col1` int(11) NOT NULL,
  `col2` varchar(64) NOT NULL DEFAULT &#39;&#39;,
  `col3` varchar(64) NOT NULL DEFAULT &#39;&#39;,
  `col4` int(11) NOT NULL,
  `col5` bigint(20) NOT NULL,
  `col6` varchar(255) NOT NULL DEFAULT &#39;&#39;,
  `col7` bigint(20) NOT NULL,
  `col8` varchar(255) DEFAULT NULL,
  `col9` datetime DEFAULT NULL,
  `col10` datetime DEFAULT NULL,
  PRIMARY KEY (`col1`,`col2`,`col3`,`col4`,`col5`,`col6`,`col7`),
  KEY `btr1` (`col1`,`col2`,`col3`,`col8`,`col7`),
  KEY `btr2` (`col1`,`col2`,`col3`,`col4`,`col8`,`col7`),
  KEY `btr3` (`col1`,`col2`,`col7`,`col5`),
  FULLTEXT KEY `ftx4` (`col8`)
) ENGINE=Mroonga DEFAULT CHARSET=utf8 COMMENT=&#39;engine &quot;InnoDB&quot; テスト用テーブル&#39;


テーブルリスト:
mroonga_command(&#39;table_list --output_pretty yes&#39;): [
    [
---省略---
    ],
    [
      256,
      &quot;mroonga_operations&quot;,
      &quot;d1.mrn.<a href="tel:0000100" target="_blank">0000100</a>&quot;,
      &quot;TABLE_NO_KEY|PERSISTENT&quot;,
      null,
      null,
      null,
      null
    ],
    [
      265,
      &quot;t1&quot;,
      &quot;d1.mrn.<a href="tel:0000109" target="_blank">0000109</a>&quot;,
      &quot;TABLE_HASH_KEY|KEY_LARGE|PERSISTENT&quot;, ←「KEY_LARGE」は自分で追加しました。
      &quot;ShortText&quot;,
      null,
      null,
      null
    ],
    [
      266,
      &quot;t1#ftx4&quot;,
      &quot;d1.mrn.000010A&quot;,
      &quot;TABLE_PAT_KEY|PERSISTENT&quot;,
      &quot;ShortText&quot;,
      null,
      &quot;TokenBigram&quot;,
      &quot;NormalizerMySQLGeneralCI&quot;
    ]
  ]

カラムリスト1:
mroonga_command(&#39;column_list t1 --output_pretty yes&#39;): [
    [
---省略---
    ],
    [
      265,
      &quot;_key&quot;,
      &quot;&quot;,
      &quot;&quot;,
      &quot;COLUMN_SCALAR&quot;,
      &quot;t1&quot;,
      &quot;ShortText&quot;,
      [
      ]
    ]
  ]

カラムリスト2:
mroonga_command(&#39;column_list t1#ftx4 --output_pretty yes&#39;): [
    [
---略---
    ],
    [
      266,
      &quot;_key&quot;,
      &quot;&quot;,
      &quot;&quot;,
      &quot;COLUMN_SCALAR&quot;,
      &quot;t1#ftx4&quot;,
      &quot;ShortText&quot;,
      [
      ]
    ],
    [
      267,
      &quot;index&quot;,
      &quot;d1.mrn.000010B&quot;,
      &quot;index&quot;,
      &quot;COLUMN_INDEX|WITH_POSITION|PERSISTENT&quot;,
      &quot;t1#ftx4&quot;,
      &quot;t1&quot;,
      [
      ]
    ]
  ]

insertファイル:
  内容:insert(bulk)文
  容量:それぞれ11MB~35MB、計870MB
  行数:各10万行、計420万行弱

主なmrnファイル:※()内はサフィックス
・d1.mrn.<a href="tel:0000109" target="_blank">0000109</a>(.001, .002, .003, 004):計4.8GB
・d1.mrn.000010A:12MB
・d1.mrn.000010B(.C):490MB

ibdファイル:
・t1.ibd:4GB ※B-Treeインデックスでかなり増加してます。

フルテキストインデックス作成対象のカラムサイズ:
・420万行(全体):420MB
・360万行(エラー発生付近):350MB 


以上</pre></div>