首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >升级Apache Superset -RuntimeError后出错:在应用程序上下文之外工作

升级Apache Superset -RuntimeError后出错:在应用程序上下文之外工作
EN

Stack Overflow用户
提问于 2020-10-24 04:24:12
回答 1查看 694关注 0票数 1

我刚刚升级到最新版本的Apache Superset。当我使用以下命令启动Apache Superset时

代码语言:javascript
复制
gunicorn \
      -w 10 \
      -k gevent \
      --timeout 120 \
      -b  0.0.0.0:8088 \
      --limit-request-line 0 \
      --limit-request-field_size 0 \
      --statsd-host localhost:8088 \
      superset:app

我在服务器上看到错误"Internal server error“,它说:

代码语言:javascript
复制
 respiter = self.wsgi(environ, resp.start_response)
  File "/usr/local/superset/lib/python3.7/site-packages/werkzeug/local.py", line 376, in <lambda>
    __call__ = lambda x, *a, **kw: x._get_current_object()(*a, **kw)
  File "/usr/local/superset/lib/python3.7/site-packages/werkzeug/local.py", line 307, in _get_current_object
    return self.__local()
  File "/usr/local/superset/lib/python3.7/site-packages/flask/globals.py", line 52, in _find_app
    raise RuntimeError(_app_ctx_err_msg)
RuntimeError: Working outside of application context.
This typically means that you attempted to use functionality that needed
to interface with the current application object in some way. To solve
this, set up an application context with app.app_context().  See the
documentation for more information.

..。

我发现我改成了"superset.app:create_app()“,我可以登录了,如下所示:

代码语言:javascript
复制
gunicorn \
      -w 10 \
      -k gevent \
      --timeout 120 \
      -b  0.0.0.0:8088 \
      --limit-request-line 0 \
      --limit-request-field_size 0 \
      --statsd-host localhost:8088 \
"superset.app:create_app()"

但是当我打开一个仪表板时,我得到了这个错误:

代码语言:javascript
复制
 File "/usr/local/superset/lib/python3.7/site-packages/MySQLdb/connections.py", line 239, in query
    _mysql.connection.query(self, query)
