IMD SolutionComputing LibraryShop main store

Troubleshooting

MQTT Engine Bad_Stale tags after removing a Transmission tag

Edge computing and IIoT Published 6 min read By IMD Solution engineering team

Short answer

MQTT Engine has no automatic pruning for Sparkplug tags retired on the Transmission side: a removed metric stays in the tag tree with Bad_Stale quality. Delete it manually or with a scripted batch, but only after a refreshed birth confirms the metric is absent and live tags keep updating. The native UNS path is the exception, with its Delete UNS Tags control.

On this page
  1. What Bad_Stale means for a retired metric
  2. Prove the metric is retired, not just unreachable
  3. Delete the confirmed tags
  4. What stale accumulation costs at scale
  5. The native UNS exception: Delete UNS Tags
  6. Which stale tag is which
  7. Questions asked

Deleting a tag in MQTT Transmission does not delete its counterpart in MQTT Engine. When the edge publisher retires a metric, the Engine-side tag stays in the tree and its quality settles at Bad_Stale, because automatic pruning of removed Sparkplug metrics is not implemented; the module vendor has publicly listed it as an open backlog item and directs users to manual or scripted cleanup. That makes deletion a deliberate step: prove the metric is absent from the publisher's refreshed birth, confirm unaffected tags still update, then delete the Engine tag by hand or with the documented Ignition scripting function. The one exception is MQTT Engine's native UNS path, which exposes a Delete UNS Tags control. This article gives the checks that separate a retired metric from a tag that is merely stale because communication stopped, the deletion procedure, and the arithmetic that shows why unpruned stale tags matter at UNS scale.

What Bad_Stale means for a retired metric #

MQTT Engine builds its tag tree from what the publisher declares. A Sparkplug birth message (NBIRTH for an edge node, DBIRTH for a device) lists every metric the publisher reports, and Engine creates one persistent Engine tag per declared metric. Values then travel only in DDATA messages published on change, the pattern described in Why Sparkplug B sends DBIRTH once and DDATA only on change.

When you delete the source tag in MQTT Transmission and refresh, the next birth simply no longer lists that metric. Nothing tells Engine to remove the old tag: it stays as a created object, no DDATA ever arrives for it again, and its quality settles at Bad_Stale. Additions propagate automatically because a birth declares them; removals do not, because absence from a birth is not an instruction to delete. The same keep-what-was-created behavior appears elsewhere in Engine, for example when tags survive a shrinking JSON array.

Prove the metric is retired, not just unreachable #

Stale quality alone is a poor deletion test: a perfectly live metric also goes stale whenever its data path stops. An outage on the publisher, broker or subscription marks tags stale in exactly the same way, and Why MQTT Engine still feeds old tags after a broker stops covers that failure, where the fix is restoring communication rather than deleting tags. Run these checks before you delete anything:

  1. Refresh the publisher with a disposable test metric. Pick or create a tag in the same edge node and device branch as the affected tags, refresh MQTT Transmission, and confirm the metric appears in Engine and follows a value change. This proves the birth and refresh path works.
  2. Delete that disposable source metric and repeat the same refresh. Inspect the Transmission-side definition, its statistics or the decoded birth, and confirm the refreshed birth no longer contains that metric.
  3. Stop here if the birth still carries it. A publisher that still advertises a metric you deleted has a source-tree problem, and any Engine tag you remove will be recreated on the next birth.
  4. Confirm neighbors still update. While the candidate sits at Bad_Stale, unaffected tags in the same branch must keep changing value; that separates one retired metric from a session-wide stall.
  5. Build the candidate list from identity, not from quality. Match each Engine tag to its edge node, device and metric name, and compare against the current publisher definitions, never against the stale flag alone.

One caution before deletion: a tag that a running display, alarm or historian record still references must be unhooked first, or operators lose that point without warning.

Delete the confirmed tags #

For a short confirmed list, delete the Engine tags by hand in the tag browser, record the deleted paths, then refresh the publisher and confirm nothing returns. A tag that reappears was still advertised, or another mapping recreates it.

For a long list, script it. The documented Ignition scripting function is system.tag.deleteTags, and the 8.1 User Manual notes that deleting a tag folder path removes the folder and every tag under it, so scope the list to exact tag paths rather than a whole folder unless the entire branch is retired. A minimal example, where stalePaths is my example variable and the two paths are examples only:

# Run only after the checks in the previous section.
# stalePaths: list of Engine tag paths confirmed absent from the refreshed birth.
stalePaths = ['Sparkplug Devices/PackLine1/Press/OilTempC',
              'Sparkplug Devices/PackLine1/Press/StampCount']
print(system.tag.deleteTags(stalePaths))

After the call, verify in the tag browser that the approved objects are gone and neighboring live tags still update. Keep candidate discovery separate from deletion: generate the report, review it against the publisher definitions, get the list approved, then delete exactly that list. Cleaning Engine's tag tree is not the same job as pruning the historian's own tag browser, which has its own procedure in Remove stale tags from the Ignition historian tag browser.

What stale accumulation costs at scale #

