Blog

    Mirth Connect Database Keeps Growing: Pruning and Archiving in the Storage Architecture

    By GauravAugust 19, 20269 mins read
    On this page

    A Mirth Connect database keeps growing until pruning and archiving become named jobs in the storage architecture. Completed messages can leave after an archive copy exists, queued and error rows stay until an owner clears them, and a database backup is a restore image rather than an archive you can browse.

    Written for digital health founders and hospital CTOs whose Connect engines are slowing down, it covers what may be pruned, the archive record, per-channel retention, rollout on a large store, and the checks that prove it works.

    What may you prune when the Mirth Connect database keeps growing?

    When the Mirth Connect database keeps growing, you may prune completed messages once an archive copy of each exists and has been counted. Agnotic Technologies never prunes QUEUED or ERROR rows, runs the pruner from one node only, and treats the archive, not the nightly backup, as the place to retrieve a single old message.

    The Connect database is still growing?

    We archive completed messages, prune once from a single node, and leave queued and error rows for an owner.

    • Archive: copy completed payload and status to the store that owns long-term records.
    • Prune: delete the engine's copy after that archive has a count.
    • Keep: QUEUED, ERROR, and anything still in flight. Those are work, not history.
    • One pruner: two jobs deleting the same rows fight the database.

    In a clustered setup, give one node the pruning schedule and leave it off on the rest. Two pruners deleting the same rows contend for the same tables and slow every channel on the server.

    Why does the Mirth Connect database keep growing?

    The database keeps growing because the engine stores each message at several stages, for every destination, until a retention rule removes it. Depending on a channel's storage setting, one inbound message can leave the raw content, transformed and encoded versions, and each destination's sent content and response behind.

    • Storage level: channels left at the level chosen during development, when every stage was kept for debugging.
    • No schedule: pruning never switched on after go-live, so nothing has ever left the store.
    • Large payloads: embedded PDFs, images or C-CDA documents carried inside messages.
    • Unowned errors: ERROR rows nobody resolves, which are never eligible for pruning.

    A store that grows without a plan slows every channel on the server, because inserts, status updates and the pruner all compete for the same tables.

    Why is a backup not the archive?

    A backup is a restore of the whole database. It is not a row you can fetch by message id. Agnotic archives first, then prunes. Restore stays a disaster recovery step.

    • Archive: one message, addressable, outside the engine.
    • Backup: the whole store, used only after a restore.
    • Forbidden: prune with neither archive nor a written retention exception.

    Which message statuses decide whether a row may leave?

    Status decides it. A message whose connectors all finished, whether sent or filtered, may be archived and then pruned. A message with any connector still queued, pending or in error stays in the store.

    Retention by Connect message status
    StatusWhat it means for retentionMay it be pruned?
    SENTThe destination accepted the messageYes, after archive
    FILTEREDA filter stopped the message on purposeYes, after archive, keeping the filter decision in the record
    RECEIVED or TRANSFORMED with no later statusProcessing did not finishNo, investigate first
    QUEUEDWaiting for a destinationNo
    PENDINGAwaiting a response or a later stepNo
    ERRORFailed and needs a decisionNo, until an owner resolves it

    A message is complete only when every destination connector is complete. One errored destination keeps the whole message in the store, even if the other destinations sent it.

    What should the archive record hold?

    The archive record should answer 'what did we receive, what did we send, and when' for one message without the engine running. Agnotic writes it as one addressable record per message.

    • Identity: server id, channel id and name, message id, and connector names.
    • Content: raw inbound payload, encoded outbound payload per destination, and attachments.
    • Status: final status per connector, received and processed timestamps, and any response a destination returned.
    • Archive metadata: batch id, archive timestamp, and a checksum so a later reader can confirm the record is unchanged.

    Keep the archive in a location with its own access controls and encryption, outside the Connect database. A copy that lives only on the engine host disappears with the host.

    How do you set retention per channel?

    Set retention per channel by the record the channel carries, not by one global number. The owner of that record type decides how long the archive keeps it; the engine settings only decide how soon the engine's own copy can go.

    Who sets what, per channel
    SettingDecided byNotes
    Engine content retentionIntegration ownerShort enough to keep the store small, long enough to reprocess recent messages
    Engine metadata retentionIntegration ownerKeeps the message list and status visible after content goes
    Archive retentionRecords or compliance ownerFollows the client's written records policy
    ExceptionsRecords owner, in writingFor example, a legal hold on one channel

    Agnotic does not pick durations for a client. We ask for the written policy and configure each channel to match it.

    What does archive before prune look like, step by step?

    Archive before prune is a fixed sequence: select, copy, verify, then delete. If verification fails, nothing is deleted.

    Archive before prune in Mirth Connect: completed messages are selected from the Connect message store, the archive job copies them with a checksum to a separate archive store, the batch count is verified, and a single pruner on one node deletes only the verified message ids, while the database backup sits apart as a whole-store restore image
    • Step 1, select: choose completed messages older than the channel's content retention, in a bounded batch.
    • Step 2, archive: write each message to the archive store with its checksum.
    • Step 3, verify: count archived records for the batch and compare with the selection count.
    • Step 4, prune: delete the engine's copy of exactly the verified message ids.
    • Step 5, record: log the batch id, counts and duration, and alert if any count differs.

    Connect's data pruner can archive before it deletes. Whether you use that or a separate job, the verify step is what keeps a failed archive from turning into data loss.

    What do the HIPAA Security Rule specifications say about backup and disposal?

    The HIPAA Security Rule lists backup and disposal as separate required specifications, which is why one cannot stand in for the other. Pruning is a disposal act; a backup is a recovery copy.

    45 CFR 164.308(a)(7)(ii)(A), the data backup plan specification, requires procedures to create and maintain retrievable exact copies of electronic protected health information.

    45 CFR 164.310(d)(2)(i) requires policies and procedures that address the final disposition of electronic protected health information and of the media it is stored on.

    Agnotic maps each to its own procedure: backups follow the disaster recovery plan, the archive follows the records policy, and pruning follows the disposal procedure with a log of what was removed. This is engineering practice, not legal advice; the client's compliance owner confirms the policy.

    A worked example: a results channel with years of content

    A worked example: a lab results channel had pruning switched off since it was built. Its message and content tables had grown large, and the database was slowing every channel on the server.

    The records owner confirmed that results are kept in the lab system and the EHR, and that the engine copy only needs to support recent reprocessing. The archive policy for the channel was written down before any deletion.

    Agnotic archived completed messages in batches outside clinic hours, verified each batch count, and pruned the matching ids. QUEUED and ERROR messages were listed for the integration owner, who resolved or reprocessed them before they became eligible.

    How do you roll out pruning on a store that is already large?

    Roll it out gradually: measure first, prune the oldest completed messages in small batches, and reclaim space only after the deletes finish. One large delete can lock tables that live channels need.

    • Measure: count messages by channel, status and age before changing anything.
    • Order: start with the oldest completed messages on the channel with the most rows.
    • Batch: keep each batch small enough that live traffic does not queue behind it.
    • Reclaim: run the space reclamation and index maintenance your database vendor documents, after pruning, not during it.

    Watch queue depth on live channels during each batch. If queues grow, pause and shrink the batch.

    How do you tell retention is working?

    Retention is working when the store size levels off, archive counts match prune counts for every batch, and no completed message older than its retention is still in the engine.

    • Size trend: database size stays flat week to week, or grows only when channels are added.
    • Batch parity: archived and pruned counts match on every run.
    • Open work age: the oldest QUEUED and ERROR messages are visible and owned, not hidden by pruning.
    • Pruner runs: one run per schedule, from one node, with a logged start and end.

    45 CFR 164.312(b) requires mechanisms that record and examine activity in systems that contain or use electronic protected health information.

    The pruner log and the archive batch records are part of that activity record. Keep them with the archive, not only on the engine host.

    What are the common mistakes when retention is added late?

    Late retention fails in predictable ways, mostly because teams treat pruning as cleanup instead of disposal.

    • Error rows pruned by age: open work disappears without anyone deciding on it.
    • Archive target full: the archive step fails and the prune runs anyway.
    • Content pruned with no archive: the message list shows rows nobody can open.
    • Reprocessing need: a downstream fix needs messages that were pruned and never archived.
    • Pruning at peak: deletes compete with live inserts on the same tables.

    What does retention mean for the build plan?

    Retention belongs in the first release of a Connect deployment, not after the database fills. Treat it as part of go-live, with the same review as the channels themselves.

    • Design: choose the storage level for each channel when the interface is designed, and write down why.
    • Archive target: provision the archive store and its access controls before the first production message.
    • Policy: get the written retention policy from the records owner and attach it to the go-live checklist.
    • Capacity: size the database for the engine retention window plus a margin for incident backlogs.

    Who owns retention decisions?

    The records owner decides how long the archive keeps each record type. The integration owner runs the engine side and clears open work. Engineering builds and monitors the jobs.

    • Records or compliance owner: archive retention, legal holds, and disposal approval.
    • Integration owner: engine retention per channel, and QUEUED and ERROR resolution.
    • Engineering: the archive job, the verify step, the pruner schedule, alerts, and the run log.
    • Database administrator: space reclamation and capacity planning.

    How does Agnotic run retention?

    Agnotic measures the store, agrees the written retention policy with the client's records owner, builds the archive and verify job, schedules one pruner, and adds the alerts that show batch parity and the age of open work.

    Archive, then prune, one node

    Completed messages out. Queued and error stay. Backup is not the archive.

    Related reading on Agnotic

    The HA pair, volume that fills the store, and recovering in-flight messages.

    Sources

    Frequently Asked Questions

    Not until an owner clears them. ERROR is work. Archive does not apply until the status is completed.

    Talk to an engineer about your project

    Tell us which statuses you still hold. We will archive completed rows, prune from one node, and leave queued and error messages for an owner.