Skip to content

Commit

Permalink
Revert "short-circuited some cases"
Browse files Browse the repository at this point in the history
This reverts commit e37d7b1.
  • Loading branch information
Aaronontheweb committed Apr 20, 2021
1 parent e37d7b1 commit 83c2205
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions src/core/Akka.Cluster/Reachability.cs
Original file line number Diff line number Diff line change
Expand Up @@ -223,31 +223,27 @@ public Reachability Merge(IImmutableSet<UniqueAddress> allowed, Reachability oth
var rows1 = ObserverRows(observer);
var rows2 = other.ObserverRows(observer);

if (rows1 == null && rows2 == null)
continue;

if (rows1 != null && rows2 != null)
{
// We throw away a complete set of records based on the version here. Couldn't we lose records here? No,
// because the observer gossips always the complete set of records. (That's hard to see in the model, because
// records also contain the version number for which they were introduced but actually the version number
// corresponds to the whole set of records of one observer at one point in time.
var rows = observerVersion1 > observerVersion2 ? rows1 : rows2;
recordBuilder.AddRange(rows.Values.Where(r => allowed.Contains(r.Subject)));
foreach (var record in rows.Values.Where(r => allowed.Contains(r.Subject)))
recordBuilder.Add(record);
}

if (rows1 != null && rows2 == null)
if (observerVersion1 > observerVersion2)
recordBuilder.AddRange(rows1.Values.Where(r => allowed.Contains(r.Subject)));
foreach (var record in rows1.Values.Where(r => allowed.Contains(r.Subject)))
recordBuilder.Add(record);
if (rows1 == null && rows2 != null)
if (observerVersion2 > observerVersion1)
recordBuilder.AddRange(rows2.Values.Where(r => allowed.Contains(r.Subject)));
foreach (var record in rows2.Values.Where(r => allowed.Contains(r.Subject)))
recordBuilder.Add(record);

if (observerVersion2 > observerVersion1)
newVersions = newVersions.SetItem(observer, observerVersion2);
}

newVersions = newVersions.Where(p => allowed.Contains(p.Key)).ToImmutableDictionary();
newVersions = ImmutableDictionary.CreateRange(newVersions.Where(p => allowed.Contains(p.Key)));

return new Reachability(recordBuilder.ToImmutable(), newVersions);
}
Expand Down

0 comments on commit 83c2205

Please sign in to comment.