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

Падает клиент mysql, в чем проблема? #84

Open
ericovva opened this issue Nov 13, 2017 · 5 comments
Open

Падает клиент mysql, в чем проблема? #84

ericovva opened this issue Nov 13, 2017 · 5 comments

Comments

@ericovva
Copy link

Internal Server Error: /admin/fias/suggest.json
Traceback (most recent call last):
File "/Users/e.ovsepyan/.virtualenvs/ganesha_fias3/lib/python3.6/site-packages/django/core/handlers/exception.py", line 42, in inner
response = get_response(request)
File "/Users/e.ovsepyan/.virtualenvs/ganesha_fias3/lib/python3.6/site-packages/django/core/handlers/base.py", line 187, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/Users/e.ovsepyan/.virtualenvs/ganesha_fias3/lib/python3.6/site-packages/django/core/handlers/base.py", line 185, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/Users/e.ovsepyan/.virtualenvs/ganesha_fias3/lib/python3.6/site-packages/django/views/generic/base.py", line 68, in view
return self.dispatch(request, *args, **kwargs)
File "/Users/e.ovsepyan/.virtualenvs/ganesha_fias3/lib/python3.6/site-packages/django/views/generic/base.py", line 88, in dispatch
return handler(request, *args, **kwargs)
File "/Users/e.ovsepyan/.virtualenvs/ganesha_fias3/lib/python3.6/site-packages/fias/suggest/backends/sphinx/views.py", line 46, in get
self.object_list = self.get_queryset()
File "/Users/e.ovsepyan/.virtualenvs/ganesha_fias3/lib/python3.6/site-packages/fias/suggest/backends/sphinx/views.py", line 64, in get_queryset
cur = connections['fias_search'].cursor()
File "/Users/e.ovsepyan/.virtualenvs/ganesha_fias3/lib/python3.6/site-packages/django/db/backends/base/base.py", line 231, in cursor
cursor = self.make_debug_cursor(self._cursor())
File "/Users/e.ovsepyan/.virtualenvs/ganesha_fias3/lib/python3.6/site-packages/django/db/backends/base/base.py", line 204, in _cursor
self.ensure_connection()
File "/Users/e.ovsepyan/.virtualenvs/ganesha_fias3/lib/python3.6/site-packages/django/db/backends/base/base.py", line 199, in ensure_connection
self.connect()
File "/Users/e.ovsepyan/.virtualenvs/ganesha_fias3/lib/python3.6/site-packages/django/db/backends/base/base.py", line 173, in connect
self.init_connection_state()
File "/Users/e.ovsepyan/.virtualenvs/ganesha_fias3/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 269, in init_connection_state
if self.features.is_sql_auto_is_null_enabled:
File "/Users/e.ovsepyan/.virtualenvs/ganesha_fias3/lib/python3.6/site-packages/django/utils/functional.py", line 35, in get
res = instance.dict[self.name] = self.func(instance)
File "/Users/e.ovsepyan/.virtualenvs/ganesha_fias3/lib/python3.6/site-packages/django/db/backends/mysql/features.py", line 77, in is_sql_auto_is_null_enabled
cursor.execute('SELECT @@SQL_AUTO_IS_NULL')
File "/Users/e.ovsepyan/.virtualenvs/ganesha_fias3/lib/python3.6/site-packages/django/db/backends/utils.py", line 79, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "/Users/e.ovsepyan/.virtualenvs/ganesha_fias3/lib/python3.6/site-packages/django/db/backends/utils.py", line 62, in execute
return self.cursor.execute(sql)
File "/Users/e.ovsepyan/.virtualenvs/ganesha_fias3/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 110, in execute
return self.cursor.execute(query, args)
File "/Users/e.ovsepyan/.virtualenvs/ganesha_fias3/lib/python3.6/site-packages/MySQLdb/cursors.py", line 250, in execute
self.errorhandler(self, exc, value)
File "/Users/e.ovsepyan/.virtualenvs/ganesha_fias3/lib/python3.6/site-packages/MySQLdb/connections.py", line 50, in defaulterrorhandler
raise errorvalue
File "/Users/e.ovsepyan/.virtualenvs/ganesha_fias3/lib/python3.6/site-packages/MySQLdb/cursors.py", line 247, in execute
res = self._query(query)
File "/Users/e.ovsepyan/.virtualenvs/ganesha_fias3/lib/python3.6/site-packages/MySQLdb/cursors.py", line 412, in _query
self._post_get_result()
File "/Users/e.ovsepyan/.virtualenvs/ganesha_fias3/lib/python3.6/site-packages/MySQLdb/cursors.py", line 416, in _post_get_result
self._rows = self._fetch_row(0)
File "/Users/e.ovsepyan/.virtualenvs/ganesha_fias3/lib/python3.6/site-packages/MySQLdb/cursors.py", line 384, in _fetch_row
return self._result.fetch_row(size, self._fetch_type)
ValueError: invalid literal for int() with base 10: ''

