# Error storing tag values

**URL:** <https://forum.inductiveautomation.com/t/error-storing-tag-values/6219>\
**Category:** Ignition\
**Created:** [April 12, 2013, 8:51pm UTC](https://forum.inductiveautomation.com/t/error-storing-tag-values/6219 "2013-04-12T20:51:17Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![jmonter](https://avatars.discourse-cdn.com/v4/letter/j/858c86/32.png) [@jmonter](https://forum.inductiveautomation.com/u/jmonter)\
**Post date:** [April 12, 2013, 8:51pm UTC](https://forum.inductiveautomation.com/t/error-storing-tag-values/6219/1 "2013-04-12T20:51:17Z")

</div>

I been getting an intermedia message but don’t know what it actually means, can someone help?

1:45:00 PM  
TagStore  
Error storing tag values.  
java.sql.BatchUpdateException: Deadlock found when trying to get lock; try restarting transaction  
at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:1237)  
at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:936)  
at org.apache.commons.dbcp.DelegatingStatement.executeBatch(DelegatingStatement.java:297)  
at com.inductiveautomation.ignition.gateway.datasource.DelegatingStatement.executeBatch(DelegatingStatement.java:59)  
at com.inductiveautomation.ignition.gateway.datasource.SRConnectionWrapper$SRStatement.executeBatch(SRConnectionWrapper.java:629)  
at com.inductiveautomation.ignition.gateway.sqltags.providers.datasource.tagstore.DBTagStore$BatchStatement.finish(DBTagStore.java:3155)  
at com.inductiveautomation.ignition.gateway.sqltags.providers.datasource.tagstore.DBTagStore.internalStoreTagValues(DBTagStore.java:1380)  
at com.inductiveautomation.ignition.gateway.sqltags.providers.datasource.tagstore.DBTagStore.storeTagValues(DBTagStore.java:1257)  
at com.inductiveautomation.ignition.gateway.sqltags.providers.AbstractStoreBasedTagProvider.tagValuesChanged(AbstractStoreBasedTagProvider.java:1918)  
at com.inductiveautomation.ignition.gateway.sqltags.scanclasses.SimpleExecutableScanClass$ScanClassTagEvaluationContext.processAndReset(SimpleExecutableScanClass.java:1122)  
at com.inductiveautomation.ignition.gateway.sqltags.scanclasses.SimpleExecutableScanClass.run(SimpleExecutableScanClass.java:863)  
at com.inductiveautomation.ignition.common.execution.impl.BasicExecutionEngine$TrackedTask.run(BasicExecutionEngine.java:573)  
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)  
at java.util.concurrent.FutureTask$Sync.innerRunAndReset(Unknown Source)  
at java.util.concurrent.FutureTask.runAndReset(Unknown Source)  
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(Unknown Source)  
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(Unknown Source)  
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)  
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)  
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)  
at java.lang.Thread.run(Unknown Source)

---

<div class="post-metadata">

