fix(site-runtime): NativeAlarmActor retries a lost subscribe response, not only a failed one (S4)
This commit is contained in:
@@ -129,6 +129,15 @@ public class NativeAlarmActor : ReceiveActor
|
|||||||
SourceReference: _source.SourceReference,
|
SourceReference: _source.SourceReference,
|
||||||
ConditionFilter: _source.ConditionFilter,
|
ConditionFilter: _source.ConditionFilter,
|
||||||
Timestamp: DateTimeOffset.UtcNow));
|
Timestamp: DateTimeOffset.UtcNow));
|
||||||
|
|
||||||
|
// Arm a response-timeout retry so a LOST subscribe response is re-sent, not
|
||||||
|
// only a failure reply (S4). Cancelled on a Success reply; a failure reply
|
||||||
|
// re-arms it at 1× (overriding this 2× response-timeout arm). 2× interval so
|
||||||
|
// a slow-but-arriving response is not pre-empted by a redundant re-send.
|
||||||
|
_retryTimer?.Cancel();
|
||||||
|
_retryTimer = Context.System.Scheduler.ScheduleTellOnceCancelable(
|
||||||
|
TimeSpan.FromMilliseconds(_options.NativeAlarmRetryIntervalMs * 2),
|
||||||
|
Self, RetrySubscribe.Instance, Self);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HandleRehydration(RehydrationCompleted msg)
|
private void HandleRehydration(RehydrationCompleted msg)
|
||||||
@@ -270,6 +279,8 @@ public class NativeAlarmActor : ReceiveActor
|
|||||||
{
|
{
|
||||||
if (resp.Success)
|
if (resp.Success)
|
||||||
{
|
{
|
||||||
|
// Success — cancel the response-timeout retry armed in SendSubscribe.
|
||||||
|
_retryTimer?.Cancel();
|
||||||
_logger.LogInformation("Native alarm subscription established for {Source} on {Instance}",
|
_logger.LogInformation("Native alarm subscription established for {Source} on {Instance}",
|
||||||
_source.CanonicalName, _instanceName);
|
_source.CanonicalName, _instanceName);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -378,4 +378,18 @@ public class NativeAlarmActorTests : TestKit, IDisposable
|
|||||||
File.Delete(_dbFile);
|
File.Delete(_dbFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void LostSubscribeResponse_ResendsSubscribe()
|
||||||
|
{
|
||||||
|
// S4: a LOST subscribe response (no reply at all) must be re-sent, not only
|
||||||
|
// a failure reply. The response-timeout arm fires at 2× the retry interval.
|
||||||
|
var options = new SiteRuntimeOptions { NativeAlarmRetryIntervalMs = 200 };
|
||||||
|
var dcl = CreateTestProbe();
|
||||||
|
Spawn(CreateTestProbe().Ref, dcl.Ref, options);
|
||||||
|
|
||||||
|
dcl.ExpectMsg<SubscribeAlarmsRequest>();
|
||||||
|
// Swallow the response entirely — the actor must still re-subscribe.
|
||||||
|
dcl.ExpectMsg<SubscribeAlarmsRequest>(TimeSpan.FromSeconds(5));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user