Close db connection immediately after calling a complex procedure cause db rollback
Pandaaaa906 opened this issue · 1 comments
Pandaaaa906 commented
Software versions
- Django: 4.1.13
- mssql-django: 1.4.2
- python: 3.12.3
- SQL Server: 2008
- OS: ubuntu 22/docker
close db connection just after executing a "no return" procedure with long run time ( ~3s, aggregating data and update the summary table), will cause procedure rollback
Failed
conn = connections[...]
with conn.cursor() as cursor:
cursor.execute("exec LongTimeProcedure")
conn.close() # auto call by celery, can't remove
Success
conn = connections[...]
with conn.cursor() as cursor:
cursor.execute("exec LongTimeProcedure")
sleep(5)
conn.close()
mShan0 commented
Hi @Pandaaaa906, I believe this is expected behaviour. If the connection is closed before a procedure is finished, it should roll back to maintain data integrity.