Comparison
Why a direct MQTT Collector SQLite edit needs the service stopped
Short answer
Direct edits to mqttcollector.sqlite work only with the entire MQTT Collector service stopped: the supported tile path is the safe default, a scripted edit with the service stopped is the fast path for tens of thousands of tags and costs one collection gap per edited site, and disabling a single collection group is ruled out because the running process still holds the file open.

On this page
- Can you edit mqttcollector.sqlite directly?
- Is there a supported alternative to the edit?
- Why is disabling one collection group not enough?
- Which edit path should you choose?
- How long will the collector be down for the edit?
- What happens to tag data while the service is stopped?
- What is the safe procedure for a scripted edit?
- How do you keep the script working after an upgrade?
- Questions asked
You can script bulk changes to the MQTT Collector's SQLite tag database, and the method is exactly as unsupported as it is fast: the entire collector service stops for the edit, the script runs against the quiet file, the service starts again, and collection at that site pauses for the length of that window. This comparison puts the three realistic paths side by side — supported tile changes, a scripted edit with the whole service stopped, and a scripted edit with only the collection group disabled — and rules the third one out, because a disabled group does not close the file and the running process and your script still share one SQLite database. The deciding inputs are the change-set size, the measured script runtime, and what the broker does with published messages while the collector is down.
Can you edit mqttcollector.sqlite directly? #
Yes — as an unsupported, at-your-own-risk method with two firm conditions: the vendor's stated guidance is that the entire MQTT Collector service must be stopped for the whole edit and restarted only after the changes are committed.
The MQTT Collector is the Canary historian's MQTT ingest service, and it keeps tag rows, collection groups and historize flags for every site it serves in this one file. A script can update tens of thousands of those rows inside one transaction, which is precisely what the supported interface cannot do quickly. The vendor's position on direct modification is that customers have made it work, but the outcome of under-the-covers changes cannot be guaranteed, such edits are hard for support to diagnose, and they are done at your own risk. The two conditions above are what make it workable at all: the process must be gone while the file is written, and it must come back only after a clean commit. An idle service is not a version of this method.
Is there a supported alternative to the edit? #
Yes: the MQTT Collector tile in the Admin interface is the supported path for normal change volume, and a Boolean gate that inhibits historian logging per tag covers the not-every-tag-needs-history case without touching the database file.
The tile writes every change through the running service, so there is no file conflict, no stop and no restart; its cost is interaction, one tag at a time, and five-figure change sets are what push engineers toward the file. If the actual goal is a smaller history volume rather than reorganized collection, supported configuration can deliver it: inhibiting historian logging of one tag with a Boolean gate keeps a tag collected while keeping its values out of the historian, and inhibiting historian logging of one tag with a Boolean gate walks through that setup. Decision: routine change sets and any site that cannot tolerate a collection gap stay on these two supported paths.
Why is disabling one collection group not enough? #
It is not: a disabled collection group only changes what the running service collects, while the process stays alive with the database file open and its configuration loaded, so the conflict the stop requirement exists to prevent is still present.
A group disable acts on the configuration the service holds in memory; it tells the process to stop collecting that group's tags and nothing more. SQLite allows a single writer at a time, and the live service can write at any moment for its own bookkeeping, so the script competes for the write lock and can interleave with the service's writes. Even a commit that lands cleanly leaves the service holding configuration that no longer matches the file, with no mechanism to tell it so. That is why the guidance for this collector is to stop the entire service, where the risk is lower — and why the group-disabled edit is ruled out in the table below.
Which edit path should you choose? #
Choose the tile for routine change sets of hundreds of tags, the stopped-service script for bulk CSV-driven changes in the tens of thousands to hundreds of thousands, and no direct edit at all while the service runs, group disabled or not.
The scale behind that split is real: sites on this collector run tens of thousands to hundreds of thousands of tags, of which only a subset needs historizing. The tile's effort grows with the number of tags touched; the script's effort is one transaction, so it grows with rows updated but finishes in minutes at either scale. What the script buys with its speed is a collection gap and an unsupported file write, so conflict risk and the gap decide the case, not speed alone.
| Approach | Vendor position | File-conflict risk | Collection impact during the edit | Speed at a five-figure change set |
|---|---|---|---|---|
| MQTT Collector tile | Supported | None | None | Slow; one entry per tag |
| Script, entire service stopped | Not supported; works for some; at your own risk | Lowest of the direct paths | All collection at that site stops for the window | Fast; one transaction |
| Script, only the group disabled | Not recommended; the stated advice is the whole service | Higher; the running process still holds the file open | Only that group stops | Fast, but ruled out |
| Script, service running | Ruled out | Highest; two writers on one SQLite file | None, until stale configuration or corruption appears | Fast, but ruled out |
On a multi-site fleet the script wins only if the gap is acceptable; the next two sections size it and cost it out.
How long will the collector be down for the edit? #
Budget the window as stop time plus script time measured on a copy plus start time; on the illustrative site below that sums to 2 + 9 + 3 = 14 minutes of collection gap, and the middle term is never assumed.
Worked example, with illustrative inputs you replace with your own measurements: a site carries 100,000 tags and the CSV change set flags 40,000 rows. A trial of the script against a copy of the database commits in 9 minutes. On that host the service takes 2 minutes to stop and 3 minutes to start, timed during an ordinary maintenance restart. The planned gap is therefore 2 + 9 + 3 = 14 minutes.
The gap also sizes the broker queue. If that site's devices publish about 2,000 messages per minute in total and the collector's session is persistent at QoS 1, each broker on the path must hold roughly 2,000 × 14 = 28,000 messages per collector session. Compare that figure with the broker's configured queue limit before scheduling: a smaller limit drops messages exactly as if no session existed.
Stagger the edits one site at a time. A fleet-wide push stops collection everywhere at once, while a one-site-at-a-time schedule caps the blind period at 14 minutes on a single site; a site that cannot tolerate any gap stays on the tile.
What happens to tag data while the service is stopped? #
Whatever the broker queues is a broker decision, not a collector one: a persistent session at QoS 1 or 2 may have the broker holding messages for you within its own queue limits, while a clean session or QoS 0 loses everything published during the stop.
While the collector is down it is simply not subscribed, so broker configuration decides the outcome for every message published in the window.
| Broker-side condition | What reaches the historian after the restart |
|---|---|
| Persistent session, subscription at QoS 1 or 2 | The broker may queue published messages for the collector, within its own queue limits; size those limits against the stop window and the publish rate |
| Clean session, or any subscription at QoS 0 | Messages published during the stop are lost to the historian |
| Retained messages on the topics | Only the last retained value per topic arrives on resubscribe; intermediate changes never do |
If the window's data matters on a clean-session or QoS 0 site, plan recovery rather than queuing: backfilling late and out-of-order data into Canary collectors covers pushing missed values in after the fact. Decision: persistent QoS 1 sessions with enough queue room make the gap nearly invisible; QoS 0 sites lose the window for good, so schedule their edits when the published data is redundant or backfillable.
What is the safe procedure for a scripted edit? #
Take a fresh file copy, stop the whole service, confirm the process has exited, validate the schema, run the whole change in one transaction, check the file's integrity, and only then start the service — in that order, with no step skipped.
- Stop the entire MQTT Collector service on the host, then confirm the process has exited and the file is released before anything opens it. A disabled collection group is not a substitute; the process must be gone.
- Take a copy of the database immediately before the edit as the rollback artifact. Scheduled volume snapshots remain a useful backstop, but they do not replace this copy.
- Map the schema on a test installation: make one historize change and one removal in the tile, then diff the affected rows against untouched rows. There is no published data dictionary, so the
.schemaoutput plus these diffs is the map of the fields and companion rows your script must write. - Make the script read the live schema on every run and abort on any difference from the schema copy it was validated against.
- Wrap all updates in one transaction, roll back on any error, and commit only when the changed-row count equals the CSV row count.
- Run an integrity check on the edited file, close every handle the script and the shell still hold, start the service, and confirm one known tag updates end to end before calling the window closed.
The transaction core, with every table and column name taken from your own schema output:
BEGIN IMMEDIATE;
-- table and column names come from the .schema output of the build you validated against
-- UPDATE <tag_table> SET <historize_flag> = ... WHERE <tag_key> IN ( ...rows from the CSV... );
-- abort and ROLLBACK unless the changed-row count equals the CSV row count
COMMIT;
PRAGMA integrity_check;
How do you keep the script working after an upgrade? #
Treat the script as version-pinned: the schema of mqttcollector.sqlite has changed before and will change again, so the script must compare the live schema against the one it was validated on and abort on any mismatch.
| Upgrade risk | Control |
|---|---|
| A column renamed, moved or given a required value | The live schema is compared against the stored validated schema on every run; any difference aborts before the first write |
| Companion rows in other tables | The tile-diff test from the procedure is repeated on the new build, and the script's row set is rebuilt from that new diff |
| An unexplained fault after an edit | Restore the pre-edit copy, reproduce the fault through the tile, and only then raise it; direct modifications cannot be guaranteed by vendor support |
Record the collector version each stored schema was validated against, next to the schema file itself. The decision for each case: routine change sets and zero-gap sites go through the tile or the Boolean gate; bulk CSV-driven historizing goes through the script with the entire service stopped, measured first on a copy and staggered one site at a time; and the group-disabled edit never runs, because a live process holding the file is the exact condition the stop requirement exists to remove.
Questions asked
Does the MQTT Collector need a restart after a change made outside the tile?
Changes made in the Admin tile take effect without a restart because they arrive through the service's own interface. A file edit bypasses that interface, so a running service never learns that the file changed. Stopping the service before the edit and starting it afterwards doubles as the reload. A collection-group disable and enable does not do this, because it acts only on the configuration already in memory.
Is an hourly disk snapshot enough of a backup before the edit?
No. Scheduled volume snapshots are a useful backstop, but one taken hours earlier can predate configuration changes made since, and restoring it would undo those changes too. The rollback for an edit is a copy of the database taken immediately before that edit, with the service stopped, kept alongside the script that made the change.
What is the blast radius if a scripted edit goes wrong?
The file holds the tag configuration for every collection group the collector serves, so a corrupt or half-applied write can stop collection for all of them, not just the rows listed in the CSV. That is the case for the full-service stop, the single transaction, the schema check and the immediate pre-edit copy: together they bound the damage to one restored file and one collection gap.
How slow is the tile at five-figure change counts?
It depends on operator pace, but a plain estimate shows the problem. At one tag entry every 2 seconds, a change set of 40,000 tags is 40,000 × 2 = 80,000 seconds, about 22 hours of continuous clicking across shifts. The same updates in one SQLite transaction commit in minutes, which is the entire reason the scripted path exists.