sqlalchemy.exc.OperationalError: (MySQLdb._exceptions.OperationalError) (1054, "Unknown column 'slices.schema_perm' in 'field list'")
[SQL: SELECT slices.created_on AS slices_created_on, slices.changed_on AS slices_changed_on, slices.id AS slices_id, slices.slice_name AS slices_slice_name, slices.datasource_id AS slices_datasource_id, slices.datasource_type AS slices_datasource_type, slices.datasource_name AS slices_datasource_name, slices.viz_type AS slices_viz_type, slices.params AS slices_params, slices.description AS slices_description, slices.cache_timeout AS slices_cache_timeout, slices.perm AS slices_perm, slices.schema_perm AS slices_schema_perm, slices.created_by_fk AS slices_created_by_fk, slices.changed_by_fk AS slices_changed_by_fk, tables_1.created_on AS tables_1_created_on, tables_1.changed_on AS tables_1_changed_on, tables_1.id AS tables_1_id, tables_1.description AS tables_1_description, tables_1.default_endpoint AS tables_1_default_endpoint, tables_1.is_featured AS tables_1_is_featured, tables_1.filter_select_enabled AS tables_1_filter_select_enabled, tables_1.offset AS tables_1_offset, tables_1.cache_timeout AS tables_1_cache_timeout, tables_1.params AS tables_1_params, tables_1.perm AS tables_1_perm, tables_1.schema_perm AS tables_1_schema_perm, tables_1.table_name AS tables_1_table_name, tables_1.main_dttm_col AS tables_1_main_dttm_col, tables_1.database_id AS tables_1_database_id, tables_1.fetch_values_predicate AS tables_1_fetch_values_predicate, tables_1.`schema` AS tables_1_schema, tables_1.`sql` AS tables_1_sql, tables_1.is_sqllab_view AS tables_1_is_sqllab_view, tables_1.template_params AS tables_1_template_params, tables_1.created_by_fk AS tables_1_created_by_fk, tables_1.changed_by_fk AS tables_1_changed_by_fk 
FROM dashboard_slices, slices LEFT OUTER JOIN `tables` AS tables_1 ON slices.datasource_id = tables_1.id AND slices.datasource_type = %s 
WHERE %s = dashboard_slices.dashboard_id AND slices.id = dashboard_slices.slice_id]
[parameters: ('table', 7)]
(Background on this error at: http://sqlalche.me/e/13/e3q8)

我已经寻找了更多的解决方案。在使用db升级命令时,我的MySQL-database似乎没有随升级一起更正:

代码语言:javascript
复制
(superset) [root@host .superset]# superset db upgrade
logging was configured successfully
INFO:superset.utils.logging_configurator:logging was configured successfully
/usr/local/superset/lib/python3.7/site-packages/flask_caching/__init__.py:188: UserWarning: Flask-Cache: CACHE_TYPE is set to null, caching is effectively disabled.
  warnings.warn("Flask-Cache: CACHE_TYPE is set to null, "
WARNI [alembic.env] SQLite Database support for metadata databases will         be removed in a future version of Superset.
INFO  [alembic.runtime.migration] Context impl SQLiteImpl.
INFO  [alembic.runtime.migration] Will assume transactional DDL.

我没有看到任何错误吗?

当我调用init时,我得到这样的结果:

代码语言:javascript
复制
(superset) [root@host .superset]# superset init
logging was configured successfully
INFO:superset.utils.logging_configurator:logging was configured successfully
/usr/local/superset/lib/python3.7/site-packages/flask_caching/__init__.py:188: UserWarning: Flask-Cache: CACHE_TYPE is set to null, caching is effectively disabled.
  warnings.warn("Flask-Cache: CACHE_TYPE is set to null, "
Syncing role definition
INFO:superset.security.manager:Syncing role definition
Syncing Admin perms
INFO:superset.security.manager:Syncing Admin perms
Syncing Alpha perms
INFO:superset.security.manager:Syncing Alpha perms
Syncing Gamma perms
INFO:superset.security.manager:Syncing Gamma perms
Syncing granter perms
INFO:superset.security.manager:Syncing granter perms
Syncing sql_lab perms
INFO:superset.security.manager:Syncing sql_lab perms
Fetching a set of all perms to lookup which ones are missing
INFO:superset.security.manager:Fetching a set of all perms to lookup which ones are missing
Creating missing datasource permissions.
INFO:superset.security.manager:Creating missing datasource permissions.
Creating missing database permissions.
INFO:superset.security.manager:Creating missing database permissions.
Creating missing metrics permissions
INFO:superset.security.manager:Creating missing metrics permissions
Cleaning faulty perms
INFO:superset.security.manager:Cleaning faulty perms

是不是因为superset需要MySQL的一些权限才能在表中进行更改?

希望有人能进一步帮助我

谢谢

EN

回答 1

Stack Overflow用户

发布于 2020-10-25 07:13:19

我不知道为什么'superset db upgrade‘命令没有更新我的MYSQL数据库,但我随后手动创建了这些字段和表,现在它似乎起作用了:

代码语言:javascript
复制
slices.schema_perm
tables.schema_perm
dbs.encrypted_extra
dbs.allow_cvas
dbs.server_cert
saved_query.extra_json

以及这些带有字段的表

代码语言:javascript
复制
CREATE TABLE `alerts` (
  `id` int(11) NOT NULL,
  `label` varchar(250) DEFAULT NULL,
  `active` tinyint(2) DEFAULT NULL,
  `crontab` varchar(250) DEFAULT NULL,
  `sql` varchar(250) DEFAULT NULL,
  `alert_type` varchar(250) DEFAULT NULL,
  `recipients` varchar(250) DEFAULT NULL,
  `log_retention` varchar(250) DEFAULT NULL,
  `grace_period` varchar(250) DEFAULT NULL,
  `slice_id` int(11) DEFAULT NULL,
  `dashboard_id` int(11) DEFAULT NULL,
  `database_id` int(11) DEFAULT NULL,
  `last_eval_dttm` varchar(250) DEFAULT NULL,
  `last_state` varchar(250) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

ALTER TABLE `alerts`
  ADD PRIMARY KEY (`id`);

CREATE TABLE `tab_state` (
  `created_on` datetime DEFAULT NULL,
  `changed_on` datetime DEFAULT NULL,
  `extra_json` varchar(250) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  `label` varchar(250) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `active` tinyint(1) DEFAULT NULL,
  `database_id` int(11) NOT NULL,
  `schema` varchar(250) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `sql` varchar(250) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `query_limit` varchar(250) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `latest_query_id` int(11) NOT NULL,
  `autorun` varchar(250) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `template_params` varchar(250) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_by_fk` int(11) NOT NULL,
  `changed_by_fk` int(11) NOT NULL,
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

我不知道字段的类型,所以也许有人可以帮我找出正确的类型。

谢谢

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64506837

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档