Fix possible hang during terminating
We've seen in production that mailroom might get stuck terminating:
{"severity":"INFO","time":"2020-11-12 17:05:17 +0000","context":{"email":"mail@gmail.com","name":"inbox"},"action":"Idling"}
/usr/lib/ruby/2.6.0/openssl/buffering.rb:57:in `sysread': Connection reset by peer (Errno::ECONNRESET)
from /usr/lib/ruby/2.6.0/openssl/buffering.rb:57:in `fill_rbuff'
from /usr/lib/ruby/2.6.0/openssl/buffering.rb:207:in `gets'
from /usr/lib/ruby/2.6.0/net/imap.rb:1230:in `get_response'
from /usr/lib/ruby/2.6.0/net/imap.rb:1147:in `receive_responses'
from /usr/lib/ruby/2.6.0/net/imap.rb:1120:in `block in initialize'
{"severity":"INFO","time":"2020-11-12 17:05:48 +0000","context":{"email":"othermail@gmail.com","name":"inbox"},"action":"Quitting connection..."}
This might happen because the watching thread of another mailbox did not join in a timely fashion.
To prevent this from happening, we now put a 60-second timeout on the
Thread#join
.
Relates to gitlab-org/charts/gitlab#2440 (closed)