# \[IGN-3829\] Error executing system.db.commitTransaction

**URL:** <https://forum.inductiveautomation.com/t/ign-3829-error-executing-system-db-committransaction/49595>\
**Category:** Ignition\
**Created:** [August 5, 2021, 1:47pm UTC](https://forum.inductiveautomation.com/t/ign-3829-error-executing-system-db-committransaction/49595 "2021-08-05T13:47:50Z")\
**Posts on this page:** 9\
**Page:** 2

<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:** [July 10, 2023, 2:58pm UTC](https://forum.inductiveautomation.com/t/ign-3829-error-executing-system-db-committransaction/49595/21 "2023-07-10T14:58:44Z")

</div>

I'm not sure what driver the prod server in running, I'll check it out and make mine match - Probably should have done that long ago.

I doubt they'll allow a driver update on prod.

---

<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:** [July 10, 2023, 3:11pm UTC](https://forum.inductiveautomation.com/t/ign-3829-error-executing-system-db-committransaction/49595/22 "2023-07-10T15:11:07Z")

</div>

Actually I'm a bit confused.  
I said 4.2 because of this:

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/8/08f56e2748b057dc739bd98ddc61a1ad1cd87998.png)

But looking in `ignition/user-lib/jdbc`, I find `mssql-jdbc-9.4.0.jre11.jar`, so I guess it's 9.4 after all ?

Could upgrading the JDBC change anything about my issue ?

---

<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:** [July 10, 2023, 3:12pm UTC](https://forum.inductiveautomation.com/t/ign-3829-error-executing-system-db-committransaction/49595/23 "2023-07-10T15:12:05Z")

</div>

4.2 is the version of the JDBC specification the driver supports.  
9.4.0 is _most likely_ the version of the driver, but a filename is not a guarantee that's actually the version you have.

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [July 10, 2023, 3:27pm UTC](https://forum.inductiveautomation.com/t/ign-3829-error-executing-system-db-committransaction/49595/24 "2023-07-10T15:27:19Z")

</div>

I think you need to `return ret` after closing transaction, not after committing. Seems like for a set of good queries without error, you commit the transaction but then return the result of your function, and I don't think your `closeTransaction` in your finally ever executes. I don't think that's necessarily your issue here, but I think it could become one.

---

<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:** [July 10, 2023, 3:30pm UTC](https://forum.inductiveautomation.com/t/ign-3829-error-executing-system-db-committransaction/49595/25 "2023-07-10T15:30:31Z")

</div>

> [@bkarabinchak.psi](#):
>
> don't think your `closeTransaction` in your finally ever executes

The whole point of a `finally:` clause is to **ensure** it executes no matter what goes on in the `try:` block. So, no, that isn't it.

---

<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:** [July 10, 2023, 3:31pm UTC](https://forum.inductiveautomation.com/t/ign-3829-error-executing-system-db-committransaction/49595/26 "2023-07-10T15:31:18Z")

</div>

The `close` call is in a `finally`, it will be called whether the function reaches a return or not.

---

<div class="post-metadata">

**Author:** ![ryan.white](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.white/32/73193_2.png) [@ryan.white](https://forum.inductiveautomation.com/u/ryan.white)\
**Post date:** [July 10, 2023, 6:21pm UTC](https://forum.inductiveautomation.com/t/ign-3829-error-executing-system-db-committransaction/49595/27 "2023-07-10T18:21:15Z")

</div>

I had a similar problem when I was trying to set up an all or nothing write to our DB. What fixed it for me was the first query in the transaction (after getting the transaction ID) needed to have the project argument filled. Subsequent named query calls do not need that parameter filled.

This worked:

```auto
txID = system.db.beginNamedQueryTransaction(project="project1", database="database1")
try:
    system.db.runNamedQuery(project="project1", path="query1", params=params1, tx=txID)
    #do some stuff

    system.db.runNamedQuery(path="query2", params=params2, tx=txID)
    # do more stuff
    system.db.commitTransaction(txID)

except:
    system.db.rollbackTransaction(txID)

finally:
    system.db.closeTransaction(txID)

```

but this would not work, for whatever reason:

```auto
txID = system.db.beginNamedQueryTransaction(project="project1", database="database1")

try:
    system.db.runNamedQuery(path="query1", params=params1, tx=txID)
    #do some stuff

    system.db.runNamedQuery(path="query2", params=params2, tx=txID)
    # do more stuff
    system.db.commitTransaction(txID)

except:
    system.db.rollbackTransaction(txID)

finally:
    system.db.closeTransaction(txID)

```

---

<div class="post-metadata">

**Author:** ![richardNZ15](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/richardnz15/32/33373_2.png) [@richardNZ15](https://forum.inductiveautomation.com/u/richardNZ15)\
**Post date:** [March 21, 2024, 6:33am UTC](https://forum.inductiveautomation.com/t/ign-3829-error-executing-system-db-committransaction/49595/28 "2024-03-21T06:33:16Z")

</div>

Is this STILL a bug???  
I'm on 8.1.37 and getting apparently similar behaviour.

I CAN'T add project argument as mentioned above, because as far as I can tell if its not called by gateway scope it won't like that..  
Which is why i have this sort of thing everywhere:

```auto
	# system.db.runNamedQuery requires project name if called from Gateway Scope. 
	scope = shared.util.getScope()	# 0 = Gateway scope, > 0 = Client scope	

	if scope > 0:
		txId = system.db.beginNamedQueryTransaction(iolistDB, isolationLevel, timeout)
	else:
		txId = system.db.beginNamedQueryTransaction("G1-Master", iolistDB, isolationLevel, timeout)

```

I am also finding that the INSERT queries are in fact being committed, and i can see the new rows show up in the database, but i still get the following error:

> 19:31:31.892 [Thread-76] ERROR Tamaki IO Checking - updateIOCheck\_new - caused by: com.inductiveautomation.ignition.client.gateway\_interface.GatewayException: Transaction "331efe66-a98f-4c72-a617-d41ba830c214" is closed.  
> caused by: java.sql.SQLException: Transaction "331efe66-a98f-4c72-a617-d41ba830c214" is closed.  
> 19:31:31.906 [Thread-76] ERROR ScriptLogger - updateIOCheck\_new - caused by: com.inductiveautomation.ignition.client.gateway\_interface.GatewayException: Transaction "331efe66-a98f-4c72-a617-d41ba830c214" is closed.  
> caused by: java.sql.SQLException: Transaction "331efe66-a98f-4c72-a617-d41ba830c214" is closed.  
> Error: updateIOCheck\_new - caused by: com.inductiveautomation.ignition.client.gateway\_interface.GatewayException: Transaction "331efe66-a98f-4c72-a617-d41ba830c214" is closed.  
> caused by: java.sql.SQLException: Transaction "331efe66-a98f-4c72-a617-d41ba830c214" is closed.

Pretty frustrating. Going to go home before and sleep on it. Hopefully someone can pitch in if they've managed to find a fix in the last year.

---

<div class="post-metadata">

**Author:** ![Brandon\_Peterson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/brandon_peterson/32/32960_2.png) [@Brandon\_Peterson](https://forum.inductiveautomation.com/u/Brandon_Peterson)\
**Post date:** [May 8, 2024, 9:22pm UTC](https://forum.inductiveautomation.com/t/ign-3829-error-executing-system-db-committransaction/49595/29 "2024-05-08T21:22:24Z")

</div>

Just wanted to post some good news to this thread in case anyone hasn't seen it yet. Looks like this issue will be solved in Ignition 8.1.40!

> [@Nightly 8.1 Changelogs - 2024](https://forum.inductiveautomation.com/t/nightly-8-1-changelogs-2024/83608/74):
>
> Nightly Changelog: 8.1.40-SNAPSHOT-b20240425 Tag Historian Store & Forward IGN-3829: Queued transactions via beginNamedQueryTransaction() are not gracefully dequeued when not used Fixed an issue where committing or rolling back a transaction id obtained from system.db.beginNamedQueryTransaction() without running any prior queries would cause an exception to be thrown.

[Previous page](https://forum.inductiveautomation.com/t/ign-3829-error-executing-system-db-committransaction/49595.md?page=1)