Unpruned stale tags are cheap one at a time and expensive in bulk. Worked example, with illustrative numbers:

  • A packaging line publishes one edge node with 40 metrics.
  • Station rebuilds retire 6 metrics every quarter. Over 12 months that is 6 × 4 = 24 retired metrics.
  • Engine still holds every one of them, so the tree shows 40 + 24 = 64 tags, of which 24 ÷ 64 = 0.375, meaning 37.5 percent of the tree is dead weight that still appears in searches, exports and any downstream consumer that enumerates tags.
  • The arithmetic scales linearly: a UNS namespace with 100,000 tags and the same retirement share carries about 0.375 × 100,000 = 37,500 stale tags.

Decision: on a tree of a few dozen tags, delete by hand at each retirement, a few minutes of work each quarter. On a namespace in the tens of thousands of tags, put a scripted sweep on a schedule with a dry-run candidate report, an approved deletion list and a post-refresh check, and run that sweep every quarter rather than letting the dead weight compound.

The native UNS exception: Delete UNS Tags #

MQTT Engine's native UNS support, the mode that maps an ISA-95 enterprise structure directly, exposes a documented boolean control named Delete UNS Tags, provided precisely to remove tags from that native UNS namespace. It is an exception, not a general fix: it belongs to the native UNS path and does not prune a Sparkplug-imported tree metric by metric. For the Sparkplug-imported path, the vendor's stated position is that cleanup stays manual or scripted, with a possible future auto-prune tied to a later Sparkplug specification iteration rather than to a current Engine release, so treat any change as something to verify in the release notes of your installed version.

Which stale tag is which #

Observation in Engine Likely cause Action
One tag at Bad_Stale, neighbors in the same branch updating Metric retired at the publisher Confirm absence from the refreshed birth, then delete the Engine tag
Many tags stale at once, including previously healthy ones Publisher, broker or subscription outage Restore communication first; do not delete
A deleted Engine tag reappears after a refresh The publisher still advertises the metric Fix the source tree, re-verify the birth, delete again
New source metrics also fail to appear Birth, refresh or import path broken Repair the import path before any cleanup

The decision in every case is the same: no auto-prune exists on the Sparkplug path, so removal is a deliberate, verified step — prove absence, unhook consumers, delete the exact approved list, refresh the publisher, and check that only the approved tags disappeared.

Questions asked

Will a future MQTT Engine release delete removed Sparkplug tags automatically?

The module vendor has publicly listed automatic pruning of removed Sparkplug metrics as a backlog item rather than a shipped feature, and has tied a possible future fix to a later Sparkplug specification iteration. Plan on manual or scripted deletion for current behavior, and treat any change as something to confirm in the release notes of the exact Engine version you run.

What does the Delete UNS Tags boolean in MQTT Engine do?

It belongs to MQTT Engine's native UNS support, the mode that maps an ISA-95 enterprise structure directly. That boolean removes tags from the native UNS namespace and is the one built-in cleanup control of this kind. It does not apply to a Sparkplug-imported tag tree, where removed metrics stay at Bad_Stale until you delete them by hand or by script.

Is Bad_Stale alone proof that a tag is safe to delete?

No. Any tag goes stale when its data path stops, so a broker outage, a dropped publisher session or a broken subscription produces the same quality on live metrics. Treat Bad_Stale as a candidate flag only: confirm the metric is absent from the publisher's refreshed birth and that unaffected tags in the same branch keep updating before deleting.

Can a deleted MQTT Engine tag come back?

Yes. If the publisher still advertises the metric, the next birth recreates the tag, and another mapping or a metrics-copier script can recreate it too. If a deleted tag returns, fix the source tag tree or the copying logic first, re-verify the refreshed birth, and only then repeat the deletion and check that it stays gone.

Keep reading

  • How-to

    Publish raw JSON from Ignition Document tags via MQTT Transmission

    Neither MQTT Transmission transmitter can emit a Document tag as the raw MQTT body: the UNS Transmitter escapes it as a String inside its JSON envelope, and the Sparkplug Transmitter carries it as a String metric inside Protobuf. The supported route on Ignition 8.3 is the module's publish API — your script serializes the document once, publishes it to the agreed topic, and a one-pass subscriber parse proves the body is raw.

    Edge computing and IIoT

  • Troubleshooting

    Why MQTT Engine shows online status after an edge node drops

    An Info/Online tag that stays true with Good quality is not proof the edge node is alive: Engine's online state comes from the node's Sparkplug death certificate, and earlier Engine versions marked tags stale only on Engine shutdown. Read Info/Online, tag quality and Store & Forward stored metrics as three separate indicators, retest on Engine 4.0.8 with Ignition 8.0.16 or later, and compare against a node that reports correctly before escalating.

    Edge computing and IIoT

  • Troubleshooting

    Why MQTT Engine tags miss transmitted Sparkplug properties

    MQTT Transmission publishes a tag property in DBIRTH only when it is unfiltered and its value differs from the Ignition default, and MQTT Engine applies it only when its own filtered list permits. On the reported 4.0.20 modules, Convert UDTs blocks properties on UDT-derived tags; disable conversion, refresh the transmitter, and the properties land.

    Edge computing and IIoT

Why PI tags stop updating after manual clock changes