更新索引报错,请问是什么问题,有遇到的吗


#1

参考文档设置索引https://cloud.seafile.com/published/seafile-manual-cn/deploy_pro/details_about_file_search.md

系统是centos7.4
seafile版本是7.1.5企业试用版
纯净系统安装
使用新建的seafile用户运行的程序

运行更新索引的命令 ./pro/pro.py search --update
会打印出
Updating search index, this may take a while…

03/19/2021 19:28:38 [INFO] seafes:208 main: storage: using filesystem storage backend
03/19/2021 19:28:38 [INFO] seafes:210 main: index office pdf: True
03/19/2021 19:28:38 [INFO] seafes:161 start_index_local: Index process initialized.
03/19/2021 19:28:38 [INFO] seafes:46 run: starting worker0 worker threads for indexing
03/19/2021 19:28:38 [INFO] seafes:46 run: starting worker1 worker threads for indexing
03/19/2021 19:28:40 [INFO] seafes:84 update_repo: Updating repo ce4533b2-384d-40fa-84f3-86887d54108a
03/19/2021 19:28:40 [INFO] seafes:84 update_repo: Updating repo 2d5612be-ac3b-4310-8194-42a30a92ad99
03/19/2021 19:28:40 [DEBUG] seafes:86 update_repo: latest_commit_id: 96408a0cf2081e1dfad6215ecf92930598104f45, status.from_commit: None
03/19/2021 19:28:40 [DEBUG] seafes:86 update_repo: latest_commit_id: 4b89aa85589b8d8a8bd40dd9b8d109acacee9d40, status.from_commit: None
03/19/2021 19:28:41 [ERROR] seafes:92 get_repo_name_mtime_size: Could not locate column in row for column 'items'
03/19/2021 19:28:41 [ERROR] seafes:92 get_repo_name_mtime_size: Could not locate column in row for column 'items'
03/19/2021 19:28:41 [ERROR] seafes:116 thread_task: Index Repo Error: 2d5612be-ac3b-4310-8194-42a30a92ad99
Traceback (most recent call last):
  File "/opt/seafile/seafile-pro-server-7.1.5/pro/python/seafes/repo_data/__init__.py", line 90, in get_repo_name_mtime_size
    return self._get_repo_name_mtime_size(repo_id)
  File "/opt/seafile/seafile-pro-server-7.1.5/pro/python/seafes/repo_data/__init__.py", line 84, in _get_repo_name_mtime_size
    raise e
  File "/opt/seafile/seafile-pro-server-7.1.5/pro/python/seafes/repo_data/__init__.py", line 82, in _get_repo_name_mtime_size
    return self.to_dict(res)
  File "/opt/seafile/seafile-pro-server-7.1.5/pro/python/seafes/repo_data/__init__.py", line 17, in to_dict
    res.append(dict(list(i.items())))
AttributeError: Could not locate column in row for column 'items'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/seafile/seafile-pro-server-7.1.5/pro/python/seafes/index_local.py", line 105, in thread_task
    self.fileindexupdater.update_repo(repo_id, commit_id)
  File "/opt/seafile/seafile-pro-server-7.1.5/pro/python/seafes/file_index_updater.py", line 90, in update_repo
    self.update_files_index(repo_id, old, new)
  File "/opt/seafile/seafile-pro-server-7.1.5/pro/python/seafes/file_index_updater.py", line 48, in update_files_index
    self.files_index.update_repo_name_index(repo_id, version, new_root)
  File "/opt/seafile/seafile-pro-server-7.1.5/pro/python/seafes/indexes/repo_files.py", line 172, in update_repo_name_index
    if not repo_data.get_repo_name_mtime_size(repo_id):
  File "/opt/seafile/seafile-pro-server-7.1.5/pro/python/seafes/repo_data/__init__.py", line 93, in get_repo_name_mtime_size
    return self._get_repo_name_mtime_size(repo_id)
  File "/opt/seafile/seafile-pro-server-7.1.5/pro/python/seafes/repo_data/__init__.py", line 84, in _get_repo_name_mtime_size
    raise e
  File "/opt/seafile/seafile-pro-server-7.1.5/pro/python/seafes/repo_data/__init__.py", line 82, in _get_repo_name_mtime_size
    return self.to_dict(res)
  File "/opt/seafile/seafile-pro-server-7.1.5/pro/python/seafes/repo_data/__init__.py", line 17, in to_dict
    res.append(dict(list(i.items())))
