From f1a030717c1200d72e9f7ff2f9d3d55aa460963a Mon Sep 17 00:00:00 2001 From: Mike Minutillo Date: Fri, 27 Mar 2026 14:43:51 +0800 Subject: [PATCH] Do not return negative throughput when queue table deleted --- .../QueueTableSnapshot.cs | 2 +- .../SqlServerQuery.cs | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/ServiceControl.Transports.SqlServer/QueueTableSnapshot.cs b/src/ServiceControl.Transports.SqlServer/QueueTableSnapshot.cs index 74c9bd18c9..c575c26d42 100644 --- a/src/ServiceControl.Transports.SqlServer/QueueTableSnapshot.cs +++ b/src/ServiceControl.Transports.SqlServer/QueueTableSnapshot.cs @@ -2,5 +2,5 @@ namespace ServiceControl.Transports.SqlServer; public class BrokerQueueTableSnapshot(BrokerQueueTable details) : BrokerQueueTable(details.DatabaseDetails, details.Schema, details.Name) { - public long RowVersion { get; set; } + public long? RowVersion { get; set; } } \ No newline at end of file diff --git a/src/ServiceControl.Transports.SqlServer/SqlServerQuery.cs b/src/ServiceControl.Transports.SqlServer/SqlServerQuery.cs index e84e58b8c4..ca742d146d 100644 --- a/src/ServiceControl.Transports.SqlServer/SqlServerQuery.cs +++ b/src/ServiceControl.Transports.SqlServer/SqlServerQuery.cs @@ -70,11 +70,14 @@ public override async IAsyncEnumerable GetThroughputPerDay(IBro var endData = await queueTableName.DatabaseDetails.GetSnapshot(queueTableName, cancellationToken); - yield return new QueueThroughput + if (endData.RowVersion.HasValue && startData.RowVersion.HasValue) { - DateUTC = DateOnly.FromDateTime(timeProvider.GetUtcNow().DateTime), - TotalThroughput = endData.RowVersion - startData.RowVersion - }; + yield return new QueueThroughput + { + DateUTC = DateOnly.FromDateTime(timeProvider.GetUtcNow().DateTime), + TotalThroughput = endData.RowVersion.Value - startData.RowVersion.Value + }; + } startData = endData; }