handle server-side timeout (i/o timeout) properly
package rest
import (
+ "net"
"net/http"
"syscall"
@@ -35,6 +36,14 @@ func handlePanics(logger logrus.FieldLogger, r *http.Request) {
handleBrokenPipe(err, logger, r)
return
}
+
+ var netErr net.Error
+ if errors.As(err, &netErr) {
+ if netErr.Timeout() {
+ handleTimeout(netErr, logger, r)
+ return
+ }
+ }
}
func handleBrokenPipe(err error, logger logrus.FieldLogger, r *http.Request) {
@@ -45,3 +54,12 @@ func handleBrokenPipe(err error, logger logrus.FieldLogger, r *http.Request) {
"hint": "Either try increasing the client-side timeout, or sending a computationally cheaper request, for example by reducing a batch size, reducing a limit, using less complex filters, etc.",
}).Errorf("broken pipe")
}
+
+func handleTimeout(err net.Error, logger logrus.FieldLogger, r *http.Request) {
+ logger.WithError(err).WithFields(logrus.Fields{
+ "method": r.Method,
+ "path": r.URL,
+ "description": "An I/O timeout occurs when the request takes longer than the specified server-side timeout.",
+ "hint": "Either try increasing the server-side timeout using e.g. '--write-timeout 600s' as a command line flag when starting Weaviate, or try sending a computationally cheaper request, for example by reducing a batch size, reducing a limit, using less complex filters, etc. Note that this error is only thrown if client-side and server-side timeouts are not in sync, more precisely if the client-side timeout is longer than the server side timeout.",
+ }).Errorf("i/o timeout")
+}