AttributeError: Could not locate column in row for column 'items'
03/19/2021 19:28:41 [ERROR] seafes:116 thread_task: Index Repo Error: ce4533b2-384d-40fa-84f3-86887d54108a
Traceback (most recent call last):
  File "/opt/seafile/seafile-pro-server-7.1.5/pro/python/seafes/repo_data/__init__.py", line 90, in get_repo_name_mtime_size
    return self._get_repo_name_mtime_size(repo_id)
  File "/opt/seafile/seafile-pro-server-7.1.5/pro/python/seafes/repo_data/__init__.py", line 84, in _get_repo_name_mtime_size
    raise e
  File "/opt/seafile/seafile-pro-server-7.1.5/pro/python/seafes/repo_data/__init__.py", line 82, in _get_repo_name_mtime_size
    return self.to_dict(res)
  File "/opt/seafile/seafile-pro-server-7.1.5/pro/python/seafes/repo_data/__init__.py", line 17, in to_dict
    res.append(dict(list(i.items())))
AttributeError: Could not locate column in row for column 'items'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/seafile/seafile-pro-server-7.1.5/pro/python/seafes/index_local.py", line 105, in thread_task
    self.fileindexupdater.update_repo(repo_id, commit_id)
  File "/opt/seafile/seafile-pro-server-7.1.5/pro/python/seafes/file_index_updater.py", line 90, in update_repo
    self.update_files_index(repo_id, old, new)
  File "/opt/seafile/seafile-pro-server-7.1.5/pro/python/seafes/file_index_updater.py", line 48, in update_files_index
    self.files_index.update_repo_name_index(repo_id, version, new_root)
  File "/opt/seafile/seafile-pro-server-7.1.5/pro/python/seafes/indexes/repo_files.py", line 172, in update_repo_name_index
    if not repo_data.get_repo_name_mtime_size(repo_id):
  File "/opt/seafile/seafile-pro-server-7.1.5/pro/python/seafes/repo_data/__init__.py", line 93, in get_repo_name_mtime_size
    return self._get_repo_name_mtime_size(repo_id)
  File "/opt/seafile/seafile-pro-server-7.1.5/pro/python/seafes/repo_data/__init__.py", line 84, in _get_repo_name_mtime_size
    raise e
  File "/opt/seafile/seafile-pro-server-7.1.5/pro/python/seafes/repo_data/__init__.py", line 82, in _get_repo_name_mtime_size
    return self.to_dict(res)
  File "/opt/seafile/seafile-pro-server-7.1.5/pro/python/seafes/repo_data/__init__.py", line 17, in to_dict
    res.append(dict(list(i.items())))
AttributeError: Could not locate column in row for column 'items'
03/19/2021 19:28:41 [DEBUG] seafes:96 thread_task: Queue is empty, worker0 worker threads stop
03/19/2021 19:28:41 [DEBUG] seafes:96 thread_task: Queue is empty, worker1 worker threads stop
03/19/2021 19:28:41 [INFO] seafes:122 thread_task: worker0 worker updated at 2021-03-19 19:28 time
03/19/2021 19:28:41 [INFO] seafes:122 thread_task: worker1 worker updated at 2021-03-19 19:28 time
03/19/2021 19:28:41 [INFO] seafes:127 thread_task: worker0 worker get 2 error
03/19/2021 19:28:41 [INFO] seafes:127 thread_task: worker1 worker get 2 error
03/19/2021 19:28:41 [INFO] seafes:38 clear_worker: All worker threads has stopped.
03/19/2021 19:28:41 [INFO] seafes:72 run: index updated, total time 2.2503256797790527 seconds
03/19/2021 19:28:41 [INFO] seafes:131 clear_deleted_repo: start to clear deleted repo
03/19/2021 19:28:41 [INFO] seafes:135 clear_deleted_repo: 0 repos need to be deleted.
03/19/2021 19:28:41 [INFO] seafes:139 clear_deleted_repo: deleted repo has been cleared
03/19/2021 19:28:41 [INFO] seafes:164 start_index_local: 

Index updated, statistic report:

03/19/2021 19:28:41 [INFO] seafes:165 start_index_local: [commit read] 2
03/19/2021 19:28:41 [INFO] seafes:166 start_index_local: [dir read]    0
03/19/2021 19:28:41 [INFO] seafes:167 start_index_local: [file read]   0
03/19/2021 19:28:41 [INFO] seafes:168 start_index_local: [block read]  0

索引也不生效,搜索不到东西。
这是什么问题,有遇到的吗


#2

看一下elasticsearch.log 有没有报错


#3

