From 9711b239c10506ba461aadf033a5fc36efd38882 Mon Sep 17 00:00:00 2001 From: John Simons Date: Tue, 4 Aug 2026 16:05:05 +1000 Subject: [PATCH 1/2] FindClrType is not used at all --- .../DatabaseConfiguration.cs | 3 --- .../RavenEmbeddedPersistenceLifecycle.cs | 5 +---- .../RavenExternalPersistenceLifecycle.cs | 5 ----- src/ServiceControl.RavenDB/EmbeddedDatabase.cs | 5 ----- src/ServiceControl.RavenDB/EmbeddedDatabaseConfiguration.cs | 4 ---- 5 files changed, 1 insertion(+), 21 deletions(-) diff --git a/src/ServiceControl.Audit.Persistence.RavenDB/DatabaseConfiguration.cs b/src/ServiceControl.Audit.Persistence.RavenDB/DatabaseConfiguration.cs index 05f9258a31..2c0e0cd5d9 100644 --- a/src/ServiceControl.Audit.Persistence.RavenDB/DatabaseConfiguration.cs +++ b/src/ServiceControl.Audit.Persistence.RavenDB/DatabaseConfiguration.cs @@ -1,7 +1,6 @@ namespace ServiceControl.Audit.Persistence.RavenDB { using System; - using Sparrow.Json; public class DatabaseConfiguration( string name, @@ -20,8 +19,6 @@ public class DatabaseConfiguration( public bool EnableFullTextSearch { get; } = enableFullTextSearch; - public Func FindClrType { get; } - public ServerConfiguration ServerConfiguration { get; } = serverConfiguration; public TimeSpan AuditRetentionPeriod { get; } = auditRetentionPeriod; diff --git a/src/ServiceControl.Audit.Persistence.RavenDB/RavenEmbeddedPersistenceLifecycle.cs b/src/ServiceControl.Audit.Persistence.RavenDB/RavenEmbeddedPersistenceLifecycle.cs index 80bf05b742..99c74f6a15 100644 --- a/src/ServiceControl.Audit.Persistence.RavenDB/RavenEmbeddedPersistenceLifecycle.cs +++ b/src/ServiceControl.Audit.Persistence.RavenDB/RavenEmbeddedPersistenceLifecycle.cs @@ -39,10 +39,7 @@ public async Task Initialize(CancellationToken cancellationToken = default) var serverConfig = databaseConfiguration.ServerConfiguration; - var embeddedConfig = new EmbeddedDatabaseConfiguration(serverConfig.ServerUrl, databaseConfiguration.Name, serverConfig.DbPath, serverConfig.LogPath, serverConfig.LogsMode) - { - FindClrType = databaseConfiguration.FindClrType - }; + var embeddedConfig = new EmbeddedDatabaseConfiguration(serverConfig.ServerUrl, databaseConfiguration.Name, serverConfig.DbPath, serverConfig.LogPath, serverConfig.LogsMode); database = EmbeddedDatabase.Start(embeddedConfig, lifetime); diff --git a/src/ServiceControl.Audit.Persistence.RavenDB/RavenExternalPersistenceLifecycle.cs b/src/ServiceControl.Audit.Persistence.RavenDB/RavenExternalPersistenceLifecycle.cs index 3b6d382b9c..316128e68e 100644 --- a/src/ServiceControl.Audit.Persistence.RavenDB/RavenExternalPersistenceLifecycle.cs +++ b/src/ServiceControl.Audit.Persistence.RavenDB/RavenExternalPersistenceLifecycle.cs @@ -46,11 +46,6 @@ public async Task Initialize(CancellationToken cancellationToken = default) } }; - if (configuration.FindClrType != null) - { - store.Conventions.FindClrType += configuration.FindClrType; - } - documentStore = store.Initialize(); await StartupChecks.EnsureServerVersion(store, cancellationToken); diff --git a/src/ServiceControl.RavenDB/EmbeddedDatabase.cs b/src/ServiceControl.RavenDB/EmbeddedDatabase.cs index cf2157181f..f0026a51d7 100644 --- a/src/ServiceControl.RavenDB/EmbeddedDatabase.cs +++ b/src/ServiceControl.RavenDB/EmbeddedDatabase.cs @@ -176,11 +176,6 @@ public async Task Connect(CancellationToken cancellationToken) SkipCreatingDatabase = true }; - if (configuration.FindClrType != null) - { - dbOptions.Conventions.FindClrType += configuration.FindClrType; - } - var store = await EmbeddedServer.Instance.GetDocumentStoreAsync(dbOptions, cancellationToken); return store; } diff --git a/src/ServiceControl.RavenDB/EmbeddedDatabaseConfiguration.cs b/src/ServiceControl.RavenDB/EmbeddedDatabaseConfiguration.cs index a7edba7b01..6aec695755 100644 --- a/src/ServiceControl.RavenDB/EmbeddedDatabaseConfiguration.cs +++ b/src/ServiceControl.RavenDB/EmbeddedDatabaseConfiguration.cs @@ -1,7 +1,5 @@ namespace ServiceControl.RavenDB { - using Sparrow.Json; - public class EmbeddedDatabaseConfiguration(string serverUrl, string dbName, string dbPath, string logPath, string logsMode) { public string Name { get; } = dbName; @@ -11,7 +9,5 @@ public class EmbeddedDatabaseConfiguration(string serverUrl, string dbName, stri public string LogsMode { get; } = logsMode; public bool RunInMemory { get; set; } - - public Func FindClrType { get; init; } } } From 72712facb51de12cdfd0ac541c6fbc68749b0090 Mon Sep 17 00:00:00 2001 From: John Simons Date: Tue, 4 Aug 2026 16:18:40 +1000 Subject: [PATCH 2/2] Remove requestId null checks The requestId null checks in RetryingManager were added in 1.30 (fb328c1b) for RetryBatch documents written by 1.29 and earlier, before retry operations existed. Every requestId reaching the manager today is non-null: the batch-reading paths in RetryProcessor and RetryDocumentManager read RequestId from documents that CreateBatch always writes, and CreateBatch is only ever fed a route-constrained value, a computed deterministic guid, or a constant. RetryDocumentManager already null-guarded before calling PreparedAdoptedBatch, and the EF persister models RequestId as required and non-nullable. --- .../Retrying/RetryDocumentManager.cs | 7 +--- .../Retrying/RetryingManager.cs | 42 +------------------ 2 files changed, 4 insertions(+), 45 deletions(-) diff --git a/src/ServiceControl/Recoverability/Retrying/RetryDocumentManager.cs b/src/ServiceControl/Recoverability/Retrying/RetryDocumentManager.cs index f2a0cc5122..98f35bdda9 100644 --- a/src/ServiceControl/Recoverability/Retrying/RetryDocumentManager.cs +++ b/src/ServiceControl/Recoverability/Retrying/RetryDocumentManager.cs @@ -54,12 +54,9 @@ public async Task RebuildRetryOperationState() foreach (var group in stagingBatchGroups) { - if (!string.IsNullOrWhiteSpace(group.RequestId)) - { - logger.LogDebug("Rebuilt retry operation status for {RetryType}/{RetryRequestId}. Aggregated batchsize: {RetryBatchSize}", group.RetryType, group.RequestId, group.InitialBatchSize); + logger.LogDebug("Rebuilt retry operation status for {RetryType}/{RetryRequestId}. Aggregated batchsize: {RetryBatchSize}", group.RetryType, group.RequestId, group.InitialBatchSize); - await operationManager.PreparedAdoptedBatch(group.RequestId, group.RetryType, group.InitialBatchSize, group.InitialBatchSize, group.Originator, group.Classifier, group.StartTime, group.Last); - } + await operationManager.PreparedAdoptedBatch(group.RequestId, group.RetryType, group.InitialBatchSize, group.InitialBatchSize, group.Originator, group.Classifier, group.StartTime, group.Last); } } diff --git a/src/ServiceControl/Recoverability/Retrying/RetryingManager.cs b/src/ServiceControl/Recoverability/Retrying/RetryingManager.cs index 95af86ae8f..83917ff965 100644 --- a/src/ServiceControl/Recoverability/Retrying/RetryingManager.cs +++ b/src/ServiceControl/Recoverability/Retrying/RetryingManager.cs @@ -18,11 +18,6 @@ public RetryingManager(IDomainEvents domainEvents, ILogger logg public Task Wait(string requestId, RetryType retryType, DateTime started, string originator = null, string classifier = null, DateTime? last = null) { - if (requestId == null) //legacy support for batches created before operations were introduced - { - return Task.CompletedTask; - } - var summary = GetOrCreate(retryType, requestId); return summary.Wait(started, originator, classifier, last); @@ -45,11 +40,6 @@ public bool IsRetryInProgressFor(string requestId) public async Task Preparing(string requestId, RetryType retryType, int totalNumberOfMessages) { - if (requestId == null) //legacy support for batches created before operations were introduced - { - return; - } - var summary = GetOrCreate(retryType, requestId); await summary.Prepare(totalNumberOfMessages); @@ -57,11 +47,6 @@ public async Task Preparing(string requestId, RetryType retryType, int totalNumb public async Task PreparedAdoptedBatch(string requestId, RetryType retryType, int numberOfMessagesPrepared, int totalNumberOfMessages, string originator, string classifier, DateTime startTime, DateTime last) { - if (requestId == null) //legacy support for batches created before operations were introduced - { - return; - } - var summary = GetOrCreate(retryType, requestId); await summary.Prepare(totalNumberOfMessages); @@ -70,11 +55,6 @@ public async Task PreparedAdoptedBatch(string requestId, RetryType retryType, in public async Task PreparedBatch(string requestId, RetryType retryType, int numberOfMessagesPrepared) { - if (requestId == null) //legacy support for batches created before operations were introduced - { - return; - } - var summary = GetOrCreate(retryType, requestId); await summary.PrepareBatch(numberOfMessagesPrepared); @@ -82,11 +62,6 @@ public async Task PreparedBatch(string requestId, RetryType retryType, int numbe public async Task Forwarding(string requestId, RetryType retryType) { - if (requestId == null) //legacy support for batches created before operations were introduced - { - return; - } - var summary = GetOrCreate(retryType, requestId); await summary.Forwarding(); @@ -94,11 +69,6 @@ public async Task Forwarding(string requestId, RetryType retryType) public async Task ForwardedBatch(string requestId, RetryType retryType, int numberOfMessagesForwarded) { - if (requestId == null) //legacy support for batches created before operations were introduced - { - return; - } - var summary = GetOrCreate(retryType, requestId); await summary.BatchForwarded(numberOfMessagesForwarded); @@ -106,11 +76,6 @@ public async Task ForwardedBatch(string requestId, RetryType retryType, int numb public void Fail(RetryType retryType, string requestId) { - if (requestId == null) //legacy support for batches created before operations were introduced - { - return; - } - var summary = GetOrCreate(retryType, requestId); summary.Fail(); @@ -118,17 +83,14 @@ public void Fail(RetryType retryType, string requestId) public async Task Skip(string requestId, RetryType retryType, int numberOfMessagesSkipped) { - if (requestId == null) //legacy support for batches created before operations were introduced - { - return; - } - var summary = GetOrCreate(retryType, requestId); await summary.Skip(numberOfMessagesSkipped); } InMemoryRetry GetOrCreate(RetryType retryType, string requestId) { + ArgumentException.ThrowIfNullOrWhiteSpace(requestId); + var key = InMemoryRetry.MakeOperationId(requestId, retryType); return retryOperations.GetOrAdd(key, _ => new InMemoryRetry(requestId, retryType, domainEvents, logger)); }