Я использую python3.5.2, django == 1.11, ubuntu16.04, AWS RDS, MSSQL сервер 17, UNIXODBC == 3.2.1, FREETDS (freetds v0.91, версия TDS: 4.2)
В моих настройках django:
os.environ['TDSVER'] = '8.0'
DATABASES = {
'default': {
'ENGINE': 'sql_server.pyodbc',
'HOST': 'host_name',
'PORT': '1433',
'NAME': 'test',
'USER': 'test',
'PASSWORD': 'test',
'AUTOCOMMIT': True,
'OPTIONS': {
'host_is_server': True,
},
}
}
Ошибка:
Internal Server Error: /dashboard
Traceback (most recent call last):
File "/home/qmcpl/projects/eddie/env_newmodel/lib/python3.5/site-packages/django/contrib/sessions/backends/base.py", line 202, in _get_session
return self._session_cache
AttributeError: 'SessionStore' object has no attribute '_session_cache'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/qmcpl/projects/eddie/env_newmodel/lib/python3.5/site-packages/django/db/backends/base/base.py", line 213, in ensure_connection
self.connect()
File "/home/qmcpl/projects/eddie/env_newmodel/lib/python3.5/site-packages/django/db/backends/base/base.py", line 189, in connect
self.connection = self.get_new_connection(conn_params)
File "/home/qmcpl/projects/eddie/env_newmodel/lib/python3.5/site-packages/sql_server/pyodbc/base.py", line 309, in get_new_connection
timeout=timeout)
pyodbc.OperationalError: ('08001', '[08001] [unixODBC][FreeTDS][SQL Server]Unable to connect to data source (0) (SQLDriverConnect)')
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/qmcpl/projects/eddie/env_newmodel/lib/python3.5/site-packages/django/core/handlers/exception.py", line 41, in inner
response = get_response(request)
File "/home/qmcpl/projects/eddie/env_newmodel/lib/python3.5/site-packages/django/core/handlers/base.py", line 187, in _get_response
return get_user_model()._meta.pk.to_python(request.session[SESSION_KEY])
File "/home/qmcpl/projects/eddie/env_newmodel/lib/python3.5/site-packages/django/contrib/sessions/backends/base.py", line 57, in __getitem__
return self._session[key]
File "/home/qmcpl/projects/eddie/env_newmodel/lib/python3.5/site-packages/django/contrib/sessions/backends/base.py", line 207, in _get_session
self._session_cache = self.load()
File "/home/qmcpl/projects/eddie/env_newmodel/lib/python3.5/site-packages/django/contrib/sessions/backends/db.py", line 35, in load
expire_date__gt=timezone.now()
File "/home/qmcpl/projects/eddie/env_newmodel/lib/python3.5/site-packages/django/db/backends/base/base.py", line 213, in ensure_connection
self.connect()
File "/home/qmcpl/projects/eddie/env_newmodel/lib/python3.5/site-packages/django/db/backends/base/base.py", line 189, in connect
self.connection = self.get_new_connection(conn_params)
File "/home/qmcpl/projects/eddie/env_newmodel/lib/python3.5/site-packages/sql_server/pyodbc/base.py", line 309, in get_new_connection
timeout=timeout)
django.db.utils.OperationalError: ('08001', '[08001] [unixODBC][FreeTDS][SQL Server]Unable to connect to data source (0) (SQLDriverConnect)')
*** Error in `/home/qmcpl/projects/eddie/env_newmodel/bin/python': corrupted size vs. prev_size: 0x00007fad5807d130 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x777e5)[0x7fad780ab7e5
/usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so(+0x3bf39)[0x7fad6ca2ff39]
/usr/lib/x86_64-linux-gnu/libodbc.so.2(SQLDriverConnectW+0x98c)[0x7fad71b850ec]
/home/qmcpl/projects/eddie/env_newmodel/lib/python3.5/site-packages/pyodbc.cpython-35m-x86_64-linux-gnu.so(_Z14Connection_NewP7_objectbblbS0_R6Object+0x2c3)[0x7fad71dcac53]
/home/qmcpl/projects/eddie/env_newmodel/lib/python3.5/site-packages/pyodbc.cpython-35m-x86_64-linux-gnu.so(+0x13d8e)[0x7fad71dd4d8e]
/home/qmcpl/projects/eddie/env_newmodel/bin/python(PyCFunction_Call+0x77)[0x4e9ba7]
/home/qmcpl/projects/eddie/env_newmodel/bin/python[0x4ebd98]
/home/qmcpl/projects/eddie/env_newmodel/bin/python(PyObject_Call+0x47)[0x5c1797]
======= Memory map:=======
00000-007a00 r-xp 00000000 08:01 4587
/home/qmcpl/projects/eddie/env_newmodel/bin/python3.5
009a9000-009ab000 r--p 003a9000 08:01 45878
/home/qmcpl/projects/eddie/env_newmodel/bin/python3.5
00000-0000 rw-p 00000000 00:00 0 [heap]
/home/qmcpl/projects/eddie/env_newmodel/lib/python3.5/site-packages/shapely/speedups/_speedups.cpython-35m-x86_64-linux-gnu.so
/home/qmcpl/projects/eddie/env_newmodel/lib/python3.5/site-packages/shapely/.libs/libgeos_c-bd8d3f16.so.1.10. /home/qmcpl/projects/eddie/env_newmodel/lib/python3.5/site-packages/Crypto/Cipher/_AES.cpython-35m-x86_64-linux-gnu.so
/home/qmcpl/projects/eddie/env_newmodel/lib/python3.5/site-packages/.libs_cffi_backend/libffi-ae16d830.so.6.0.4
/home/qmcpl/projects/eddie/env_newmodel/lib/python3.5/site-packages/_cffi_backend.cpython-35m-x86_64-linux-gnu.so/home/qmcpl/projects/eddie/env_newmodel/lib/python3.5/site-packages/_cffi_backend.cpython-35m-x86_64-linux-gnu.so
/home/qmcpl/projects/eddie/env_newmodel/lib/python3.5/site-packages/cryptography/hazmat/bindings/_constant_time.abi3.so
7fad6930c000-7fad694cc000 rw-p 00000000 00:00 0
/home/qmcpl/projects/eddie/env_newmodel/lib/python3.5/site-packages/PIL/.libs/libfreetype-c8a1f873.so.6.14.0 /home/qmcpl/projects/eddie/env_newmodel/lib/python3.5/site-packages/PIL/_imagingft.cpython-35m-x86_64-linux-gnu.so
7fad699bc000-7fad69bbc000 ---p 00004000 08:01 4858292 /home/qmcpl/projects/eddie/env_newmodel/lib/python3.5/site-packages/PIL/_imagingft.cpython-35m-x86_64-linux-gnu.soAborted (core dumped)
Примечание:
Сервер работал нормально, и нет проблем в экземпляре AWS RDS, где MSSQLсервер есть.Мы являемся тремя пользователями (dev), в настройках AWS RDS может быть максимум до 30-40 соединений.Часто сталкиваемся с этой ошибкой, иногда в течение 2-5 часов, иногда в течение 10 минут, а иногда мы не получаем ошибку через 6-8 часов.
Я проверил файл /etc/odbcinst.ini:
[ODBC Driver 13 for SQL Server]
Description=Microsoft ODBC Driver 13 for SQL Server
Driver=/opt/microsoft/msodbcsql/lib64/libmsodbcsql-13.1.so.4.0
UsageCount=1
[FreeTDS]
Description=FreeTDS Driver
Driver=/usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so
Setup=/usr/lib/x86_64-linux-gnu/odbc/libtdsS.so
[ODBC Driver 17 for SQL Server]
Description=Microsoft ODBC Driver 17 for SQL Server
Driver=/opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.2.so.0.1
UsageCount=1
Иногда я также получаю ошибку ниже:
python: malloc.c:2394: sysmalloc: Assertion `(old_top == initial_top (av) && old_size == 0) || ((unsigned long) (old_size) >= MINSIZE && prev_inuse (old_top) && ((unsigned long) old_end & (pagesize - 1)) == 0)' failed.
Aborted (core dumped)