几百块找大佬解决一个小问题

2020-08-02 09:52:27 +08:00
 graetdk

我使用开源 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 太菜了,不知道有什么好的方法可以改一下(例如增加等待时间啥的)

因此希望求助各位大佬,能解决的给一个大红包,拜谢了

3586 次点击
所在节点    问与答
14 条回复
huabalance
2020-08-02 10:00:04 +08:00
如果数据很多,并发也多的话,sqlite 不算是好的数据库。。
lxk11153
2020-08-02 10:03:48 +08:00
加锁?加 TM de
huabalance
2020-08-02 10:04:41 +08:00
可以留下你的联系方式。。
graetdk
2020-08-02 10:31:14 +08:00
@huabalance 微信 Z3JlYXRkaw==
imn1
2020-08-02 10:56:29 +08:00
加个参数? check_same_thread=False
不过用的是 sqlalchemy,那我也不清楚了
jakezh
2020-08-02 11:09:23 +08:00
楼主帮你省几百块钱 touch your_path/superset.db
graetdk
2020-08-02 11:31:05 +08:00
@jakezh 这个文件在哪个目录下面啊?
barrelsoil
2020-08-02 11:53:02 +08:00
@graetdk find 啊
graetdk
2020-08-02 12:47:08 +08:00
@jakezh
@barrelsoil

木有找到这个文件
liprais
2020-08-02 12:49:15 +08:00
别用 sqlite 呗
renmu123
2020-08-02 13:09:41 +08:00
lasuar
2020-08-03 13:51:38 +08:00
切 mysql 可解
Neenjage
2020-10-25 18:26:34 +08:00
楼主,你好,我也是 superset 遇到这个问题了,每次第一次访问 dashboard 基本就会有这个问题,楼主解决问题了吗,分享下
graetdk
2020-10-26 10:31:38 +08:00
@Neenjage 没有,我现在用最粗暴的办法,开一个 supervisor,遇到这个报错就 restart 整个 superset,这样刷新后就能正常进入报表

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/694957

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX