SQL Server question, transactions remaining open

55 views
Skip to first unread message

Jason Solack

unread,
Jun 28, 2016, 12:36:02 PM6/28/16
to web2py-users
Hello all, i am running an app that utilizes the scheduler and i'm seeing a lot of open transaction in SQL server with the last sql command being:

IF @@TRANCOUNT > 0 COMMIT BEGIN TRANSACTION

any idea where those are being generated and how to close those transactions?

Thank you

Jason

Niphlod

unread,
Jun 28, 2016, 3:22:42 PM6/28/16
to web2py-users
are you explicitely calling db.commit() at the end of your taks ?

Jason Solack

unread,
Jun 29, 2016, 8:57:37 AM6/29/16
to web2py-users
I am, i am passing db into some modules, do i need to be explicit about db.commit within modules?

Niphlod

unread,
Jun 29, 2016, 2:59:23 PM6/29/16
to web2py-users
you need to be explicit everywhere if you are not in a web request environment. 

Dave S

unread,
Jun 29, 2016, 5:53:36 PM6/29/16
to web2py-users


On Wednesday, June 29, 2016 at 11:59:23 AM UTC-7, Niphlod wrote:
you need to be explicit everywhere if you are not in a web request environment. 

On Wednesday, June 29, 2016 at 2:57:37 PM UTC+2, Jason Solack wrote:
I am, i am passing db into some modules, do i need to be explicit about db.commit within modules?

It may be enough, though, to do the commit in the task's top-level procedure (what you queue for the scheduler), when you've returned from the calls into the modules.  That would depend in part on whether rolling back a single transaction is adequate, or whether you need several transactions to capture progress along the task.

(My scheduler job isn't an example -- it's read-only on the db -- but the functions to handle starting and stopping the scheduling, and adding a "manual" run to the schedule (that is, running the task an extra time to handle something between periodic runs) are done with functions in controller/default.py using the -S switch, and each of those does a db.commit so that the scheduler sees the changes.)

/dps


 

Jason Solack

unread,
Jun 30, 2016, 10:39:59 AM6/30/16
to web2py-users
Thank you for the replies!  I am going to try being more explicit and see if that cleans things up
Reply all
Reply to author
Forward
0 new messages