maedhroz commented on code in PR #3274:
URL: https://github.com/apache/cassandra/pull/3274#discussion_r1593084038
##########
src/java/org/apache/cassandra/transport/Dispatcher.java:
##########
@@ -154,14 +323,49 @@ public String description()
{
return request.toString();
}
+
+ @Override
+ public String toString()
+ {
+ return "RequestProcessor{" +
+ "request=" + request +
+ ", approxStartTimeNanos=" + startTimeNanos +
+ '}';
+ }
+ }
+
+ /**
+ * Checks if the item in the head of the queue has spent more than allowed
time in the queue.
+ */
+ @Override
+ public boolean hasQueueCapacity()
+ {
+ double threshold =
DatabaseDescriptor.getNativeTransportQueueMaxItemAgeThreshold();
+ if (threshold <= 0)
+ return true;
+
+ return requestExecutor.oldestTaskQueueTime() <
(DatabaseDescriptor.getNativeTransportTimeout(TimeUnit.NANOSECONDS) *
threshold);
}
/**
* Note: this method may be executed on the netty event loop, during
initial protocol negotiation; the caller is
* responsible for cleaning up any global or thread-local state. (ex.
tracing, client warnings, etc.).
*/
- private static Message.Response processRequest(ServerConnection
connection, Message.Request request, Overload backpressure, long startTimeNanos)
+ private static Message.Response processRequest(ServerConnection
connection, Message.Request request, Overload backpressure, RequestTime
requestTime)
{
+ long queueTime = requestTime.timeSpentInQueueNanos();
+
+ // If we have already crossed the max timeout for all possible RPCs,
we time out the query immediately.
+ // We do not differentiate between query types here, since if we got
into a situation when, say, we have a PREPARE
+ // query that is stuck behind the EXECUTE query, we would rather time
it out and catch up with a backlog, expecting
+ // that the bursts are going to be short-lived.
+ ClientMetrics.instance.queueTime(queueTime, TimeUnit.NANOSECONDS);
+ if (queueTime >
DatabaseDescriptor.getNativeTransportTimeout(TimeUnit.NANOSECONDS))
Review Comment:
nit: This is a hot-ish (?) path. Would it make sene to memoize the native
transport timeout so we don't have to call `TimeUnit#covert()` so much?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]