Commit e363f069 authored by mgravell's avatar mgravell

track whether we have an active writer, which can be approximated by: is the write lock unavailable

parent ed4c9987
......@@ -229,10 +229,11 @@ void add(string lk, string sk, string v)
// Add server data, if we have it
if (server != null)
{
server.GetOutstandingCount(message.Command, out int inst, out int qs, out long @in, out int qu, out long toRead, out long toWrite);
server.GetOutstandingCount(message.Command, out int inst, out int qs, out long @in, out int qu, out bool aw, out long toRead, out long toWrite);
add("OpsSinceLastHeartbeat", "inst", inst.ToString());
add("Queue-Awaiting-Write", "qu", qu.ToString());
add("Queue-Awaiting-Response", "qs", qs.ToString());
add("Active-Writer", "aw", aw.ToString());
if (@in >= 0) add("Inbound-Bytes", "in", @in.ToString());
if (toRead >= 0) add("Inbound-Pipe-Bytes", "in-pipe", toRead.ToString());
......
......@@ -289,13 +289,14 @@ private void ShutdownSubscriptionQueue()
internal bool TryEnqueueBackgroundSubscriptionWrite(in PendingSubscriptionState state)
=> isDisposed ? false : (_subscriptionBackgroundQueue ?? GetSubscriptionQueue()).Writer.TryWrite(state);
internal void GetOutstandingCount(out int inst, out int qs, out long @in, out int qu, out long toRead, out long toWrite)
internal void GetOutstandingCount(out int inst, out int qs, out long @in, out int qu, out bool aw, out long toRead, out long toWrite)
{
inst = (int)(Interlocked.Read(ref operationCount) - Interlocked.Read(ref profileLastLog));
lock(_backlog)
{
qu = _backlog.Count;
}
aw = !_singleWriterMutex.IsAvailable;
var tmp = physical;
if (tmp == null)
{
......
......@@ -375,17 +375,18 @@ internal ServerCounters GetCounters()
return counters;
}
internal void GetOutstandingCount(RedisCommand command, out int inst, out int qs, out long @in, out int qu, out long toRead, out long toWrite)
internal void GetOutstandingCount(RedisCommand command, out int inst, out int qs, out long @in, out int qu, out bool aw, out long toRead, out long toWrite)
{
var bridge = GetBridge(command, false);
if (bridge == null)
{
inst = qs = qu = 0;
@in = toRead = toWrite = 0;
aw = false;
}
else
{
bridge.GetOutstandingCount(out inst, out qs, out @in, out qu, out toRead, out toWrite);
bridge.GetOutstandingCount(out inst, out qs, out @in, out qu, out aw, out toRead, out toWrite);
}
}
......
......@@ -15,7 +15,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Pipelines.Sockets.Unofficial" Version="2.0.9" />
<PackageReference Include="Pipelines.Sockets.Unofficial" Version="2.0.10" />
<PackageReference Include="System.Diagnostics.PerformanceCounter" Version="4.5.0" />
<PackageReference Include="System.IO.Pipelines" Version="4.5.1" />
<PackageReference Include="System.Threading.Channels" Version="4.5.0" />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment