# Store and Forward quarantine Violation of PRIMARY KEY constraint error

**URL:** <https://forum.inductiveautomation.com/t/store-and-forward-quarantine-violation-of-primary-key-constraint-error/101771>\
**Category:** Ignition\
**Created:** [February 3, 2025, 4:37pm UTC](https://forum.inductiveautomation.com/t/store-and-forward-quarantine-violation-of-primary-key-constraint-error/101771 "2025-02-03T16:37:52Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![josh\_willett](https://avatars.discourse-cdn.com/v4/letter/j/85f322/32.png) [@josh\_willett](https://forum.inductiveautomation.com/u/josh_willett)\
**Post date:** [February 3, 2025, 4:37pm UTC](https://forum.inductiveautomation.com/t/store-and-forward-quarantine-violation-of-primary-key-constraint-error/101771/1 "2025-02-03T16:37:52Z")

</div>

Hello Everyone,

I am currently getting an error in my Store and Forward on Ignition 8.1.36.  
Error  
Violation of PRIMARY KEY constraint 'PK\_\_sqlt\_dat\_\_BE126DD1EA310A01'. Cannot insert duplicate key in object 'dbo.sqlt\_data\_1\_2025\_01'. The duplicate key value is (6367, 1738359922827).

I am currently trying to correlate the tagID to a tag path so I can troubleshoot the offending tags.  
I am able to query the DB and get the relating info for the tag, but I cant seem to correlate the SQL tagID to a historian path in ignition.

Can anyone help with this? Running MSSQL. Currently I delete the quarantined records and they return shortly after.

---

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [February 3, 2025, 4:42pm UTC](https://forum.inductiveautomation.com/t/store-and-forward-quarantine-violation-of-primary-key-constraint-error/101771/2 "2025-02-03T16:42:48Z")

</div>

This doc shows the table references and should help you.

> **[Ignition Database Table Reference | Ignition User Manual](https://www.docs.inductiveautomation.com/docs/8.1/appendix/reference-pages/ignition-database-table-reference#tag-history)**
>
> Ignition has a lot of systems built-in that will query the database automatically without requiring you to build a query. These systems automatically create the necessary tables in the database, insert the relevant data, and even query it back out...

---

<div class="post-metadata">

**Author:** ![josh\_willett](https://avatars.discourse-cdn.com/v4/letter/j/85f322/32.png) [@josh\_willett](https://forum.inductiveautomation.com/u/josh_willett)\
**Post date:** [February 3, 2025, 4:46pm UTC](https://forum.inductiveautomation.com/t/store-and-forward-quarantine-violation-of-primary-key-constraint-error/101771/3 "2025-02-03T16:46:51Z")

</div>

Thank you! This is exactly what I was looking for.

---

<div class="post-metadata">

**Author:** ![Ha99](https://avatars.discourse-cdn.com/v4/letter/h/7feea3/32.png) [@Ha99](https://forum.inductiveautomation.com/u/Ha99)\
**Post date:** [February 11, 2025, 1:17pm UTC](https://forum.inductiveautomation.com/t/store-and-forward-quarantine-violation-of-primary-key-constraint-error/101771/4 "2025-02-11T13:17:22Z")

</div>

Hi,  
Have you found a solution, I am in the same situation ?

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [February 11, 2025, 1:27pm UTC](https://forum.inductiveautomation.com/t/store-and-forward-quarantine-violation-of-primary-key-constraint-error/101771/5 "2025-02-11T13:27:38Z")

</div>

What's your issue exactly, and what do you hope to do about it ?

---

<div class="post-metadata">

**Author:** ![Ha99](https://avatars.discourse-cdn.com/v4/letter/h/7feea3/32.png) [@Ha99](https://forum.inductiveautomation.com/u/Ha99)\
**Post date:** [February 11, 2025, 1:32pm UTC](https://forum.inductiveautomation.com/t/store-and-forward-quarantine-violation-of-primary-key-constraint-error/101771/6 "2025-02-11T13:32:43Z")

</div>

I have de same probleme, I have this error **java.sql.BatchUpdateException: Violation of PRIMARY KEY constraint 'PK\_\_sqlt\_dat** , The tags that cause problems are the opc tag, collected via a KEPServerEX.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [February 11, 2025, 1:35pm UTC](https://forum.inductiveautomation.com/t/store-and-forward-quarantine-violation-of-primary-key-constraint-error/101771/7 "2025-02-11T13:35:06Z")

</div>

The duplicate key will not magically go away. Use the S&F retry to make sure anything that can succeed in a batch does so, then discard anything left.

(There is a longstanding race condition that can cause this on connection breakage/re-establishment, and the resulting duplicates have to be discarded.)

---

<div class="post-metadata">

**Author:** ![Chris\_Bingham](https://avatars.discourse-cdn.com/v4/letter/c/e5b9ba/32.png) [@Chris\_Bingham](https://forum.inductiveautomation.com/u/Chris_Bingham)\
**Post date:** [February 11, 2025, 1:37pm UTC](https://forum.inductiveautomation.com/t/store-and-forward-quarantine-violation-of-primary-key-constraint-error/101771/8 "2025-02-11T13:37:14Z")

</div>

I’ve seen this happen regularly in cases of intermittent comms between Ignition gateways. A remote (Edge?) gateway is able to send records to the Historian, but the receipt confirmation does not make it back to the remote gateway, so it sends the data again. Luckily, primary key constraint prevents duplicate entries in the DB.

---

<div class="post-metadata">

**Author:** ![Ha99](https://avatars.discourse-cdn.com/v4/letter/h/7feea3/32.png) [@Ha99](https://forum.inductiveautomation.com/u/Ha99)\
**Post date:** [February 11, 2025, 1:38pm UTC](https://forum.inductiveautomation.com/t/store-and-forward-quarantine-violation-of-primary-key-constraint-error/101771/9 "2025-02-11T13:38:21Z")

</div>

I already tried that, but there are new values ​​that appear after a while.

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [February 11, 2025, 1:39pm UTC](https://forum.inductiveautomation.com/t/store-and-forward-quarantine-violation-of-primary-key-constraint-error/101771/10 "2025-02-11T13:39:48Z")

</div>

This error means that something is trying to insert duplicate records into the historian: There's already a record for that combination of tagid/timestamp.

Now, what do you want us to help you with ?  
Finding where the duplicates come from ?  
Getting rid of them ?

---

<div class="post-metadata">

**Author:** ![Ha99](https://avatars.discourse-cdn.com/v4/letter/h/7feea3/32.png) [@Ha99](https://forum.inductiveautomation.com/u/Ha99)\
**Post date:** [February 11, 2025, 1:53pm UTC](https://forum.inductiveautomation.com/t/store-and-forward-quarantine-violation-of-primary-key-constraint-error/101771/11 "2025-02-11T13:53:24Z")

</div>

Find where the error is coming from.  
The tags that cause problems are the opc tag, collected via a KEPServerEX.  
The database, it's in another machine.  
The history is not manual, there is no script or another part for historization.

---

<div class="post-metadata">

**Author:** ![josh\_willett](https://avatars.discourse-cdn.com/v4/letter/j/85f322/32.png) [@josh\_willett](https://forum.inductiveautomation.com/u/josh_willett)\
**Post date:** [February 11, 2025, 1:53pm UTC](https://forum.inductiveautomation.com/t/store-and-forward-quarantine-violation-of-primary-key-constraint-error/101771/12 "2025-02-11T13:53:55Z")

</div>

So ultimately I believe the errors I was receiving were caused by the race condition that pturmel was describing. I have done two things to resolve the problem and it has not yet re-occurred.  
First was to improve the reliability of one of my OPC servers KepServerEX. I had some ongoing network and licensing issues with it that were causing instability. This was likely the actual fix, as when the instable KepServer would come back online it would produce the issue.  
I also used the following SQL query to look up the offending tag in the database.  
SELECT \* from sqlth\_te  
WHERE id=;  
Be careful with the SQL query if you haven't done it before.  
Once I found the offending tag I verified it's configuration and I also renamed it so that it would start new history on that tag.

---

<div class="post-metadata">

**Author:** ![Ha99](https://avatars.discourse-cdn.com/v4/letter/h/7feea3/32.png) [@Ha99](https://forum.inductiveautomation.com/u/Ha99)\
**Post date:** [February 11, 2025, 2:00pm UTC](https://forum.inductiveautomation.com/t/store-and-forward-quarantine-violation-of-primary-key-constraint-error/101771/13 "2025-02-11T14:00:07Z")

</div>

I can't rename the tags, however I think I have the same behavior with kep as I don't have KEP license in dev environment, on the other hand in production I have the same behavior but I have the kep license.

---

<div class="post-metadata">

**Author:** ![josh\_willett](https://avatars.discourse-cdn.com/v4/letter/j/85f322/32.png) [@josh\_willett](https://forum.inductiveautomation.com/u/josh_willett)\
**Post date:** [February 11, 2025, 2:07pm UTC](https://forum.inductiveautomation.com/t/store-and-forward-quarantine-violation-of-primary-key-constraint-error/101771/14 "2025-02-11T14:07:19Z")

</div>

pturmel Just to confirm something I got from one of your previous posts.  
If I have a failed batch in store and forward and maybe there is only one duplicate ID in the batch it will fail the entire batch. This may include tags that do not have duplicates. But if I use the retry feature it will insert all of the tags that it can without duplicates and leave only the tags that have duplicate conflicts? I noticed this issue because it was affecting other tags in the provider that did not have conflicts. It seems they were getting caught up in the failed S&F batch.

---

<div class="post-metadata">

**Author:** ![josh\_willett](https://avatars.discourse-cdn.com/v4/letter/j/85f322/32.png) [@josh\_willett](https://forum.inductiveautomation.com/u/josh_willett)\
**Post date:** [February 11, 2025, 2:30pm UTC](https://forum.inductiveautomation.com/t/store-and-forward-quarantine-violation-of-primary-key-constraint-error/101771/15 "2025-02-11T14:30:32Z")

</div>

Ha99 I would recommend that you use the SQL query I shared to determine which tag is causing you problems.  
SELECT \* from sqlth\_te  
WHERE id=(First set of numbers from the error);  
Verify that this tags configuration is good, then right click on the tag and restart history. Once you have verified it, you will need to go to the store and forward page. Retry the quarantined batch, and then delete what remains.  
The query can either be done through the named queries section in your designer or through whatever SQL management tool you have. Note this query is designed for MSSQL. It may be different if you are using a different DB.

---

<div class="post-metadata">

**Author:** ![Ha99](https://avatars.discourse-cdn.com/v4/letter/h/7feea3/32.png) [@Ha99](https://forum.inductiveautomation.com/u/Ha99)\
**Post date:** [February 11, 2025, 3:04pm UTC](https://forum.inductiveautomation.com/t/store-and-forward-quarantine-violation-of-primary-key-constraint-error/101771/16 "2025-02-11T15:04:42Z")

</div>

Here is my tag history configuration:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/d/4d84e2ee8996c1ac4d54d26e33c7cc35f6f68062.png)  
I check the id in the sqlth\_te, I delete any record from the sql sqlt\_data\_ table using the xml export file using a specific script, I try again and it's ok, but after 2 hours or more I have other errors

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [February 11, 2025, 5:10pm UTC](https://forum.inductiveautomation.com/t/store-and-forward-quarantine-violation-of-primary-key-constraint-error/101771/17 "2025-02-11T17:10:48Z")

</div>

> [@josh\_willett](#):
>
> If I have a failed batch in store and forward and maybe there is only one duplicate ID in the batch it will fail the entire batch

Hmmm. That hasn't been my experience, but I may have missed that. Not sure.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [February 11, 2025, 5:24pm UTC](https://forum.inductiveautomation.com/t/store-and-forward-quarantine-violation-of-primary-key-constraint-error/101771/18 "2025-02-11T17:24:50Z")

</div>

I'm pretty sure the "one part of batch failed, the whole batch goes to quarantine" thing was a bug that we fixed at some point in the 8.1.x lifecycle, but I'm not up to date on all things historian.

---

<div class="post-metadata">

**Author:** ![josh\_willett](https://avatars.discourse-cdn.com/v4/letter/j/85f322/32.png) [@josh\_willett](https://forum.inductiveautomation.com/u/josh_willett)\
**Post date:** [February 11, 2025, 5:29pm UTC](https://forum.inductiveautomation.com/t/store-and-forward-quarantine-violation-of-primary-key-constraint-error/101771/19 "2025-02-11T17:29:21Z")

</div>

Thanks, I just want to understand how the store and forward quarantine works. I have some Kepservers that will always have an unstable connection as they are part of mobile machinery and are often disconnected and powered off and on. Currently running 8.1.36 but plan on upgrading to the latest stable branch in the next few months.

---

<div class="post-metadata">

**Author:** ![Ha99](https://avatars.discourse-cdn.com/v4/letter/h/7feea3/32.png) [@Ha99](https://forum.inductiveautomation.com/u/Ha99)\
**Post date:** [February 12, 2025, 7:42am UTC](https://forum.inductiveautomation.com/t/store-and-forward-quarantine-violation-of-primary-key-constraint-error/101771/20 "2025-02-12T07:42:46Z")

</div>

I work with the same version 8.1.36, so you suggest to upgrade to 8.1.45
