[admin] Changing default admin email address causes database to be locked
See original GitHub issueAdding an email address of the default admin account times out (stuck loading) for me. My reverse proxy for OpenWISP reports a 502 Bad Gateway. But once I reload the page and try to do it again, it does not time out, but it returns Server Error (500). Any subsequent operation relating to the database (adding a new device) shows the 500 error as well.
Here is what I’m trying to do:
Looking in the logs at /opt/openwisp2/log/error.log
shows that the database is locked after timing out.
[ERROR 2018-11-08 15:17:37,453] module: exception, process: 1012, thread: 140389754636032
Internal Server Error: /admin/openwisp_users/user/881634f0-f3b0-4d73-98e0-f61a09822add/change/
Traceback (most recent call last):
File "/opt/openwisp2/env/lib/python3.6/site-packages/django/db/backends/utils.py", line 85, in _execute
return self.cursor.execute(sql, params)
File "/opt/openwisp2/env/lib/python3.6/site-packages/django/db/backends/sqlite3/base.py", line 303, in execute
return Database.Cursor.execute(self, query, params)
sqlite3.OperationalError: database is locked
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/opt/openwisp2/env/lib/python3.6/site-packages/django/core/handlers/exception.py", line 35, in inner
response = get_response(request)
File "/opt/openwisp2/env/lib/python3.6/site-packages/django/core/handlers/base.py", line 128, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/opt/openwisp2/env/lib/python3.6/site-packages/django/core/handlers/base.py", line 126, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/opt/openwisp2/env/lib/python3.6/site-packages/django/contrib/admin/options.py", line 575, in wrapper
return self.admin_site.admin_view(view)(*args, **kwargs)
File "/opt/openwisp2/env/lib/python3.6/site-packages/django/utils/decorators.py", line 142, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "/opt/openwisp2/env/lib/python3.6/site-packages/django/views/decorators/cache.py", line 44, in _wrapped_view_func
response = view_func(request, *args, **kwargs)
File "/opt/openwisp2/env/lib/python3.6/site-packages/django/contrib/admin/sites.py", line 223, in inner
return view(request, *args, **kwargs)
File "/opt/openwisp2/env/lib/python3.6/site-packages/reversion/admin.py", line 181, in change_view
return super(VersionAdmin, self).change_view(request, object_id, form_url, extra_context)
File "/opt/openwisp2/env/lib/python3.6/site-packages/django/contrib/admin/options.py", line 1557, in change_view
return self.changeform_view(request, object_id, form_url, extra_context)
File "/opt/openwisp2/env/lib/python3.6/site-packages/django/utils/decorators.py", line 62, in _wrapper
return bound_func(*args, **kwargs)
File "/opt/openwisp2/env/lib/python3.6/site-packages/django/utils/decorators.py", line 142, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "/opt/openwisp2/env/lib/python3.6/site-packages/django/utils/decorators.py", line 58, in bound_func
return func.__get__(self, type(self))(*args2, **kwargs2)
File "/opt/openwisp2/env/lib/python3.6/site-packages/django/contrib/admin/options.py", line 1451, in changeform_view
return self._changeform_view(request, object_id, form_url, extra_context)
File "/opt/openwisp2/env/lib/python3.6/site-packages/django/contrib/admin/options.py", line 1491, in _changeform_view
self.save_model(request, new_object, form, not add)
File "/opt/openwisp2/env/lib/python3.6/site-packages/openwisp_users/admin.py", line 109, in save_model
super(UserAdmin, self).save_model(request, obj, form, change)
File "/opt/openwisp2/env/lib/python3.6/site-packages/django/contrib/admin/options.py", line 1027, in save_model
obj.save()
File "/opt/openwisp2/env/lib/python3.6/site-packages/django/contrib/auth/base_user.py", line 73, in save
super().save(*args, **kwargs)
File "/opt/openwisp2/env/lib/python3.6/site-packages/django/db/models/base.py", line 729, in save
force_update=force_update, update_fields=update_fields)
File "/opt/openwisp2/env/lib/python3.6/site-packages/django/db/models/base.py", line 759, in save_base
updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
File "/opt/openwisp2/env/lib/python3.6/site-packages/django/db/models/base.py", line 823, in _save_table
forced_update)
File "/opt/openwisp2/env/lib/python3.6/site-packages/django/db/models/base.py", line 872, in _do_update
return filtered._update(values) > 0
File "/opt/openwisp2/env/lib/python3.6/site-packages/django/db/models/query.py", line 712, in _update
return query.get_compiler(self.db).execute_sql(CURSOR)
File "/opt/openwisp2/env/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 1379, in execute_sql
cursor = super().execute_sql(result_type)
File "/opt/openwisp2/env/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 1068, in execute_sql
cursor.execute(sql, params)
File "/opt/openwisp2/env/lib/python3.6/site-packages/django/db/backends/utils.py", line 68, in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File "/opt/openwisp2/env/lib/python3.6/site-packages/django/db/backends/utils.py", line 77, in _execute_with_wrappers
return executor(sql, params, many, context)
File "/opt/openwisp2/env/lib/python3.6/site-packages/django/db/backends/utils.py", line 85, in _execute
return self.cursor.execute(sql, params)
File "/opt/openwisp2/env/lib/python3.6/site-packages/django/db/utils.py", line 89, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/opt/openwisp2/env/lib/python3.6/site-packages/django/db/backends/utils.py", line 85, in _execute
return self.cursor.execute(sql, params)
File "/opt/openwisp2/env/lib/python3.6/site-packages/django/db/backends/sqlite3/base.py", line 303, in execute
return Database.Cursor.execute(self, query, params)
django.db.utils.OperationalError: database is locked
Here is the error from /opt/openwisp2/log/nginx.error.log
:
2018/11/08 14:57:43 [error] 813#813: *15 upstream prematurely closed connection while reading response headerfrom upstream, client: 192.168.1.116, server: openwisp.danielwang.me, request: "POST /admin/openwisp_users/user/881634f0-f3b0-4d73-98e0-f61a09822add/change/ HTTP/1.0", upstream: "uwsgi://127.0.0.1:3031", host: "openwisp.danielwang.me", referrer: "https://openwisp.danielwang.me/admin/openwisp_users/user/881634f0-f3b0-4d73-98e0-f61a09822add/change/"
After restarting the server, the database is unlocked, and all other database operations work besides adding an email to the default admin user, which locks the database again.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:10 (9 by maintainers)
Top Results From Across the Web
Change WordPress admin email without confirmation
Log into the database. phpMyAdmin is a good choice. · Locate the wp_options table. · Near the top locate the admin_email option ·...
Read more >How to Change the WordPress Admin Email (3 Methods)
By default, WordPress uses the first email address you provide as your ... Things to Do Before Changing Admin Email Address in WordPress....
Read more >Locked out of Your WordPress Admin Dashboard? (Here's ...
A common WordPress security practice is to change the default admin login URL ( domain.com/wp-admin ) to something custom.
Read more >Locked Out of WordPress? Here's What You Need to Do
Locked out of your WordPress admin account? Check out this article to learn why it happens and nine methods to fix it easily!...
Read more >Connect to SQL Server when system administrators are ...
This article describes how you can regain access to the SQL Server Database Engine as a system administrator if you've been locked out....
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 FreeTop 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
Top GitHub Comments
I think this PR may have fixed this issue: https://github.com/openwisp/openwisp-users/pull/74
We need to test that openwisp-user version and try replicating the issue again to see if it still happens.
this kind of error happens with sqlite when multiple processes try to write to the database at the same time. The strange thing is that it never happened to me. Yes please, try it out in the dev server, if you can’t replicate it there I’ll move the issue to
ansible-openwisp2
.