база psql, python 3.6, настроил sphinx

@RomanKovalev
Copy link

Есть ли у кого подобная проблема? Как решали?

@ericovva
Copy link
Author

ericovva commented Aug 6, 2018

@RomanKovalev Да, проблема решается изменением версии сфинкса. Если детализировать отправляемые запросы, то перед каждым коннектом mysql клиент запрашивает статус какой-то там переменной у mysql, но в сфинкс не поддерживает валидный ответ. Поиграйтесь с версией sphinx и проблема будет решена. Если хотите побороть с любой версией, то переопределите mysql клиент в месте, где выполняется этот запрос, я сделал таким образом

@ericovva
Copy link
Author

ericovva commented Aug 6, 2018

@RomanKovalev чтобы найти этот запрос, включите режим DEBUG в логгере django

@RomanKovalev
Copy link

Вот мой лог запросов, запрос в сфинкс выделил жирным.
Не могу найти проблему.

(0.004)
SELECT c.relname, c.relkind
FROM pg_catalog.pg_class c
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
WHERE c.relkind IN ('r', 'v')
AND n.nspname NOT IN ('pg_catalog', 'pg_toast')
AND pg_catalog.pg_table_is_visible(c.oid); args=None

(0.001) SELECT "django_migrations"."app", "django_migrations"."name" FROM "django_migrations"; args=()

(0.002) SELECT "django_session"."session_key", "django_session"."session_data", "django_session"."expire_date" FROM "django_session" WHERE ("django_session"."session_key" = 'db2l38t0skrfptus7cr1gxysk6jyvdrp' AND "django_session"."expire_date" > '2018-08-07T07:05:46.319630+00:00'::timestamptz); args=('db2l38t0skrfptus7cr1gxysk6jyvdrp', datetime.datetime(2018, 8, 7, 7, 5, 46, 319630, tzinfo=))

(0.001) SELECT "auth_user"."id", "auth_user"."password", "auth_user"."last_login", "auth_user"."is_superuser", "auth_user"."username", "auth_user"."first_name", "auth_user"."last_name", "auth_user"."email", "auth_user"."is_staff", "auth_user"."is_active", "auth_user"."date_joined" FROM "auth_user" WHERE "auth_user"."id" = 1; args=(1,)
(0.001) SELECT "django_content_type"."id", "django_content_type"."app_label", "django_content_type"."model" FROM "django_content_type" WHERE ("django_content_type"."app_label" = 'search' AND "django_content_type"."model" = 'item'); args=('search', 'item')

(0.003) SELECT "django_session"."session_key", "django_session"."session_data", "django_session"."expire_date" FROM "django_session" WHERE ("django_session"."session_key" = 'db2l38t0skrfptus7cr1gxysk6jyvdrp' AND "django_session"."expire_date" > '2018-08-07T07:05:46.480753+00:00'::timestamptz); args=('db2l38t0skrfptus7cr1gxysk6jyvdrp', datetime.datetime(2018, 8, 7, 7, 5, 46, 480753, tzinfo=))

(0.002) SELECT "auth_user"."id", "auth_user"."password", "auth_user"."last_login", "auth_user"."is_superuser", "auth_user"."username", "auth_user"."first_name", "auth_user"."last_name", "auth_user"."email", "auth_user"."is_staff", "auth_user"."is_active", "auth_user"."date_joined" FROM "auth_user" WHERE "auth_user"."id" = 1; args=(1,)

(0.001) SELECT "aoguid", "fullname" FROM "default_addrobj" WHERE MATCH("''") ORDER BY item_weight DESC,weight() DESC LIMIT 30; args=('',)

