Persist tag values on gateway restart is creating duplicate historical entries

Tag History Duplicate Entry Issue

Problem Description

The system experiences duplicate entries in tag history during gateway restarts, creating data integrity issues in historical context.

Current Behavior

Normal Operation

  1. Calculation Result Storage: Engine computes values (e.g., E_CO2 = 10.5)
  2. Tag Value Write: Result is written to Ignition tag using tagRepository.writeTagValueOrCreate() (internal method, calls provider)
  3. Historian Trigger: Ignition historian automatically captures the tag value change to history database
  4. Requirement: System must capture ALL writes to history, including identical values (e.g., E_CO2 = 10.5 followed by E_CO2 = 10.5)

Problem During Gateway Restart

  1. Pre-Restart State: Tag has value E_CO2 = 10.5 (already stored in history at timestamp T1)
  2. Gateway Restart: Ignition gateway restarts for maintenance/updates
  3. Value Persistence: Gateway configuration setPersistValues(true) restores tag value E_CO2 = 10.5
  4. Historian Re-trigger: Historian treats the restored value as a "new" change
  5. Duplicate Entry: Same value E_CO2 = 10.5 gets written to history again with timestamp T2 (restart time)

Current Configuration

// Current settings attempt to balance requirements
TAG_HISTORY_TIME_DEADBAND = 0;
TAG_HISTORY_DEADBAND = 0.0;
HistoricalDeadbandMode = Off;

Has anyone run into this scenario, am I missing something with tag configuration or even system configuration that would solve the problem?

Ignition's Historian isn't designed to implement your requirement. You should use your own DB tables and script all of the writes you need.