diff --git a/docs/drivers/AbLegacy.md b/docs/drivers/AbLegacy.md
index 351d2495a..8bdd8a1db 100644
--- a/docs/drivers/AbLegacy.md
+++ b/docs/drivers/AbLegacy.md
@@ -381,4 +381,4 @@ and the UI authoring flow.
## Read-plan cache (#1073)
-`ReadAsync` memoises its plan (resolution, per-device bucketing, coalesced-block planning) per EXACT ordered reference list, up to 64 lists per device-table generation (a full cache is cleared). The cache is dropped on every initialise and teardown, so a config change re-plans. The plan is cached as if no block were refused; the device's current refused-block memory is applied at use time. Reads containing an unresolved reference are not cached.
+`ReadAsync` memoises its plan (resolution, per-device bucketing, coalesced-block planning) per EXACT ordered reference list, up to 64 lists per device-table generation (a full cache is cleared). The cache is dropped on every initialise and teardown, so a config change re-plans. The plan is cached as if no block were refused; the device's current refused-block memory is applied at use time. A plan holding a TRANSIENT unresolved reference (resolver miss / unknown device) is never cached, so a late resolution is not pinned Bad; deterministic refusals (a malformed address, a config-rejected tag) are cached (#1087) because they only change on re-initialise, which drops the cache.
diff --git a/docs/security.md b/docs/security.md
index 5b86a8c2f..0b4b9bd77 100644
--- a/docs/security.md
+++ b/docs/security.md
@@ -2121,6 +2121,7 @@ The five config secrets and their canonical secret names:
| `Security:Jwt:SigningKey` | `JwtOptions` | `otopcua/jwt/signing-key` |
| `Security:Ldap:ServiceAccountPassword` | `LdapOptions` | `otopcua/ldap/service-account-password` |
| `Security:DeployApiKey` | `DeployApiEndpoints` | `otopcua/deploy/api-key` |
+| `Security:FailoverApiKey` | `ManualFailoverApiEndpoints` (#1078) | `otopcua/failover/api-key` |
| `ConnectionStrings:ConfigDb` | `AddOtOpcUaConfigDb` | `otopcua/sql/configdb-connstr` |
| `ServerHistorian:ApiKey` | `ServerHistorianOptions` | `otopcua/historian/api-key` |
diff --git a/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.AbLegacy/AbLegacyDriver.Coalescing.cs b/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.AbLegacy/AbLegacyDriver.Coalescing.cs
index 9af09443c..a2bbe33ed 100644
--- a/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.AbLegacy/AbLegacyDriver.Coalescing.cs
+++ b/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.AbLegacy/AbLegacyDriver.Coalescing.cs
@@ -170,7 +170,7 @@ public sealed partial class AbLegacyDriver
}
/// The planned, device-bucketed form of one read's reference list (#1073).
- private sealed record ReadPlan((int Index, uint Status)[] Unresolved, DevicePlan[] Devices);
+ private sealed record ReadPlan((int Index, uint Status)[] Unresolved, DevicePlan[] Devices, bool HasTransient = false);
/// One device's units, planned with no block refusal applied (see ).
private sealed record DevicePlan(DeviceState Device, List Units);
@@ -221,9 +221,10 @@ public sealed partial class AbLegacyDriver
if (cache.Plans.TryGetValue(key, out var hit)) return hit;
var plan = BuildReadPlan(devices, key);
Interlocked.Increment(ref _readPlanBuilds);
- // Only a plan with no Unresolved entries is cached: an unresolved reference may resolve later (a transient
- // equipment-tag parse), and caching would pin the Bad answer.
- if (plan.Unresolved.Length == 0)
+ // A plan is cached unless it holds a TRANSIENT unresolved reference (resolver miss / unknown device: it may
+ // resolve later, and caching would pin the Bad answer). Deterministic refusals - a malformed address or a
+ // config-rejected tag - are cached (#1087); both only change on re-initialise, which drops the cache.
+ if (!plan.HasTransient)
{
if (cache.Plans.Count >= MaxCachedReadPlans) cache.Plans.Clear();
cache.Plans[key] = plan;
@@ -244,6 +245,7 @@ public sealed partial class AbLegacyDriver
private ReadPlan BuildReadPlan(Dictionary devices, string[] references)
{
var unresolved = new List<(int, uint)>();
+ var transient = false;
var buckets = new Dictionary>(ReferenceEqualityComparer.Instance);
for (var i = 0; i < references.Length; i++)
{
@@ -251,6 +253,7 @@ public sealed partial class AbLegacyDriver
if (!_resolver.TryResolve(reference, out var def) || !devices.TryGetValue(def.DeviceHostAddress, out var device))
{
unresolved.Add((i, AbLegacyStatusMapper.BadNodeIdUnknown));
+ transient = true;
continue;
}
// A tag whose data type its device's PLC family does not ship is a per-tag configuration error: answered
@@ -271,7 +274,8 @@ public sealed partial class AbLegacyDriver
list.Add(new ReadItem(i, reference, def, parsed));
}
return new ReadPlan([.. unresolved],
- [.. buckets.Select(kv => new DevicePlan(kv.Key, PlanReadUnits(kv.Key, kv.Value, applyRefusals: false)))]);
+ [.. buckets.Select(kv => new DevicePlan(kv.Key, PlanReadUnits(kv.Key, kv.Value, applyRefusals: false)))],
+ transient);
}
/// What a block read concluded; = read the members singly instead.
diff --git a/tests/Drivers/ZB.MOM.WW.OtOpcUa.Driver.AbLegacy.Tests/AbLegacyReadPlanCacheTests.cs b/tests/Drivers/ZB.MOM.WW.OtOpcUa.Driver.AbLegacy.Tests/AbLegacyReadPlanCacheTests.cs
index 8399906ed..1c1ad6d40 100644
--- a/tests/Drivers/ZB.MOM.WW.OtOpcUa.Driver.AbLegacy.Tests/AbLegacyReadPlanCacheTests.cs
+++ b/tests/Drivers/ZB.MOM.WW.OtOpcUa.Driver.AbLegacy.Tests/AbLegacyReadPlanCacheTests.cs
@@ -74,6 +74,36 @@ public sealed class AbLegacyReadPlanCacheTests
drv.CachedReadPlanCount.ShouldBe(0);
}
+ [Fact]
+ public async Task A_malformed_address_plan_is_cached_but_a_transient_unresolved_reference_is_not()
+ {
+ var factory = new FakeAbLegacyTagFactory { Customise = p => new FakeAbLegacyTag(p) { Value = 1 } };
+ var drv = new AbLegacyDriver(new AbLegacyDriverOptions
+ {
+ Devices = [new AbLegacyDeviceOptions(Host)],
+ RawTags = AbLegacyRawTags.Entries([
+ new AbLegacyTagDefinition("Good", Host, "N7:0", AbLegacyDataType.Int),
+ new AbLegacyTagDefinition("Bad", Host, "not-an-address", AbLegacyDataType.Int)]),
+ Probe = new AbLegacyProbeOptions { Enabled = false },
+ }, "drv-plan", factory);
+ await drv.InitializeAsync("{}", CancellationToken.None);
+
+ // Deterministic: malformed address -> cached, built once.
+ string[] malformed = ["Good", "Bad"];
+ await drv.ReadAsync(malformed, CancellationToken.None);
+ await drv.ReadAsync(malformed, CancellationToken.None);
+ drv.ReadPlanBuilds.ShouldBe(1);
+ drv.CachedReadPlanCount.ShouldBe(1);
+
+ // Positive control: an unknown reference (transient resolver miss) is never pinned.
+ string[] unknown = ["Good", "NoSuchTag"];
+ await drv.ReadAsync(unknown, CancellationToken.None);
+ await drv.ReadAsync(unknown, CancellationToken.None);
+ drv.ReadPlanBuilds.ShouldBe(3);
+ drv.CachedReadPlanCount.ShouldBe(1);
+ await drv.ShutdownAsync(CancellationToken.None);
+ }
+
[Fact]
public async Task The_cache_is_bounded()
{