Skip to content

Commit 1b2c508

Browse files
ChangeFeedProcessor: Refactors ShutdownAsync to abstract in base class
- Make ShutdownAsync abstract in DocumentServiceLeaseStoreManager - Add no-op override in DocumentServiceLeaseStoreManagerCosmos - Consolidate ShutdownAsync call to single line in ChangeFeedProcessorCore Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent a21cfcd commit 1b2c508

3 files changed

Lines changed: 10 additions & 13 deletions

File tree

Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/ChangeFeedProcessorCore.cs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,9 @@ public override async Task StopAsync()
8080
DefaultTrace.TraceInformation("Stopping processor...");
8181
await this.partitionManager.StopAsync().ConfigureAwait(false);
8282

83-
// ShutdownAsync persists in-memory lease state. Runs outside finally
84-
// because: (a) partitionManager.StopAsync() rarely fails, and when it
85-
// does the caller already receives that exception; (b) letting
86-
// ShutdownAsync exceptions propagate ensures callers know if
87-
// persistence failed — silently swallowing defeats the feature's
88-
// guarantee.
89-
await this.documentServiceLeaseStoreManager
90-
.ShutdownAsync()
91-
.ConfigureAwait(false);
83+
// Persists in-memory lease state (no-op for Cosmos-backed leases).
84+
// Runs after partitionManager.StopAsync() so exceptions propagate to the caller.
85+
await this.documentServiceLeaseStoreManager.ShutdownAsync().ConfigureAwait(false);
9286

9387
DefaultTrace.TraceInformation("Processor stopped.");
9488
}

Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/LeaseManagement/DocumentServiceLeaseStoreManager.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@ internal abstract class DocumentServiceLeaseStoreManager
3636
/// Called when the processor is stopping. Allows implementations to perform
3737
/// cleanup or state persistence (e.g., exporting in-memory lease state).
3838
/// </summary>
39-
public virtual Task ShutdownAsync()
40-
{
41-
return Task.CompletedTask;
42-
}
39+
public abstract Task ShutdownAsync();
4340
}
4441
}

Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/LeaseManagement/DocumentServiceLeaseStoreManagerCosmos.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Microsoft.Azure.Cosmos.ChangeFeed.LeaseManagement
66
{
77
using System;
8+
using System.Threading.Tasks;
89
using Microsoft.Azure.Cosmos;
910

1011
/// <summary>
@@ -80,5 +81,10 @@ internal DocumentServiceLeaseStoreManagerCosmos(
8081
public override DocumentServiceLeaseCheckpointer LeaseCheckpointer => this.leaseCheckpointer;
8182

8283
public override DocumentServiceLeaseContainer LeaseContainer => this.leaseContainer;
84+
85+
public override Task ShutdownAsync()
86+
{
87+
return Task.CompletedTask;
88+
}
8389
}
8490
}

0 commit comments

Comments
 (0)