(0.002) SELECT "django_session"."session_key", "django_session"."session_data", "django_session"."expire_date" FROM "django_session" WHERE ("django_session"."session_key" = 'db2l38t0skrfptus7cr1gxysk6jyvdrp' AND "django_session"."expire_date" > '2018-08-07T07:05:47.912403+00:00'::timestamptz); args=('db2l38t0skrfptus7cr1gxysk6jyvdrp', datetime.datetime(2018, 8, 7, 7, 5, 47, 912403, tzinfo=))

(0.001) SELECT "auth_user"."id", "auth_user"."password", "auth_user"."last_login", "auth_user"."is_superuser", "auth_user"."username", "auth_user"."first_name", "auth_user"."last_name", "auth_user"."email", "auth_user"."is_staff", "auth_user"."is_active", "auth_user"."date_joined" FROM "auth_user" WHERE "auth_user"."id" = 1; args=(1,)
(0.001) SELECT "aoguid", "fullname" FROM "default_addrobj" WHERE MATCH("'М'") ORDER BY item_weight DESC,weight() DESC LIMIT 30; args=('М',)**
(0.002) SELECT "django_session"."session_key", "django_session"."session_data", "django_session"."expire_date" FROM "django_session" WHERE ("django_session"."session_key" = 'db2l38t0skrfptus7cr1gxysk6jyvdrp' AND "django_session"."expire_date" > '2018-08-07T07:05:49.856030+00:00'::timestamptz); args=('db2l38t0skrfptus7cr1gxysk6jyvdrp', datetime.datetime(2018, 8, 7, 7, 5, 49, 856030, tzinfo=))

(0.001) SELECT "auth_user"."id", "auth_user"."password", "auth_user"."last_login", "auth_user"."is_superuser", "auth_user"."username", "auth_user"."first_name", "auth_user"."last_name", "auth_user"."email", "auth_user"."is_staff", "auth_user"."is_active", "auth_user"."date_joined" FROM "auth_user" WHERE "auth_user"."id" = 1; args=(1,)

(0.001) SELECT "aoguid", "fullname" FROM "default_addrobj" WHERE MATCH("'Мо*'") ORDER BY item_weight DESC,weight() DESC LIMIT 30; args=('Мо*',)

(0.002) SELECT "django_session"."session_key", "django_session"."session_data", "django_session"."expire_date" FROM "django_session" WHERE ("django_session"."session_key" = 'db2l38t0skrfptus7cr1gxysk6jyvdrp' AND "django_session"."expire_date" > '2018-08-07T07:05:50.224246+00:00'::timestamptz); args=('db2l38t0skrfptus7cr1gxysk6jyvdrp', datetime.datetime(2018, 8, 7, 7, 5, 50, 224246, tzinfo=))

(0.001) SELECT "auth_user"."id", "auth_user"."password", "auth_user"."last_login", "auth_user"."is_superuser", "auth_user"."username", "auth_user"."first_name", "auth_user"."last_name", "auth_user"."email", "auth_user"."is_staff", "auth_user"."is_active", "auth_user"."date_joined" FROM "auth_user" WHERE "auth_user"."id" = 1; args=(1,)

(0.001) SELECT "aoguid", "fullname" FROM "default_addrobj" WHERE MATCH("'Мос*'") ORDER BY item_weight DESC,weight() DESC LIMIT 30; args=('Мос*',)

(0.002) SELECT "django_session"."session_key", "django_session"."session_data", "django_session"."expire_date" FROM "django_session" WHERE ("django_session"."session_key" = 'db2l38t0skrfptus7cr1gxysk6jyvdrp' AND "django_session"."expire_date" > '2018-08-07T07:05:50.569152+00:00'::timestamptz); args=('db2l38t0skrfptus7cr1gxysk6jyvdrp', datetime.datetime(2018, 8, 7, 7, 5, 50, 569152, tzinfo=))

(0.001) SELECT "auth_user"."id", "auth_user"."password", "auth_user"."last_login", "auth_user"."is_superuser", "auth_user"."username", "auth_user"."first_name", "auth_user"."last_name", "auth_user"."email", "auth_user"."is_staff", "auth_user"."is_active", "auth_user"."date_joined" FROM "auth_user" WHERE "auth_user"."id" = 1; args=(1,)

@RomanKovalev
Copy link

RomanKovalev commented Aug 7, 2018

А вот, походу, и проблема.

Запатчил так:
django.db.backends.mysql.features
def is_sql_auto_is_null_enabled(self):
pass

