我使用开源 BI 工具 Superset 搭了一个业务看板,其它方面没得说,确实挺棒的
但就是有一个问题:在每次进入 Dashboard 的时候,会出现这样的报错:
需要刷新很多次才能好
完整报错代码如下:
Traceback (most recent call last):
File "/root/.pyenv/versions/3.6.5/envs/venv-3.6.5/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 755, in _commit_impl
self.engine.dialect.do_commit(self.connection)
File "/root/.pyenv/versions/3.6.5/envs/venv-3.6.5/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 534, in do_commit
dbapi_connection.commit()
sqlite3.OperationalError: database is locked
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/root/.pyenv/versions/3.6.5/envs/venv-3.6.5/lib/python3.6/site-packages/flask/app.py", line 2446, in wsgi_app
response = self.full_dispatch_request()
File "/root/.pyenv/versions/3.6.5/envs/venv-3.6.5/lib/python3.6/site-packages/flask/app.py", line 1951, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/root/.pyenv/versions/3.6.5/envs/venv-3.6.5/lib/python3.6/site-packages/flask/app.py", line 1820, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/root/.pyenv/versions/3.6.5/envs/venv-3.6.5/lib/python3.6/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/root/.pyenv/versions/3.6.5/envs/venv-3.6.5/lib/python3.6/site-packages/flask/app.py", line 1949, in full_dispatch_request
rv = self.dispatch_request()
File "/root/.pyenv/versions/3.6.5/envs/venv-3.6.5/lib/python3.6/site-packages/flask/app.py", line 1935, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/root/.pyenv/versions/3.6.5/envs/venv-3.6.5/lib/python3.6/site-packages/flask_appbuilder/security/decorators.py", line 109, in wraps
return f(self, *args, **kwargs)
File "/root/.pyenv/versions/3.6.5/envs/venv-3.6.5/lib/python3.6/site-packages/superset/views/core.py", line 1796, in dashboard
edit_mode=edit_mode,
File "/root/.pyenv/versions/3.6.5/envs/venv-3.6.5/lib/python3.6/site-packages/superset/utils/log.py", line 78, in wrapper
referrer=referrer,
File "/root/.pyenv/versions/3.6.5/envs/venv-3.6.5/lib/python3.6/site-packages/superset/utils/log.py", line 161, in log
sesh.commit()
File "/root/.pyenv/versions/3.6.5/envs/venv-3.6.5/lib/python3.6/site-packages/sqlalchemy/orm/scoping.py", line 162, in do
return getattr(self.registry(), name)(*args, **kwargs)
File "/root/.pyenv/versions/3.6.5/envs/venv-3.6.5/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 1036, in commit
self.transaction.commit()
File "/root/.pyenv/versions/3.6.5/envs/venv-3.6.5/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 507, in commit
t[1].commit()
File "/root/.pyenv/versions/3.6.5/envs/venv-3.6.5/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1727, in commit
self._do_commit()
File "/root/.pyenv/versions/3.6.5/envs/venv-3.6.5/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1758, in _do_commit
self.connection._commit_impl()
File "/root/.pyenv/versions/3.6.5/envs/venv-3.6.5/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 757, in _commit_impl
self._handle_dbapi_exception(e, None, None, None, None)
File "/root/.pyenv/versions/3.6.5/envs/venv-3.6.5/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1476, in _handle_dbapi_exception
util.raise_from_cause(sqlalchemy_exception, exc_info)
File "/root/.pyenv/versions/3.6.5/envs/venv-3.6.5/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 398, in raise_from_cause
reraise(type(exception), exception, tb=exc_tb, cause=cause)
File "/root/.pyenv/versions/3.6.5/envs/venv-3.6.5/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 152, in reraise
raise value.with_traceback(tb)
File "/root/.pyenv/versions/3.6.5/envs/venv-3.6.5/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 755, in _commit_impl
self.engine.dialect.do_commit(self.connection)
File "/root/.pyenv/versions/3.6.5/envs/venv-3.6.5/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 534, in do_commit
dbapi_connection.commit()
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) database is locked
(Background on this error at: http://sqlalche.me/e/e3q8)
初步判断是 sqlite3 的问题,在读数据库的时候遇到锁了,但是咱 python 太菜了,不知道有什么好的方法可以改一下(例如增加等待时间啥的)
因此希望求助各位大佬,能解决的给一个大红包,拜谢了
1
huabalance 2020-08-02 10:00:04 +08:00
如果数据很多,并发也多的话,sqlite 不算是好的数据库。。
|
2
lxk11153 2020-08-02 10:03:48 +08:00
加锁?加 TM de
|
3
huabalance 2020-08-02 10:04:41 +08:00
可以留下你的联系方式。。
|
4
graetdk OP @huabalance 微信 Z3JlYXRkaw==
|
5
imn1 2020-08-02 10:56:29 +08:00
加个参数? check_same_thread=False
不过用的是 sqlalchemy,那我也不清楚了 |
6
jakezh 2020-08-02 11:09:23 +08:00
楼主帮你省几百块钱 touch your_path/superset.db
|
8
barrelsoil 2020-08-02 11:53:02 +08:00
@graetdk find 啊
|
9
graetdk OP |
10
liprais 2020-08-02 12:49:15 +08:00
别用 sqlite 呗
|
11
renmu123 2020-08-02 13:09:41 +08:00 via Android
看看这个 https://stackoverflow.com/questions/2740806/python-sqlite-database-is-locked 用 MySQL 可能会少进很多坑
|
12
lasuar 2020-08-03 13:51:38 +08:00
切 mysql 可解
|
13
Neenjage 2020-10-25 18:26:34 +08:00
楼主,你好,我也是 superset 遇到这个问题了,每次第一次访问 dashboard 基本就会有这个问题,楼主解决问题了吗,分享下
|