This is an automated email from the ASF dual-hosted git repository.

siddteotia pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git


The following commit(s) were added to refs/heads/master by this push:
     new 15fa8ccf55 [BugFix] Avoid reporting negative values for server 
latency. (#8892)
15fa8ccf55 is described below

commit 15fa8ccf55ea0908fc5d98ca51353c875720991c
Author: Vivek Iyer Vaidyanathan <[email protected]>
AuthorDate: Wed Jun 15 18:03:42 2022 -0700

    [BugFix] Avoid reporting negative values for server latency. (#8892)
    
    While working on testing changes in #8808, noticed that we report negative
    values for ResponseDelayMs in high QPS usecases. This can happen if the 
response
    from the server is received before the query is marked as submitted. This
    typically happens if request is sent to server but there's a delay in 
calling the
    callback in _channel.writeAndFlush(cb).
---
 .../java/org/apache/pinot/core/transport/ServerResponse.java | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git 
a/pinot-core/src/main/java/org/apache/pinot/core/transport/ServerResponse.java 
b/pinot-core/src/main/java/org/apache/pinot/core/transport/ServerResponse.java
index 90d558adb3..e358e0051d 100644
--- 
a/pinot-core/src/main/java/org/apache/pinot/core/transport/ServerResponse.java
+++ 
b/pinot-core/src/main/java/org/apache/pinot/core/transport/ServerResponse.java
@@ -62,11 +62,17 @@ public class ServerResponse {
   }
 
   public int getResponseDelayMs() {
-    if (_receiveDataTableTimeMs != 0) {
-      return (int) (_receiveDataTableTimeMs - _submitRequestTimeMs);
-    } else {
+    if (_receiveDataTableTimeMs == 0) {
       return -1;
     }
+    if (_receiveDataTableTimeMs < _submitRequestTimeMs) {
+      // We currently mark a request as submitted after sending the request to 
the server. In highQPS-lowLatency
+      // usecases, there can be a race condition where the DataTable/response 
is received before the request is
+      // marked as submitted. Return 0 to avoid reporting negative values.
+      return 0;
+    }
+
+    return (int) (_receiveDataTableTimeMs - _submitRequestTimeMs);
   }
 
   public int getResponseSize() {


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to