Skip to content

5xx errors from random fails on asserts on moongoo socket connection (send) #36

@dev0pz

Description

@dev0pz

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions