mroonga/mroonga — pull request #7 by yoku0825 (2014-04-21 16:35:04+00:00)
Title: mroonga_lock_timeout doesn't refrect when it's specified at mysqld starts up

Detail:
MySQL system variable "mroonga_lock_timeout" added in Mroonga 3.11 doesn't refrect lock timeout value at Groonga's layer lock, when it is setted at mysqld's startup, by my.cnf and by command-line argument.
"SET GLOBAL mroonga_lock_timeout" works well, but both of starting "bin/mysqld_safe --mroonga-lock-timeout=5" and writing "mroonga-lock-timeout= 5" into my.cnf doesn't work as expected.
Because of that, grn_set_lock_timeout is only called when "SET GLOBAL mroonga_lock_timeout"'s execution, mrn_init should call grn_set_lock_timeout too.

How to repeat:
--write mroonga-lock-timeout=5 into my.cnf and start mysqld.
--at connection 1.
mysql> SELECT @@global.mroonga_lock_timeout; -- This prints "5" as expected.
mysql> CREATE DATABASE mroonga;
mysql> CREATE TABLE mroonga.t1 (num int) Engine= Mroonga;
--at connection 2.
shell> ruby -e require "groonga"; Groonga::Database.open("/path/to/mroonga.mrn"); Groonga["t1"].lock; exit' # force locking table.
--at connection 1.
mysql> INSERT INTO mroonga.t1 VALUES (1); -- This doesn't return over "5"ms as expected.

(gdb) bt
#0 0x0000003eb480ed2d in nanosleep () from /lib64/libpthread.so.0
#1 0x00007fb46d4bb1d9 in grn_nanosleep (nanoseconds=) at ctx.c:82
#2 0x00007fb46d5c30f2 in grn_io_lock (ctx=0x7fb41c03f518, io=0x7fb41c36be30, timeout=10000000) at io.c:1320
..

grn_io_lock receives timeout value 10000000, this isn't the value specified in my.cnf.

Suggested fix:
Add grn_set_lock_timeout() in mrn_init() like attached patch.