解决HUE报错MultipleObjectsReturned: get() returned more than one Document2 -- it returned 2!

表现:界面上报错:,刚登陆进去就能看到,点击执行也会出现。日志里报:

Traceback (most recent call last):
  File "/home/work/hue-3.10.0/desktop/libs/notebook/src/notebook/decorators.py", line 81, in decorator
    return func(*args, **kwargs)
  File "/home/work/hue-3.10.0/desktop/libs/notebook/src/notebook/api.py", line 124, in execute
    history = _historify(notebook, request.user)
  File "/home/work/hue-3.10.0/desktop/libs/notebook/src/notebook/api.py", line 319, in _historify
    is_history=True
  File "/home/work/hue-3.10.0/build/env/local/lib/python2.7/site-packages/Django-1.6.10-py2.7.egg/django/db/models/manager.py", line 157, in create
    return self.get_queryset().create(**kwargs)
  File "/home/work/hue-3.10.0/build/env/local/lib/python2.7/site-packages/Django-1.6.10-py2.7.egg/django/db/models/query.py", line 322, in create
    obj.save(force_insert=True, using=self.db)
  File "/home/work/hue-3.10.0/desktop/core/src/desktop/models.py", line 1138, in save
    home_dir = Document2.objects.get_home_directory(self.owner)
  File "/home/work/hue-3.10.0/desktop/core/src/desktop/models.py", line 935, in get_home_directory
    return self.get(owner=user, parent_directory=None, name=Document2.HOME_DIR, type=‘directory‘)
  File "/home/work/hue-3.10.0/build/env/local/lib/python2.7/site-packages/Django-1.6.10-py2.7.egg/django/db/models/manager.py", line 151, in get
    return self.get_queryset().get(*args, **kwargs)
  File "/home/work/hue-3.10.0/build/env/local/lib/python2.7/site-packages/Django-1.6.10-py2.7.egg/django/db/models/query.py", line 313, in get
    (self.model._meta.object_name, num))
MultipleObjectsReturned: get() returned more than one Document2 -- it returned 2!

复现步骤:已账号xxxx登录hue,即可看到异常.

ps: 有人在官网报此问题,http://gethue.com/how-to-fix-the-multipleobjectsreturned-error-in-hue/  但官方没有给出解决方法.

根据stacktrace: File "/home/work/hue-3.10.0/desktop/core/src/desktop/models.py", line 935, in get_home_directory查到代码:

  def get_home_directory(self, user):
    try:
      return self.get(owner=user, parent_directory=None, name=Document2.HOME_DIR, type=‘directory‘)
    except Document2.DoesNotExist:
      return self.create_user_directories(user)

是class Document2Manager的方法,怀疑是用户表中存的用户记录多了一条,所以查到两个home directory,查了auth_user表和useradmin_userprofile表,都正常。后又查表desktop_document2,按self.get()中的查询条件果然查到两行:

查别的正常账号,只有一条,解决方法应该是删掉多余的数据即可。

由于此表有个自连接的外键:CONSTRAINT `parent_directory_id_refs_id_4fe2babf` FOREIGN KEY (`parent_directory_id`) REFERENCES `desktop_document2` (`id`), 应先删除衍生数据,再删除根数据:

delete from desktop_document2 where parent_directory_id=7;

delete from desktop_document2 where id=7;

之后测试,果然解决。

为何会产生两条数据,原因未知。

时间: 2024-11-05 02:34:13

解决HUE报错MultipleObjectsReturned: get() returned more than one Document2 -- it returned 2!的相关文章

解决hue报错:timed out (code THRIFTSOCKET): None

报错栈: [15/Jun/2017 19:25:15 +0800] decorators ERROR error running <function execute at 0x7fba2804ecf8> Traceback (most recent call last): File "/home/work/hue-3.10.0/desktop/libs/notebook/src/notebook/decorators.py", line 81, in decorator r

git:Git fetch和git pull的区别, 解决Git报错:error: You have not concluded your merge (MERGE_HEAD exists).

Git fetch和git pull的区别, 解决Git报错:error: You have not concluded your merge (MERGE_HEAD exists). 解决办法一:保留本地的更改,中止合并->重新合并->重新拉取 $:git merge --abort $:git reset --merge $:git pull 解决办法二:舍弃本地代码,远端版本覆盖本地版本(慎重) $:git fetch --all $:git reset --hard origin/ma

解决tomcat报错javax.imageio.IIOException: Can&#39;t create output stream!

启动tomcat catalina.out报错如下,登陆的时候无法显示验证码 2017-06-09 11:23:06,628 DEBUG org.springframework.web.servlet.DispatcherServlet 845 - DispatcherServlet with name 'spring-mvc' processing GET request for [/data-analysis/kaptchaImage.do]2017-06-09 11:23:06,629 D

系统调优:如何解决系统报错too many open files瓶颈

一.检查系统版本是否手工升级 [[email protected] ~]# uname -r   linux的内核版本号 2.6.32-358.el6.x86_64 [[email protected] ~]# cat /proc/version Linux version 2.6.32-358.el6.x86_64  [[email protected] ~]# cat /etc/issue  系统安装时默认的发行版本 CentOS release 6.4 (Final) [[email pr

解决mysql报错:- Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column &#39;information_schema.PROFILING.SEQ&#39;

mysql执行报错: - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'information_schema.PROFILING.SEQ' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_fu

解决yum报错:UnicodeDecodeError: &#39;ascii&#39; codec can&#39;t decode ... ordinal not in range

在使用yum部署环境的时候,出现了报错: UnicodeDecodeError: 'ascii' codec can't decode ... ordinal not in range 解决办法: [[email protected] ~]# ll /var/lib/rpm/*db*-rw-r--r-- 1 root root 73728 Aug 15 14:52 /var/lib/rpm/__db.001-rw-r--r-- 1 root root 270336 Aug 15 14:52 /v

解决Git报错:error: You have not concluded your merge (MERGE_HEAD exists).

Git fetch和git pull的区别, 解决Git报错:error: You have not concluded your merge (MERGE_HEAD exists). 2017年02月22日 20:38:28 阅读数:19178 Git fetch和git pull的区别: 都可以从远程获取最新版本到本地 1.Git fetch:只是从远程获取最新版本到本地,不会merge(合并) $:git fetch origin master //从远程的origin的master主分支

解决 sqlalchemy 报错:(1193, &quot;Unknown system variable &#39;tx_isolation&#39;&quot;)

1出现此报错的原因是使用的mysql8.0 以前用的是:tx_isolation 现在用是: transaction_isolation a.通过升级 sqlalchemy 的方法可以解决此问题, pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --upgrade sqlalchemy --ignore-installed(亲测有效————) b.通过降低,mysql 版本来解决这个问题. 解决 sqlalchemy 报错:(119

解决MySql报错:1130 - Host &#39;xxx&#39; is not allowed to connect to this MySQL server的方法

发现问题 使用Navicat连接MySql数据库时,未能成功,提示信息如下图: 这个错误提示已经很明确了,"不允许主机'desktop-teat9ob'连接到此mysql服务器",知道问题所在就好解决了. 解决办法 我们远程联接到MySql服务器,打开服务器本地Navicat软件,在查询编辑器中执行下面的SQL语句 #查询允许连接的主机及用户信息 select Host,User,Password from mysql.user; 结果如下图: 从结果中可以看到,MySql只允许使用r