diff --git a/src/NServiceBus.Core/Persistence/Raven/TimeoutPersister/RavenTimeoutPersistence.cs b/src/NServiceBus.Core/Persistence/Raven/TimeoutPersister/RavenTimeoutPersistence.cs index a4a59fa43ea..0dcce334e89 100644 --- a/src/NServiceBus.Core/Persistence/Raven/TimeoutPersister/RavenTimeoutPersistence.cs +++ b/src/NServiceBus.Core/Persistence/Raven/TimeoutPersister/RavenTimeoutPersistence.cs @@ -32,6 +32,7 @@ private static IRavenQueryable GetChunkQuery(IDocumentSession sessi .OrderBy(t => t.Time) .Where( t => + t.OwningTimeoutManager == null || t.OwningTimeoutManager == String.Empty || t.OwningTimeoutManager == Configure.EndpointName); } @@ -67,7 +68,7 @@ public List> GetNextChunk(DateTime startSlice, out DateT // Allow for occasionally cleaning up old timeouts for edge cases where timeouts have been // added after startSlice have been set to a later timout and we might have missed them // because of stale indexes. - if (lastCleanupTime.Add(TriggerCleanupEvery) > now || lastCleanupTime == DateTime.MinValue) + if (lastCleanupTime.Add(TriggerCleanupEvery) < now || lastCleanupTime == DateTime.MinValue) { results.AddRange(GetCleanupChunk(startSlice)); }