Skip to content

Commit 8cf67b1

Browse files
authored
Avoid restarting history after rebrowse in some cases (#871)
If we discover new nodes there's no real reason to restart history.
1 parent 33975ec commit 8cf67b1

File tree

4 files changed

+13
-3
lines changed

4 files changed

+13
-3
lines changed

Extractor/History/HistoryReader.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -332,16 +332,17 @@ public void AddStates(IEnumerable<VariableExtractionState> varStates, IEnumerabl
332332
{
333333
lock (statesLock)
334334
{
335+
bool anyAdded = false;
335336
foreach (var state in varStates.Where(s => s.FrontfillEnabled))
336337
{
337-
activeVarStates[state.SourceId] = state;
338+
anyAdded |= activeVarStates.TryAdd(state.SourceId, state);
338339
}
339340

340341
foreach (var state in eventStates.Where(s => s.FrontfillEnabled))
341342
{
342-
activeEventStates[state.SourceId] = state;
343+
anyAdded |= activeEventStates.TryAdd(state.SourceId, state);
343344
}
344-
if (state.IsGood)
345+
if (state.IsGood && anyAdded)
345346
{
346347
stateChangedEvent.Set();
347348
}

Test/Integration/EventTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,8 @@ async Task Reset()
197197
extractor.State.Clear();
198198
var reader = (HistoryReader)extractor.GetType().GetField("historyReader", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(extractor);
199199
reader.AddIssue(HistoryReader.StateIssue.NodeHierarchyRead);
200+
((Dictionary<NodeId, VariableExtractionState>)reader.GetType().GetField("activeVarStates", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(reader)).Clear();
201+
((Dictionary<NodeId, EventExtractionState>)reader.GetType().GetField("activeEventStates", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(reader)).Clear();
200202
await tester.RemoveSubscription(extractor, SubscriptionName.Events);
201203
}
202204

Test/Unit/CDFPusherTest.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1266,6 +1266,8 @@ public async Task TestCDFAsSourceData()
12661266
string oldTimeseries = System.Text.Json.JsonSerializer.Serialize(handler.TimeseriesRaw);
12671267
extractor.ClearKnownSubscriptions();
12681268
var reader = (HistoryReader)extractor.GetType().GetField("historyReader", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(extractor);
1269+
((Dictionary<NodeId, VariableExtractionState>)reader.GetType().GetField("activeVarStates", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(reader)).Clear();
1270+
((Dictionary<NodeId, EventExtractionState>)reader.GetType().GetField("activeEventStates", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(reader)).Clear();
12691271
reader.AddIssue(HistoryReader.StateIssue.NodeHierarchyRead);
12701272
await extractor.RunExtractor(true);
12711273
Assert.True(extractor.State.NodeStates.Count > 0);

manifest.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ schema:
6767
- "https://raw.githubusercontent.com/"
6868

6969
versions:
70+
"2.28.2":
71+
description: Avoid restarting history after rebrowse if no new nodes were discovered.
72+
changelog:
73+
fixed:
74+
- Fix issue causing history to be restarted if rebrowse was triggered but no new nodes were discovered.
7075
"2.38.1":
7176
description: Fix issue causing the extractor to stop pushing datapoints if pushing nodes to CDF during rebrowse fails.
7277
changelog:

0 commit comments

Comments
 (0)