groonga pgroonga lock

FreeBSD

/var/log/pgsql/pgroonga.log
2018-06-13 13:57:08.446030|w|92306: [DB Locked] time out(900000): io(base/[database oid]/pgrn) collisions(900000/90)
2018-06-13 13:57:08.446253|e|92306: grn_io_lock failed
2018-06-13 13:57:08.453398|e|92306: 0xa12ffe74e  at /usr/local/lib/libgroonga.so.0

セッションが終了してもpostgresのprocessが残る (psに出る、pg_stat_activity に出ない)

select datid,datname from pg_stat_database;

postgresqlでデータベース、テーブルのOIDを取得
https://hogem.hatenablog.com/entry/20090620/1245431458

(gdb) bt
#0  0x000000080111948a in _nanosleep () from /lib/libc.so.7
#1  0x0000000a123cd4cc in pthread_suspend_all_np () from /lib/libthr.so.3
#2  0x0000000a12e9c9a9 in ?? () from /usr/local/lib/libgroonga.so.0
#3  0x0000000000000000 in ?? ()

復旧方法

postgres停止 → pgroongaロック削除 → postgres起動

cd /usr/local/pgsql/data/base/[database oid]
$ groonga pgrn
 > clearlock
 [[0,1528866270.726295,16.03510427474976],true]
 > quit
 [[0,1528866294.04867,5.650520324707031e-05],true]

↑で復旧しない場合は↓の方法?

...
Here is the right way to recover the IO lock:

Stop PostgreSQL.
Remove pgrn* files in data directory.
Start PostgreSQL.
Run REINDEX INDEX index_name; for all PGroonga indexes.

In many cases, you can recover by only running REINDEX. But some cases (e.g.: lock stays behind pgrn (no following number) file), you need to 1., 2. and 3.

https://github.com/pgroonga/pgroonga/issues/48#issuecomment-314448290