**Author:** ![greg.simpson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/greg.simpson/32/3135_2.png) [@greg.simpson](https://forum.inductiveautomation.com/u/greg.simpson)\
**Post date:** [April 15, 2013, 10:06pm UTC](https://forum.inductiveautomation.com/t/error-storing-tag-values/6219/2 "2013-04-15T22:06:44Z")

</div>

You have a deadlock. What version of Ignition are you using?

---

<div class="post-metadata">

**Author:** ![jmonter](https://avatars.discourse-cdn.com/v4/letter/j/858c86/32.png) [@jmonter](https://forum.inductiveautomation.com/u/jmonter)\
**Post date:** [April 19, 2013, 2:54am UTC](https://forum.inductiveautomation.com/t/error-storing-tag-values/6219/3 "2013-04-19T02:54:37Z")

</div>

Windows 7 64bit  
Ignition Version 7.5.6 (b1317)  
Java Version 6 Update 31  
MySQL 5.5 64bit

What does a deadlock mean?

---

<div class="post-metadata">

**Author:** ![Robert](https://avatars.discourse-cdn.com/v4/letter/r/e95f7d/32.png) [@Robert](https://forum.inductiveautomation.com/u/Robert)\
**Post date:** [April 19, 2013, 9:01pm UTC](https://forum.inductiveautomation.com/t/error-storing-tag-values/6219/4 "2013-04-19T21:01:22Z")

</div>

> [@jmonter](#):
>
> What does a deadlock mean?

It's when process A requests something from process B and waits for a answer before continuing. Meanwhile, process B asks process A for something and waits for process A to answer before continuing.

For a longer definition see [here](http://en.wikipedia.org/wiki/Deadlock).

---

<div class="post-metadata">

**Author:** ![Colby.Clegg](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/colby.clegg/32/3282_2.png) [@Colby.Clegg](https://forum.inductiveautomation.com/u/Colby.Clegg)\
**Post date:** [April 19, 2013, 11:17pm UTC](https://forum.inductiveautomation.com/t/error-storing-tag-values/6219/5 "2013-04-19T23:17:51Z")

</div>

Hi,

In this case we should clarify things a bit. You’re running into database deadlock detection, which is quite a bit different than if you were to run into a real deadlock in Ignition.

Basically, in cases like this, it tends to go along the lines of one part of the system trying to read the data of the table at the same time that another part is writing. When one of those operations is taking a long time, the database may say that it’s a “deadlock”, and will throw the exception to break the wait.

Since the error indicates that it’s trying to update tag values, my guess is that you probably have many tags in the external provider, and that perhaps every once in a while (and certainly on startup) many of them are changing and need to be written. The write could take some time, and at the same time, the system is trying to poll for changes.

How many tags do you have? If you go to Status\>Database connections, and turn on “enable live values”, do you see some queries lingering for seconds? If so, how long do they normally last? Can you stop the “live values” and copy them in here?

Ultimately, the goal would be to reduce the contention by speeding up the database (through various means), or reducing the number of writes, or the poll frequency.

Has this always done this, or did it just start?

Regards,

---

<div class="post-metadata">

**Author:** ![jmonter](https://avatars.discourse-cdn.com/v4/letter/j/858c86/32.png) [@jmonter](https://forum.inductiveautomation.com/u/jmonter)\
**Post date:** [April 22, 2013, 9:00pm UTC](https://forum.inductiveautomation.com/t/error-storing-tag-values/6219/6 "2013-04-22T21:00:07Z")

</div>

[quote=“Colby.Clegg”]Hi,

In this case we should clarify things a bit. You’re running into database deadlock detection, which is quite a bit different than if you were to run into a real deadlock in Ignition.

Basically, in cases like this, it tends to go along the lines of one part of the system trying to read the data of the table at the same time that another part is writing. When one of those operations is taking a long time, the database may say that it’s a “deadlock”, and will throw the exception to break the wait.

Since the error indicates that it’s trying to update tag values, my guess is that you probably have many tags in the external provider, and that perhaps every once in a while (and certainly on startup) many of them are changing and need to be written. The write could take some time, and at the same time, the system is trying to poll for changes.

How many tags do you have? If you go to Status\>Database connections, and turn on “enable live values”, do you see some queries lingering for seconds? If so, how long do they normally last? Can you stop the “live values” and copy them in here?

Ultimately, the goal would be to reduce the contention by speeding up the database (through various means), or reducing the number of writes, or the poll frequency.

Has this always done this, or did it just start?

Regards,[/quote]

I only have 717 Tags, with two scan rates. Default 1sec, Fast 250ms. Why so fast you might ask, well I have to scan a barcode and do a query and return the value back to the PLC in a very short time.  
The Fast Rate only has 17 Tags.

Originally I had set the Realtime SQLTags to be Database Driving since than I changed it to Internal Provider and I haven’t had the issues described before.

---

<div class="post-metadata">

**Author:** ![Colby.Clegg](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/colby.clegg/32/3282_2.png) [@Colby.Clegg](https://forum.inductiveautomation.com/u/Colby.Clegg)\
**Post date:** [April 22, 2013, 9:42pm UTC](https://forum.inductiveautomation.com/t/error-storing-tag-values/6219/7 "2013-04-22T21:42:00Z")

</div>

Hi,

The rates are OK, the question would probably be “how many values are changing each cycle”? Adjusting the tag deadbands could help.

However, if I understand, you’re now using the internal provider, so this is no longer an issue… right? (the internal provider doesn’t run into this issue, because it doesn’t have to store so many values)

Regards,

---

<div class="post-metadata">

**Author:** ![jmonter](https://avatars.discourse-cdn.com/v4/letter/j/858c86/32.png) [@jmonter](https://forum.inductiveautomation.com/u/jmonter)\
**Post date:** [April 23, 2013, 9:01pm UTC](https://forum.inductiveautomation.com/t/error-storing-tag-values/6219/8 "2013-04-23T21:01:30Z")

</div>

[quote=“Colby.Clegg”]Hi,

The rates are OK, the question would probably be “how many values are changing each cycle”? Adjusting the tag deadbands could help.

However, if I understand, you’re now using the internal provider, so this is no longer an issue… right? (the internal provider doesn’t run into this issue, because it doesn’t have to store so many values)

Regards,[/quote]

That is correct I’m using the internal provider.
