Revert switching to approxTime in Dispatcher

Patch by Arun Ganesh; reviewed by Caleb Rackliffe and David Capwell for CASSANDRA-19454
This commit is contained in:
arkn98 2024-03-06 13:35:32 -05:00 committed by Caleb Rackliffe
parent 06ed1afc34
commit a26fa6cf2c
4 changed files with 16 additions and 14 deletions

View File

@ -1,4 +1,5 @@
5.0-beta2
* Revert switching to approxTime in Dispatcher (CASSANDRA-19454)
* Add an optimized default configuration to tests and make it available for new users (CASSANDRA-18753)
* Fix remote JMX under Java17 (CASSANDRA-19453)
* Avoid consistency violations for SAI intersections over unrepaired data at consistency levels requiring reconciliation (CASSANDRA-19018)

View File

@ -26,7 +26,8 @@ import org.apache.cassandra.schema.TableMetadata;
import static java.lang.Long.max;
import static java.util.concurrent.TimeUnit.NANOSECONDS;
import static org.apache.cassandra.utils.MonotonicClock.Global.approxTime;
import static org.apache.cassandra.utils.Clock.Global.nanoTime;
/**
* Virtual table that lists currently running queries on the NTR (coordinator) and Read/Mutation (local) stages
@ -78,7 +79,7 @@ final class QueriesTable extends AbstractVirtualTable
long creationTimeNanos = task.creationTimeNanos();
long startTimeNanos = task.startTimeNanos();
long now = approxTime.now();
long now = nanoTime();
long queuedMicros = NANOSECONDS.toMicros(max((startTimeNanos > 0 ? startTimeNanos : now) - creationTimeNanos, 0));
long runningMicros = startTimeNanos > 0 ? NANOSECONDS.toMicros(now - startTimeNanos) : 0;

View File

@ -44,10 +44,10 @@ import org.apache.cassandra.transport.Flusher.FlushItem;
import org.apache.cassandra.transport.messages.ErrorMessage;
import org.apache.cassandra.transport.messages.EventMessage;
import org.apache.cassandra.utils.JVMStabilityInspector;
import org.apache.cassandra.utils.MonotonicClock;
import org.apache.cassandra.utils.NoSpamLogger;
import static org.apache.cassandra.concurrent.SharedExecutorPool.SHARED;
import static org.apache.cassandra.utils.Clock.Global.nanoTime;
public class Dispatcher
{
@ -119,8 +119,8 @@ public class Dispatcher
private final FlushItemConverter forFlusher;
private final Overload backpressure;
private final long approxCreationTimeNanos = MonotonicClock.Global.approxTime.now();
private volatile long approxStartTimeNanos;
private final long creationTimeNanos = nanoTime();
private volatile long startTimeNanos;
public RequestProcessor(Channel channel, Message.Request request, FlushItemConverter forFlusher, Overload backpressure)
{
@ -133,20 +133,20 @@ public class Dispatcher
@Override
public void run()
{
approxStartTimeNanos = MonotonicClock.Global.approxTime.now();
processRequest(channel, request, forFlusher, backpressure, approxStartTimeNanos);
startTimeNanos = nanoTime();
processRequest(channel, request, forFlusher, backpressure, startTimeNanos);
}
@Override
public long creationTimeNanos()
{
return approxCreationTimeNanos;
return creationTimeNanos;
}
@Override
public long startTimeNanos()
{
return approxStartTimeNanos;
return startTimeNanos;
}
@Override
@ -206,11 +206,11 @@ public class Dispatcher
/**
* Note: this method may be executed on the netty event loop.
*/
static Message.Response processRequest(Channel channel, Message.Request request, Overload backpressure, long approxStartTimeNanos)
static Message.Response processRequest(Channel channel, Message.Request request, Overload backpressure, long startTimeNanos)
{
try
{
return processRequest((ServerConnection) request.connection(), request, backpressure, approxStartTimeNanos);
return processRequest((ServerConnection) request.connection(), request, backpressure, startTimeNanos);
}
catch (Throwable t)
{
@ -235,9 +235,9 @@ public class Dispatcher
/**
* Note: this method is not expected to execute on the netty event loop.
*/
void processRequest(Channel channel, Message.Request request, FlushItemConverter forFlusher, Overload backpressure, long approxStartTimeNanos)
void processRequest(Channel channel, Message.Request request, FlushItemConverter forFlusher, Overload backpressure, long startTimeNanos)
{
Message.Response response = processRequest(channel, request, backpressure, approxStartTimeNanos);
Message.Response response = processRequest(channel, request, backpressure, startTimeNanos);
FlushItem<?> toFlush = forFlusher.toFlushItem(channel, request, response);
Message.logger.trace("Responding: {}, v={}", response, request.connection().getVersion());
flush(toFlush);

View File

@ -164,7 +164,7 @@ public class MessageDispatcherTest
Message.Request request,
FlushItemConverter forFlusher,
ClientResourceLimits.Overload backpressure,
long approxStartTimeNanos)
long startTimeNanos)
{
// noop
}