elasticsearch.log 没有报错,有几个警告解决了,还是没用。并且一段时间后普通用户无法运行seahub.sh脚本,会提示pkill: killing pid 2600 failed: Operation not permitted
,很奇怪,刚刚搭建好事没问题的。重装了很多遍一样的问题


#4

我也遇到了这个问题,翻了源码,修改了一下,目前功能可用了。

代码路径:{seafile目录}/seafile-pro-server-8.0.0/pro/python/seafes/repo_data/ __init __.py

import logging
from sqlalchemy.sql import text

from seafes.config import seafes_config
from seafes.repo_data.db import init_db_session_class

logger = logging.getLogger('seafes')


class RepoData(object):
    def __init__(self):
        self.db_session = init_db_session_class(seafes_config.seafile_conf)

    def to_dict(self, keys, result_proxy):
        res = []
        for i in result_proxy:
            res.append(dict(zip(keys, i)))
        return res

    def _get_repo_id_commit_id(self, start, count):
        session = self.db_session()
        try:
            cmd = """SELECT repo_id, commit_id
                     FROM Branch WHERE name = :name
                     AND repo_id NOT IN (SELECT repo_id from VirtualRepo)
                     limit :start, :count"""
            res = [(r['repo_id'], r['commit_id']) for r in session.execute(text(cmd),
                                                                      {'name': 'master',
                                                                       'start': start,
                                                                       'count': count})]
            return res
        except Exception as e:
            raise e
        finally:
            session.close()


    def _get_all_trash_repo_list(self):
        session = self.db_session()
        try:
            cmd = """SELECT repo_id, repo_name, head_id, owner_id, 
            size, org_id, del_time FROM RepoTrash ORDER BY del_time DESC"""
            res = session.execute(text(cmd))
            keys = ['repo_id', 'repo_name', 'head_id', 'owner_id', 'size', 'org_id', 'del_time']
            return self.to_dict(keys, res)
        except Exception as e:
            raise e
        finally:
            session.close()

    def _get_all_repo_list(self):
        session = self.db_session()
        try:
            cmd = """SELECT r.repo_id, c.file_count FROM Repo r LEFT JOIN RepoFileCount c
            ON r.repo_id = c.repo_id"""
            res = session.execute(text(cmd))
            keys = ['repo_id', 'file_count']
            return self.to_dict(keys, res)
        except Exception as e:
            raise e
        finally:
            session.close()

    def _get_repo_head_commit(self, repo_id):
        session = self.db_session()
        try:
            cmd = """SELECT b.commit_id
                     from Branch as b inner join Repo as r
                     where b.repo_id=r.repo_id and b.repo_id=:repo_id"""
            res = session.execute(text(cmd), {'repo_id': repo_id}).fetchone()
            return res[0] if res else None
        except Exception as e:
            raise e
        finally:
            session.close()

    def _get_repo_name_mtime_size(self, repo_id):
        session = self.db_session()
        try:
            cmd = """SELECT RepoInfo.name, RepoInfo.update_time, RepoSize.size
                     FROM RepoInfo INNER JOIN RepoSize ON RepoInfo.repo_id = RepoSize.repo_id
                     AND RepoInfo.repo_id = :repo_id"""

            res = session.execute(text(cmd), {'repo_id': repo_id})
            keys = ['name', 'update_time', 'size']

            return self.to_dict(keys, res)
        except Exception as e:
            raise e
        finally:
            session.close()

    def get_repo_name_mtime_size(self, repo_id):
        try:
            return self._get_repo_name_mtime_size(repo_id)
        except Exception as e:
            logger.error(e)
            return self._get_repo_name_mtime_size(repo_id)

    def get_all_repo_list(self):
        try:
            return self._get_all_repo_list()
        except Exception as e:
            logger.error(e)
            return self._get_all_repo_list()

    def get_all_trash_repo_list(self):
        try:
            return self._get_all_trash_repo_list()
        except Exception as e:
            logger.error(e)
            return self._get_all_trash_repo_list()

    def get_repo_id_commit_id(self, start, count):
        try:
            return self._get_repo_id_commit_id(start, count)
        except Exception as e:
            logger.error(e)
            return self._get_repo_id_commit_id(start, count)

    def get_repo_head_commit(self, repo_id):
        try:
            return self._get_repo_head_commit(repo_id)
        except Exception as e:
            logger.error(e)
            return self._get_repo_head_commit(repo_id)


repo_data = RepoData()

用上述文件替换掉原有内容,应该就可以建立索引了。
修改前记得备份原有文件!!!!