From cac9d9df26c229ef26af01e5a2ac52b51a505ce3 Mon Sep 17 00:00:00 2001 From: Sebastian Stehle Date: Wed, 31 Mar 2021 14:46:05 +0200 Subject: [PATCH] Do not update content when stale. --- .../Squidex.Infrastructure/Commands/DomainObject.cs | 11 ++++++++++- .../src/Squidex.Infrastructure/States/Persistence.cs | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/backend/src/Squidex.Infrastructure/Commands/DomainObject.cs b/backend/src/Squidex.Infrastructure/Commands/DomainObject.cs index da4beb8d7..9e60080fd 100644 --- a/backend/src/Squidex.Infrastructure/Commands/DomainObject.cs +++ b/backend/src/Squidex.Infrastructure/Commands/DomainObject.cs @@ -315,7 +315,16 @@ namespace Squidex.Infrastructure.Commands if (persistence.IsSnapshotStale) { - await persistence.WriteSnapshotAsync(Snapshot); + try + { + await persistence.WriteSnapshotAsync(Snapshot); + } + catch (Exception ex) + { + log.LogError(ex, w => w + .WriteProperty("action", "RepairSnapshot") + .WriteProperty("status", "Failed")); + } } } } diff --git a/backend/src/Squidex.Infrastructure/States/Persistence.cs b/backend/src/Squidex.Infrastructure/States/Persistence.cs index b4a2dbbe9..53a2abf60 100644 --- a/backend/src/Squidex.Infrastructure/States/Persistence.cs +++ b/backend/src/Squidex.Infrastructure/States/Persistence.cs @@ -46,7 +46,7 @@ namespace Squidex.Infrastructure.States public bool IsSnapshotStale { - get => persistenceMode == PersistenceMode.SnapshotsAndEventSourcing && versionSnapshot < versionEvents; + get => persistenceMode == PersistenceMode.SnapshotsAndEventSourcing && versionSnapshot < versionEvents && versionSnapshot > EtagVersion.Empty; } public Persistence(DomainId ownerKey, Type ownerType,