Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change Feed Processor: Fixes disposal of unused CancellationTokenSource #4220

Merged
merged 5 commits into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ private async Task ProcessPartitionAsync(PartitionSupervisor partitionSupervisor
}

await this.RemoveLeaseAsync(lease: lease, wasAcquired: true).ConfigureAwait(false);

partitionSupervisor.Dispose();
ealsur marked this conversation as resolved.
Show resolved Hide resolved
}

private async Task HandlePartitionGoneAsync(DocumentServiceLease lease, string lastContinuationToken)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ public async Task Controller_ShouldSignalSynchronizerSplitPartition_IfPartitionS
await sut.ShutdownAsync().ConfigureAwait(false);

Mock.Get(synchronizer).VerifyAll();

Mock.Get(partitionSupervisor)
.Verify(s => s.Dispose(), Times.Once);
}

[TestMethod]
Expand Down Expand Up @@ -76,6 +79,9 @@ public async Task Controller_ShouldPassLastKnownContinuationTokenToSynchronizer_
await sut.ShutdownAsync().ConfigureAwait(false);

Mock.Get(synchronizer).VerifyAll();

Mock.Get(partitionSupervisor)
.Verify(s => s.Dispose(), Times.Once);
}

[TestMethod]
Expand Down Expand Up @@ -108,6 +114,9 @@ public async Task Controller_ShouldCopyParentLeaseProperties_IfPartitionSplitHap
.VerifySet(l => l.Properties = customProperties, Times.Once);
Mock.Get(leaseChild2)
.VerifySet(l => l.Properties = customProperties, Times.Once);

Mock.Get(partitionSupervisor)
.Verify(s => s.Dispose(), Times.Once);
}

[TestMethod]
Expand All @@ -132,6 +141,9 @@ public async Task Controller_ShouldKeepParentLease_IfSplitThrows()
await sut.ShutdownAsync().ConfigureAwait(false);

Mock.Get(leaseManager).Verify(manager => manager.DeleteAsync(lease), Times.Never);

Mock.Get(partitionSupervisor)
.Verify(s => s.Dispose(), Times.Once);
}

[TestMethod]
Expand Down Expand Up @@ -180,6 +192,13 @@ public async Task Controller_ShouldRunProcessingOnChildPartitions_IfHappyPath()

monitor.Verify(m => m.NotifyLeaseAcquireAsync(leaseChild1.CurrentLeaseToken), Times.Once);
monitor.Verify(m => m.NotifyLeaseReleaseAsync(leaseChild2.CurrentLeaseToken), Times.Once);

Mock.Get(partitionSupervisor)
.Verify(s => s.Dispose(), Times.Once);
Mock.Get(partitionSupervisor1)
.Verify(s => s.Dispose(), Times.Once);
Mock.Get(partitionSupervisor2)
.Verify(s => s.Dispose(), Times.Once);
}

[TestMethod]
Expand Down