fix(grpc-data): A1 review nit — colliding condition placements are logged at Warning (locally)

DistinctPlacements still drops every placement of an address claimed twice (fail closed); Compile takes an
optional logger (the coordinator passes its own) and the drop is reported in the local log only.
This commit is contained in:
Joseph Doherty
2026-11-24 10:44:00 -05:00
parent 16166c21e5
commit 2fdf9d87c2
3 changed files with 54 additions and 5 deletions
@@ -168,7 +168,7 @@ public sealed class LocalCatalogCoordinator
&& string.Equals(node.ClusterId, snapshot.ClusterId, StringComparison.OrdinalIgnoreCase)
&& node.Enabled && !node.MaintenanceMode)) return false;
var token = _activation.CaptureStagedAuthority(attempt.Epoch, state.AuthorityEpoch);
_staged = LocalExportCatalog.Compile(snapshot, serving, token);
_staged = LocalExportCatalog.Compile(snapshot, serving, token, logger: Logger);
if (_staged.DroppedUnknownOperations.Count != 0 && !string.Equals(_droppedExportRevision, attempt.Revision, StringComparison.Ordinal))
dropped = _staged.DroppedUnknownOperations;
_droppedExportRevision = attempt.Revision;
@@ -21,7 +21,8 @@ public sealed partial class LocalExportCatalog
/// <summary>Compile origin views from the deployed snapshot using the same identity and ACL producers as the SDK.</summary>
public static LocalExportCatalog Compile(DraftSnapshot snapshot, ServingIdentity serving,
IDataMappedCatalogAuthority activation, int maximumNodes = 100_000)
IDataMappedCatalogAuthority activation, int maximumNodes = 100_000,
Microsoft.Extensions.Logging.ILogger? logger = null)
{
ArgumentNullException.ThrowIfNull(snapshot);
serving.Validate(requireEpochs: true);
@@ -184,7 +185,7 @@ public sealed partial class LocalExportCatalog
kind == DataValueKind.Unspecified ? DataValueKind.Null : kind, supported: kind != DataValueKind.Unspecified, enabled: value.Enabled);
}
AddConditionPlacements();
return new(cluster, serving, activation, nodes, snapshot.DataExports, maximumNodes, DistinctPlacements(conditionPlacements));
return new(cluster, serving, activation, nodes, snapshot.DataExports, maximumNodes, DistinctPlacements(conditionPlacements, logger));
// A1 (§5.2): the UNS placements. Native: the RESERVED reference id Area/Line/Equipment/EffectiveName of every
// reference to an alarm-bearing tag — the same derivation as AddressSpaceComposer.BuildUnsReferenceVariables, which
@@ -231,8 +232,22 @@ public sealed partial class LocalExportCatalog
/// An address claimed by two placements is ambiguous: neither is listed (fail closed for conditions), and the v1
/// catalog compiles exactly as before.
/// </summary>
private static IReadOnlyList<LocalConditionPlacement> DistinctPlacements(IEnumerable<LocalConditionPlacement> placements) =>
placements.GroupBy(x => (x.View.Realm, x.View.Address.Identifier)).Where(x => x.Count() == 1).Select(x => x.Single()).ToArray();
/// <remarks>Review nit: the drop is logged at Warning — LOCALLY only (the identifiers may be RawPaths; nothing about
/// the collision reaches a peer, which simply does not see those conditions listed).</remarks>
private static IReadOnlyList<LocalConditionPlacement> DistinctPlacements(IEnumerable<LocalConditionPlacement> placements,
Microsoft.Extensions.Logging.ILogger? logger)
{
var groups = placements.GroupBy(x => (x.View.Realm, x.View.Address.Identifier)).ToList();
var colliding = groups.Where(x => x.Count() > 1).ToList();
if (colliding.Count > 0 && logger is not null)
{
Microsoft.Extensions.Logging.LoggerExtensions.LogWarning(logger,
"Origin catalog: {Count} condition placement address(es) are claimed by more than one placement and are not listed (fail closed): {Addresses}",
colliding.Count, string.Join(", ", colliding.Take(10).Select(g => $"{g.Key.Realm}:{g.Key.Identifier} x{g.Count()}")));
}
return groups.Where(x => x.Count() == 1).Select(x => x.Single()).ToArray();
}
private static DataValueKind ValueKind(string type) => type switch
{