Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Close db connection immediately after calling a complex procedure cause db rollback #401

Open
Pandaaaa906 opened this issue Jun 14, 2024 · 1 comment

Comments

@Pandaaaa906
Copy link

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
Copy link
Contributor

mShan0 commented Jun 14, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants