From 7ac62fb40f66ed9170628b73a181893e3ef9f2b6 Mon Sep 17 00:00:00 2001 From: Stephen Atherton Date: Fri, 31 May 2019 12:33:39 -0700 Subject: [PATCH] For HTTP requests, a missing request ID in the response is ignored if the response code is 5xx indicating a server error. --- fdbclient/HTTP.actor.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/fdbclient/HTTP.actor.cpp b/fdbclient/HTTP.actor.cpp index a81ac35262..98068e2350 100644 --- a/fdbclient/HTTP.actor.cpp +++ b/fdbclient/HTTP.actor.cpp @@ -392,17 +392,17 @@ namespace HTTP { responseID = iid->second; } event.detail("RequestIDReceived", responseID); - if(requestID != responseID) { + + // If the response code is 5xx (server error) then a response ID is not expected + // so a missing id will be ignored but a mismatching id will still be an error. + bool serverError = r->code >= 500 && r->code < 600; + + // If request/response IDs do not match and either this is not a server error + // or it is but the response ID is not empty then log an error. + if(requestID != responseID && (!serverError || !responseID.empty()) ) { err = http_bad_request_id(); - // Log a non-debug a error - Severity sev = SevError; - // If the response code is 5xx (server error) and the responseID is empty then just warn - if(responseID.empty() && r->code >= 500 && r->code < 600) { - sev = SevWarnAlways; - } - - TraceEvent(sev, "HTTPRequestFailedIDMismatch") + TraceEvent(SevError, "HTTPRequestFailedIDMismatch") .detail("DebugID", conn->getDebugID()) .detail("RemoteAddress", conn->getPeerAddress()) .detail("Verb", verb) @@ -433,6 +433,7 @@ namespace HTTP { return r; } catch(Error &e) { double elapsed = timer() - send_start; + // A bad_request_id error would have already been logged in verbose mode before err is thrown above. if(CLIENT_KNOBS->HTTP_VERBOSE_LEVEL > 0 && e.code() != error_code_http_bad_request_id) { printf("[%s] HTTP *ERROR*=%s early=%d, time=%fs %s %s contentLen=%d [%d out]\n", conn->getDebugID().toString().c_str(), e.name(), earlyResponse, elapsed, verb.c_str(), resource.c_str(), contentLen, total_sent);