cfd403710e
Every HistoryUpdate a SQL backend applies now leaves a modification trail
(prior value, principal, Part 11 update type, modification time), and
HistoryReadRaw with IsReadModified=true serves it as HistoryModifiedData.
- Core: HistoryUpdateContext threaded into all three IHistorianDataUpdater
methods; IHistorianDataSource.ReadModifiedAsync (default NotSupported =>
BadHistoryOperationUnsupported on Gateway/Null); HistoryModified* contracts.
- SqlServer: schema v2 (002_sample_modified.sql, RequiredVersion=2, docs copy);
trail written by OUTPUT ... INTO on the same MERGE/DELETE statement, so a
failed update leaves no audit row; retention purges SampleModified per tag on
the source-time cutoff; ReadModifiedAsync keyed on (SourceTimeUtc, ModifiedId).
- QuestDB: append-only {prefix}sample_modified (TTL like samples), trail row
written BEFORE the change (orphan-on-crash, never an untracked change);
existence reads now carry the prior value; ReadModifiedAsync.
- Node manager: modified reads dispatch + page via the #669 continuation store
(HistoryContinuationState gains HistoryCursorKind + LastModifiedId), gated by
the existing HistoryRead decision; session principal / key id passed to the
updater. IsDeleteModified stays unsupported.
- Client.CLI: historyread --modified.
- Tests: node-manager dispatch/paging/cursor binding/principal threading,
over-the-wire HistoryModifiedData, shared ModifiedValueConformance on both
backends, SqlServer atomicity (forced trail failure => no change) + v1->v2
upgrade + retention trail purge.
- Docs: Historian.md (Modified-value history section, schema v2 upgrade note),
security.md, Client.CLI.md, CLAUDE.md.
39 lines
1.7 KiB
C#
39 lines
1.7 KiB
C#
using Shouldly;
|
|
using Xunit;
|
|
using ZB.MOM.WW.OtOpcUa.Core.Abstractions;
|
|
using ZB.MOM.WW.OtOpcUa.Driver.Historian.Sql.Common;
|
|
|
|
namespace ZB.MOM.WW.OtOpcUa.Driver.Historian.QuestDb.IntegrationTests;
|
|
|
|
public sealed partial class TombstoneTests
|
|
{
|
|
/// <summary>
|
|
/// The live writer's outbox redelivers batches (at-least-once). A batch replayed after an operator's
|
|
/// DeleteAtTime must not bring the deleted sample back: the writer's existence check counts a tombstone as
|
|
/// present (it deliberately does not filter <c>NOT deleted</c>), so the redelivered row is skipped.
|
|
/// </summary>
|
|
[Fact]
|
|
public async Task Tombstone_is_not_resurrected_by_a_writer_redelivery()
|
|
{
|
|
fx.SkipIfUnavailable();
|
|
var rig = UpdateTests.MakeRig(fx);
|
|
var writer = new QuestDbHistorianValueWriter(rig.Conn, rig.Tags,
|
|
new QuestDbWalVisibility(rig.Conn, TimeSpan.FromSeconds(5)));
|
|
HistorizationValue[] batch =
|
|
[
|
|
new(T0, HistorianValue.FromDouble(1), HistorianStatusCodes.Good),
|
|
new(T0.AddSeconds(1), HistorianValue.FromDouble(2), HistorianStatusCodes.Good),
|
|
];
|
|
|
|
(await writer.WriteLiveValuesAsync("r", batch, default)).ShouldBeTrue();
|
|
(await rig.Updater.DeleteAtTimeAsync("r", [T0], UpdateTests.Who, default)).ShouldBe([HistorianStatusCodes.Good]);
|
|
(await writer.WriteLiveValuesAsync("r", batch, default)).ShouldBeTrue(); // the redelivery
|
|
|
|
(await UpdateTests.RowsAsync(rig, "r", liveOnly: true)).Select(r => r.Num).ShouldBe([2d]);
|
|
var all = await UpdateTests.RowsAsync(rig, "r");
|
|
all.Count.ShouldBe(2);
|
|
all[0].Deleted.ShouldBeTrue();
|
|
all[0].Num.ShouldBeNull();
|
|
}
|
|
}
|