upgrade 4.1.0 to 4.2.0 cause access to wrong table
See original GitHub issueI am using silk on a system which does not managed the table, its migration model like this
migrations.CreateModel(
name='User',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('password', models.CharField(max_length=128, verbose_name='password')),
('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')),
('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')),
('username', models.CharField(error_messages={'unique': 'A user with that username already exists.'}, help_text='Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.', max_length=150, unique=True, validators=[django.contrib.auth.validators.UnicodeUsernameValidator()], verbose_name='username')),
('first_name', models.CharField(blank=True, max_length=150, verbose_name='first name')),
('last_name', models.CharField(blank=True, max_length=150, verbose_name='last name')),
('email', models.EmailField(blank=True, max_length=254, verbose_name='email address')),
('is_staff', models.BooleanField(default=False, help_text='Designates whether the user can log into this admin site.', verbose_name='staff status')),
('is_active', models.BooleanField(default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')),
('date_joined', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date joined')),
('display_name', models.CharField(blank=True, max_length=255, null=True)),
('role', models.IntegerField(choices=[(0, 'System'), (1, 'Admin'), (2, 'Operator'), (3, 'CustomerService'), (100, 'Merchant'), (200, 'Platform'), (300, 'Agent'), (1000, 'Player')], default=2)),
('google2fa_secret', models.CharField(max_length=100)),
('update_time', models.DateTimeField(auto_now=True)),
],
options={
'db_table': 'backend_user',
'managed': False,
},
managers=[
('objects', django.contrib.auth.models.UserManager()),
],
)
it is work fine on 4.1.0, but I encounter below issue on 4.2.0
2021-11-02 23:17:19,237 [WARNING][unicorn_common.middleware:34] - get_jwt_user() UnicornAuthentication failed. message: (1146, "Table 'olympus.backend_user' doesn't exist")
2021-11-02 23:17:19,296 [ERROR][django.request:224] - Internal Server Error: /games/games/
Traceback (most recent call last):
File "/home/venv_olympus/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
File "/home/venv_olympus/lib/python3.8/site-packages/django/db/backends/mysql/base.py", line 73, in execute
return self.cursor.execute(query, args)
File "/home/venv_olympus/lib/python3.8/site-packages/MySQLdb/cursors.py", line 206, in execute
res = self._query(query)
File "/home/venv_olympus/lib/python3.8/site-packages/MySQLdb/cursors.py", line 319, in _query
db.query(q)
File "/home/venv_olympus/lib/python3.8/site-packages/MySQLdb/connections.py", line 259, in query
_mysql.connection.query(self, query)
MySQLdb._exceptions.ProgrammingError: (1146, "Table 'olympus.backend_user' doesn't exist")
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/venv_olympus/lib/python3.8/site-packages/asgiref/sync.py", line 482, in thread_handler
raise exc_info[1]
File "/home/venv_olympus/lib/python3.8/site-packages/django/core/handlers/exception.py", line 38, in inner
response = await get_response(request)
File "/home/venv_olympus/lib/python3.8/site-packages/django/core/handlers/base.py", line 231, in _get_response_async
response = await wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/venv_olympus/lib/python3.8/site-packages/asgiref/sync.py", line 444, in __call__
ret = await asyncio.wait_for(future, timeout=None)
File "/usr/lib/python3.8/asyncio/tasks.py", line 455, in wait_for
return await fut
File "/home/venv_olympus/lib/python3.8/site-packages/asgiref/current_thread_executor.py", line 22, in run
result = self.fn(*self.args, **self.kwargs)
File "/home/venv_olympus/lib/python3.8/site-packages/asgiref/sync.py", line 486, in thread_handler
return func(*args, **kwargs)
File "/home/venv_olympus/lib/python3.8/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
return view_func(*args, **kwargs)
File "/home/venv_olympus/lib/python3.8/site-packages/rest_framework/viewsets.py", line 125, in view
return self.dispatch(request, *args, **kwargs)
File "/home/venv_olympus/lib/python3.8/site-packages/rest_framework/views.py", line 509, in dispatch
response = self.handle_exception(exc)
File "/home/venv_olympus/lib/python3.8/site-packages/rest_framework/views.py", line 469, in handle_exception
self.raise_uncaught_exception(exc)
File "/home/venv_olympus/lib/python3.8/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
raise exc
File "/home/venv_olympus/lib/python3.8/site-packages/rest_framework/views.py", line 497, in dispatch
self.initial(request, *args, **kwargs)
File "/home/venv_olympus/lib/python3.8/site-packages/rest_framework/views.py", line 414, in initial
self.perform_authentication(request)
File "/home/venv_olympus/lib/python3.8/site-packages/rest_framework/views.py", line 324, in perform_authentication
request.user
File "/home/venv_olympus/lib/python3.8/site-packages/rest_framework/request.py", line 227, in user
self._authenticate()
File "/home/venv_olympus/lib/python3.8/site-packages/rest_framework/request.py", line 380, in _authenticate
user_auth_tuple = authenticator.authenticate(self)
File "/home/venv_olympus/lib/python3.8/site-packages/rest_framework_simplejwt/authentication.py", line 42, in authenticate
return self.get_user(validated_token), validated_token
File "/home/venv_olympus/lib/python3.8/site-packages/unicorn_common/authentication.py", line 25, in get_user
user = auth_model.objects.get(pk=_id)
File "/home/venv_olympus/lib/python3.8/site-packages/django/db/models/manager.py", line 85, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/home/venv_olympus/lib/python3.8/site-packages/django/db/models/query.py", line 425, in get
num = len(clone)
File "/home/venv_olympus/lib/python3.8/site-packages/django/db/models/query.py", line 269, in __len__
self._fetch_all()
File "/home/venv_olympus/lib/python3.8/site-packages/django/db/models/query.py", line 1308, in _fetch_all
self._result_cache = list(self._iterable_class(self))
File "/home/venv_olympus/lib/python3.8/site-packages/django/db/models/query.py", line 53, in __iter__
results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size)
File "/home/venv_olympus/lib/python3.8/site-packages/silk/sql.py", line 94, in execute_sql
query_dict['analysis'] = _explain_query(q, params)
File "/home/venv_olympus/lib/python3.8/site-packages/silk/sql.py", line 56, in _explain_query
cur.execute(prefixed_query, params)
File "/home/venv_olympus/lib/python3.8/site-packages/django/db/backends/utils.py", line 98, in execute
return super().execute(sql, params)
File "/home/venv_olympus/lib/python3.8/site-packages/django/db/backends/utils.py", line 66, in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File "/home/venv_olympus/lib/python3.8/site-packages/django/db/backends/utils.py", line 75, in _execute_with_wrappers
return executor(sql, params, many, context)
File "/home/venv_olympus/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
File "/home/venv_olympus/lib/python3.8/site-packages/django/db/utils.py", line 90, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/home/venv_olympus/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
File "/home/venv_olympus/lib/python3.8/site-packages/django/db/backends/mysql/base.py", line 73, in execute
return self.cursor.execute(query, args)
File "/home/venv_olympus/lib/python3.8/site-packages/MySQLdb/cursors.py", line 206, in execute
res = self._query(query)
File "/home/venv_olympus/lib/python3.8/site-packages/MySQLdb/cursors.py", line 319, in _query
db.query(q)
File "/home/venv_olympus/lib/python3.8/site-packages/MySQLdb/connections.py", line 259, in query
_mysql.connection.query(self, query)
django.db.utils.ProgrammingError: (1146, "Table 'olympus.backend_user' doesn't exist")
it seems something change from 4.1.0 to 4.2.0 at below function
File "/home/venv_olympus/lib/python3.8/site-packages/silk/sql.py", line 94, in execute_sql
query_dict['analysis'] = _explain_query(q, params)
File "/home/venv_olympus/lib/python3.8/site-packages/silk/sql.py", line 56, in _explain_query
cur.execute(prefixed_query, params)
I am not sure what change cause this issue, but I think it should work the same way like 4.1.0 without error.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:11 (5 by maintainers)
Top Results From Across the Web
Solved: just attempted upgrade of 4.1.0 to 4.1.1 got error...
On a linux Unbuntu system : I just attempted upgrade of 4.1.0 to 4.1.1 server and got error messgages with start of Upgrading...
Read more >Sentry Upgrade Errors When Upgrading to BDA 4.5.0
During upgrade of Oracle Big Data Appliance from 4.2.0 to 4.5.0 seeing the error: ERROR: Sentry database should be on primary mysql node...
Read more >Release 4.2.0 Change Log - OpenIAM Documentation
Issue Type Issue key Summary
Bug IAM‑5079 Audit logs fields do not work
Bug IAM‑5076 fix for 'my direct report access' page
Bug IAM‑5071 Linux connector...
Read more >TWikiUpgradeGuide < TWiki04x03 < TWiki
This guide covers upgrading from a previous version of TWiki (such as Cairo or ... From TWiki-4.1.0 the configure script which you ran...
Read more >Installation and Upgrade Guide | SUSE Manager 4.3
Table of Contents. Installation and Upgrade Guide Overview. 1. 1. General Requirements. 2. 1.1. Obtain Your SUSE Customer Center Credentials ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@caesarleong @rafou @j-zaballa: Please see if #538 fixes the issue for you.
@glujan thank you so much for the PR. It does indeed solve the issue 😃