Closed evenyag closed 5 years ago
Hi. Could you please rebase?
Hi. Could you please rebase?
done
Note that the error is quite odd and this PR, actually, doesn't solve it. Looks like I should think of how to handle EAGAIN.
Could you please describe your environment? Is it VM?
I believe that this unwrap should be infallible. Also looks like there exist situations where it is possible for blocking socket to return EAGAIN. I'll investigate further.
I believe that this unwrap should be infallible. Also looks like there exist situations where it is possible for blocking socket to return EAGAIN. I'll investigate further.
recv()/send() may returns EAGAIN when a read/write timeout had been set and the timeout expired. As described in man recv
EAGAIN or EWOULDBLOCK The socket is marked nonblocking and the receive operation would block, or a receive timeout had been set and the timeout expired before data was received. POSIX.1 allows either error to be returned for this case, and does not require these constants to have the same value, so a portable application should check for both possibilities.
When the db server is under heavy load, it may not be able to handle all client's request. It's reasonable to throws such error to the caller and let the caller decides what to do next (such as retry or reply Server is busy
to user) instead of panic in get_system_var()
, because even get_system_var()
supports retry, errors may still occur.
Yeah. Panic is definitely not an option.
However get_system_var()
is requered to properly configure the connection. Could you please alter this PR to retry get_system_var()
until success in case of EAGAIN (and keep error for other cases)?
Since the read_timeout
/write_timeout
set by user had been expired in such situation (we're using blocking socket), it should be ok to just throw the error in get_system_var()
and stop the Conn::new()
process, keep the codes simple and clear. Also, the EAGAIN case rarely occurs in most user's environment
Conn::get_system_var()
unwraps theResult
fromConn::query()
, which may be anErr
and cause panic. This PR just returns theErr
to caller and avoids panic.The backtrace: