From 0d8b4007c49426f5aeaed34bb4f22062771e52a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Lehon=C4=8D=C3=A1k?= Date: Fri, 8 Mar 2024 13:07:57 +0100 Subject: [PATCH] UpdateIAmAlive for SingleMembership fixed to not create invalid subdocuments without required properties --- .../Membership/Store/Single/SingleMembershipCollection.cs | 7 +++++-- Orleans.Providers.MongoDB/Orleans.Providers.MongoDB.csproj | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Orleans.Providers.MongoDB/Membership/Store/Single/SingleMembershipCollection.cs b/Orleans.Providers.MongoDB/Membership/Store/Single/SingleMembershipCollection.cs index 986d96f..e3f7240 100644 --- a/Orleans.Providers.MongoDB/Membership/Store/Single/SingleMembershipCollection.cs +++ b/Orleans.Providers.MongoDB/Membership/Store/Single/SingleMembershipCollection.cs @@ -92,8 +92,11 @@ public async Task ReadRow(string deploymentId, SiloAddress public async Task UpdateIAmAlive(string deploymentId, SiloAddress address, DateTime iAmAliveTime) { - await Collection.UpdateOneAsync(x => x.DeploymentId == deploymentId, - Update + var filter = Builders.Filter.And( + Builders.Filter.Eq(x => x.DeploymentId, deploymentId), + Builders.Filter.Exists($"Members.{BuildKey(address)}", true)); + + await Collection.UpdateOneAsync(filter, Update .Set($"Members.{BuildKey(address)}.IAmAliveTime", LogFormatter.PrintDate(iAmAliveTime))); } diff --git a/Orleans.Providers.MongoDB/Orleans.Providers.MongoDB.csproj b/Orleans.Providers.MongoDB/Orleans.Providers.MongoDB.csproj index 04492a3..1815fd9 100644 --- a/Orleans.Providers.MongoDB/Orleans.Providers.MongoDB.csproj +++ b/Orleans.Providers.MongoDB/Orleans.Providers.MongoDB.csproj @@ -15,7 +15,7 @@ Orleans OrleansProviders MongoDB snupkg net8.0 - 8.0.2 + 8.0.3