-
-
Notifications
You must be signed in to change notification settings - Fork 33
Description
Hi Isage!
I was testing it under some stressed conditions and I found some sporadic 500 errors coming from aborted: runtime error
example:
2020/02/18 21:22:09 [error] 7#7: *1242 lua entry thread aborted: runtime error: /usr/local/openresty/lualib/resty/moongoo/connection.lua:157: bad request
stack traceback:
coroutine 0:
[C]: in function 'send'
/usr/local/openresty/lualib/resty/moongoo/connection.lua:157: in function '_query'
/usr/local/openresty/lualib/resty/moongoo/cursor.lua:155: in function 'find_one'
that would be:
https://github.com/isage/lua-resty-moongoo/blob/master/lib/resty/moongoo/connection.lua#L157
connection.lua:157: assert(self:send(data))
and also
2020/02/18 21:19:37 [error] 7#7: *283 lua entry thread aborted: runtime error: /usr/local/openresty/lualib/resty/moongoo/connection.lua:88: assertion failed!
stack traceback:
coroutine 0:
[C]: in function 'assert'
/usr/local/openresty/lualib/resty/moongoo/connection.lua:88: in function '_query'
/usr/local/openresty/lualib/resty/moongoo/database.lua:43: in function '_cmd'
/usr/local/openresty/lualib/resty/moongoo.lua:75: in function 'connect'
/usr/local/openresty/lualib/resty/moongoo/cursor.lua:139: in function 'find_one'
that would be:
https://github.com/isage/lua-resty-moongoo/blob/master/lib/resty/moongoo/connection.lua#L88
connection.lua:88: assert ( r_to == cbson.uint(self._id) )
I managed to lowered the error rate even more setting: socketTimeoutMS=30000 (being 60s supposedly the default value, so then 30s as mongo )
(also including a minor lint change at:)
https://github.com/isage/lua-resty-moongoo/blob/master/lib/resty/moongoo.lua#L30
from:
local stimeout = conninfo.query.socketTimeoutMS and conninfo.query.socketTimeoutMS or nil
to:
local stimeout = conninfo.query and conninfo.query.socketTimeoutMS or nil
I'm considering changing those assert to a pcall wrapping and letting it just quietly fail without returning any data to avoid any sporadic 5xx
Any other suggestion/fix?