Трейс:
(0.004)
SELECT c.relname, c.relkind
FROM pg_catalog.pg_class c
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
WHERE c.relkind IN ('r', 'v')
AND n.nspname NOT IN ('pg_catalog', 'pg_toast')
AND pg_catalog.pg_table_is_visible(c.oid); args=None

(0.001) SELECT "django_migrations"."app", "django_migrations"."name" FROM "django_migrations"; args=()

(0.002) SELECT "django_session"."session_key", "django_session"."session_data", "django_session"."expire_date" FROM "django_session" WHERE ("django_session"."session_key" = 'db2l38t0skrfptus7cr1gxysk6jyvdrp' AND "django_session"."expire_date" > '2018-08-07T08:46:26.336757+00:00'::timestamptz); args=('db2l38t0skrfptus7cr1gxysk6jyvdrp', datetime.datetime(2018, 8, 7, 8, 46, 26, 336757, tzinfo=))

(0.001) SELECT "auth_user"."id", "auth_user"."password", "auth_user"."last_login", "auth_user"."is_superuser", "auth_user"."username", "auth_user"."first_name", "auth_user"."last_name", "auth_user"."email", "auth_user"."is_staff", "auth_user"."is_active", "auth_user"."date_joined" FROM "auth_user" WHERE "auth_user"."id" = 1; args=(1,)

(0.001) SELECT "django_content_type"."id", "django_content_type"."app_label", "django_content_type"."model" FROM "django_content_type" WHERE ("django_content_type"."app_label" = 'search' AND "django_content_type"."model" = 'item'); args=('search', 'item')

(0.002) SELECT "django_session"."session_key", "django_session"."session_data", "django_session"."expire_date" FROM "django_session" WHERE ("django_session"."session_key" = 'db2l38t0skrfptus7cr1gxysk6jyvdrp' AND "django_session"."expire_date" > '2018-08-07T08:46:26.489612+00:00'::timestamptz); args=('db2l38t0skrfptus7cr1gxysk6jyvdrp', datetime.datetime(2018, 8, 7, 8, 46, 26, 489612, tzinfo=))

(0.002) SELECT "auth_user"."id", "auth_user"."password", "auth_user"."last_login", "auth_user"."is_superuser", "auth_user"."username", "auth_user"."first_name", "auth_user"."last_name", "auth_user"."email", "auth_user"."is_staff", "auth_user"."is_active", "auth_user"."date_joined" FROM "auth_user" WHERE "auth_user"."id" = 1; args=(1,)

(0.000) SELECT @@SQL_AUTO_IS_NULL; args=None

(0.002) SELECT "django_session"."session_key", "django_session"."session_data", "django_session"."expire_date" FROM "django_session" WHERE ("django_session"."session_key" = 'db2l38t0skrfptus7cr1gxysk6jyvdrp' AND "django_session"."expire_date" > '2018-08-07T08:46:28.670015+00:00'::timestamptz); args=('db2l38t0skrfptus7cr1gxysk6jyvdrp', datetime.datetime(2018, 8, 7, 8, 46, 28, 670015, tzinfo=))
(0.001) SELECT "auth_user"."id", "auth_user"."password", "auth_user"."last_login", "auth_user"."is_superuser", "auth_user"."username", "auth_user"."first_name", "auth_user"."last_name", "auth_user"."email", "auth_user"."is_staff", "auth_user"."is_active", "auth_user"."date_joined" FROM "auth_user" WHERE "auth_user"."id" = 1; args=(1,)

(0.000) SELECT @@SQL_AUTO_IS_NULL; args=None

(0.002) SELECT "django_session"."session_key", "django_session"."session_data", "django_session"."expire_date" FROM "django_session" WHERE ("django_session"."session_key" = 'db2l38t0skrfptus7cr1gxysk6jyvdrp' AND "django_session"."expire_date" > '2018-08-07T08:46:29.986753+00:00'::timestamptz); args=('db2l38t0skrfptus7cr1gxysk6jyvdrp', datetime.datetime(2018, 8, 7, 8, 46, 29, 986753, tzinfo=))

(0.001) SELECT "auth_user"."id", "auth_user"."password", "auth_user"."last_login", "auth_user"."is_superuser", "auth_user"."username", "auth_user"."first_name", "auth_user"."last_name", "auth_user"."email", "auth_user"."is_staff", "auth_user"."is_active", "auth_user"."date_joined" FROM "auth_user" WHERE "auth_user"."id" = 1; args=(1,)

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