michiya / django-pyodbc-azure

Django backend for Microsoft SQL Server and Azure SQL Database using pyodbc
https://pypi.python.org/pypi/django-pyodbc-azure
BSD 3-Clause "New" or "Revised" License
321 stars 140 forks source link

Segmentation fault with Sql Server #200

Closed CaptainDriftwood closed 5 years ago

CaptainDriftwood commented 5 years ago

I keep getting a segmentation fault when trying to query Sql Server with Python 3.4.5, Django 2.0.13 (or newer), pyodbc 4.0.25, and django-pyodbc-azure 2.0.8 (the latest version that supports Django 2.0.13).

On my local machine using Python 3.5 (on Windows using Microsoft's Sql Server drivers) and both the latest version of Django and latest version of django-pyodbc-azure (2.1.0), everything works fine.

I am also using Microsoft official linux driver for Sql Server, ODBC Driver 13 for Sql Server.

The error is coming from multiple threaded connections. The program fails at line 307 in base.py when trying to instantiate a new database connection from Database.connect()

while conn is None: try: conn = Database.connect(connstr, unicode_results=unicode_results, timeout=timeout) <------------- Right here is where the code fails. except Exception as e: for error_number in self._transient_error_numbers: if error_number in e.args[1]: if error_number in e.args[1] and retry_count < retries: time.sleep(backoff_time) need_to_retry = True retry_count = retry_count + 1 else: need_to_retry = False break if not need_to_retry: raise

CaptainDriftwood commented 5 years ago

Turns out this is an issue with Microsoft's Sql Server driver and my distribution of Linux.