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

autocommit not wrapped #2

Open
diegobill opened this issue Nov 25, 2020 · 4 comments
Open

autocommit not wrapped #2

diegobill opened this issue Nov 25, 2020 · 4 comments

Comments

@diegobill
Copy link

This library is not handling "mysql server has gone away" exceptions when autocommit is executed so I am receiving the error below when I execute any django orm query, for example "TicketSold.objects.filter(tapos_performance_code__in=perfs).delete()":

on_deleted error: Traceback (most recent call last):
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\backends\mysql\base.py", line 257, in _set_autocommit
    self.connection.autocommit(autocommit)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\MySQLdb\connections.py", line 211, in autocommit
    _mysql.connection.autocommit(self, on)
MySQLdb._exceptions.OperationalError: (2006, 'MySQL server has gone away')

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\Administrator\Desktop\sensible-sync\utils.py", line 12, in wrapper
    return func(*args, **kwargs)
  File "C:\Users\Administrator\Desktop\sensible-sync\FileStream.py", line 45, in on_deleted
    self.handle_deleted(event)
  File "C:\Users\Administrator\Desktop\sensible-sync\sync\lib\SensiblePlaydate2TaposStream.py", line 120, in handle_deleted
    TicketSold.objects.filter(tapos_performance_code__in=perfs).delete()
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\models\query.py", line 711, in delete
    deleted, _rows_count = collector.delete()
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\models\deletion.py", line 284, in delete
    with transaction.atomic(using=self.using, savepoint=False):
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\transaction.py", line 201, in __enter__
    connection.set_autocommit(False, force_begin_transaction_with_broken_autocommit=True)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\backends\base\base.py", line 405, in set_autocommit
    self._set_autocommit(autocommit)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\backends\mysql\base.py", line 257, in _set_autocommit
    self.connection.autocommit(autocommit)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\utils.py", line 89, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\backends\mysql\base.py", line 257, in _set_autocommit
    self.connection.autocommit(autocommit)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\MySQLdb\connections.py", line 211, in autocommit
    _mysql.connection.autocommit(self, on)
django.db.utils.OperationalError: (2006, 'MySQL server has gone away')

how can I wrap autocommit too?

@akoidan
Copy link
Owner

akoidan commented Nov 25, 2020

@diegobill this is weird, I'm using autocommit true and it works.

  • Which version of django are you using?
  • Do you use atomic transaction decorator under multiple queries?

Can you collaborate with PR? I would be happy to merge it.

@diegobill
Copy link
Author

@akoidan , I am using django 2.2.6

@diegobill
Copy link
Author

I am not using atomic transaction decorator

@akoidan
Copy link
Owner

akoidan commented Nov 25, 2020

Roger that @diegobill

I will check this tomorrow if I have time.

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