jxxghp / MoviePilot

NAS媒体库自动化管理工具
https://wiki.movie-pilot.org
GNU General Public License v3.0
6.97k stars 839 forks source link

[错误报告]: 运行模块 出错:(sqlite3.OperationalError) database is locked #3297

Open shiliuawa opened 2 days ago

shiliuawa commented 2 days ago

确认

当前程序版本

v2.1.1

运行环境

Docker

问题类型

主程序运行问题

问题描述

资源搜索无法显示 一直卡在最后几个站点 稍等一会 有没有搜到种子都在 "正在处理..." 的位置转圈 不知道和这个有没有关系:(sqlite3.OperationalError) database is locked

发生问题时系统日志和配置文件

(Background on this error at: https://sqlalche.me/e/20/e3q8)
[parameters: ('N',)]
WHERE subscribe.state = ?]
FROM subscribe 
[SQL: SELECT subscribe.id AS subscribe_id, subscribe.name AS subscribe_name, subscribe.year AS subscribe_year, subscribe.type AS subscribe_type, subscribe.keyword AS subscribe_keyword, subscribe.tmdbid AS subscribe_tmdbid, subscribe.imdbid AS subscribe_imdbid, subscribe.tvdbid AS subscribe_tvdbid, subscribe.doubanid AS subscribe_doubanid, subscribe.bangumiid AS subscribe_bangumiid, subscribe.season AS subscribe_season, subscribe.poster AS subscribe_poster, subscribe.backdrop AS subscribe_backdrop, subscribe.vote AS subscribe_vote, subscribe.description AS subscribe_description, subscribe.filter AS subscribe_filter, subscribe.include AS subscribe_include, subscribe.exclude AS subscribe_exclude, subscribe.quality AS subscribe_quality, subscribe.resolution AS subscribe_resolution, subscribe.effect AS subscribe_effect, subscribe.total_episode AS subscribe_total_episode, subscribe.start_episode AS subscribe_start_episode, subscribe.lack_episode AS subscribe_lack_episode, subscribe.note AS subscribe_note, subscribe.state AS subscribe_state, subscribe.last_update AS subscribe_last_update, subscribe.date AS subscribe_date, subscribe.username AS subscribe_username, subscribe.sites AS subscribe_sites, subscribe.downloader AS subscribe_downloader, subscribe.best_version AS subscribe_best_version, subscribe.current_priority AS subscribe_current_priority, subscribe.save_path AS subscribe_save_path, subscribe.search_imdbid AS subscribe_search_imdbid, subscribe.manual_total_episode AS subscribe_manual_total_episode, subscribe.custom_words AS subscribe_custom_words, subscribe.media_category AS subscribe_media_category, subscribe.filter_groups AS subscribe_filter_groups 
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) database is locked
    cursor.execute(statement, parameters)
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/engine/default.py", line 941, in do_execute
    self.dialect.do_execute(
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1967, in _exec_single_context
    raise sqlalchemy_exception.with_traceback(exc_info[2]) from e
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 2355, in _handle_dbapi_exception
    self._handle_dbapi_exception(
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1986, in _exec_single_context
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
    return self._exec_single_context(
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1846, in _execute_context
          ^^^^^^^^^^^^^^^^^^^^^^
    ret = self._execute_context(
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1640, in _execute_clauseelement
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    return connection._execute_clauseelement(
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/sql/elements.py", line 515, in _execute_on_connection
           ^^^^^
    return meth(
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1418, in execute
             ^^^^^^^^^^^^^
    result = conn.execute(
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/orm/context.py", line 305, in orm_execute_statement
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    result: Result[Any] = compile_state_cls.orm_execute_statement(
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/orm/session.py", line 2247, in _execute_internal
           ^^^^^^^^^^^^^^^^^^^^^^^
    return self._execute_internal(
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/orm/session.py", line 2362, in execute
                                                  ^^^^^^^^^^^^^^^^^^^^^
    result: Union[ScalarResult[_T], Result[_T]] = self.session.execute(
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/orm/query.py", line 2827, in _iter
           ^^^^^^^^^^^^
    return self._iter().all()  # type: ignore
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/orm/query.py", line 2673, in all
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    result = db.query(Subscribe).filter(Subscribe.state == state).all()
  File "/app/app/db/models/subscribe.py", line 101, in get_by_state
             ^^^^^^^^^^^^^^^^^^^^^
    result = func(*args, **kwargs)
  File "/app/app/db/__init__.py", line 177, in wrapper
    raise err
  File "/app/app/db/__init__.py", line 179, in wrapper
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    return Subscribe.get_by_state(self._db, state)
  File "/app/app/db/subscribe_oper.py", line 72, in list
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    subscribes = self.subscribeoper.list(state)
  File "/app/app/chain/subscribe.py", line 244, in search
    job["func"](*args, **kwargs)
  File "/app/app/scheduler.py", line 338, in start
Traceback (most recent call last):

The above exception was the direct cause of the following exception:

sqlite3.OperationalError: database is locked
    cursor.execute(statement, parameters)
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/engine/default.py", line 941, in do_execute
    self.dialect.do_execute(
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1967, in _exec_single_context
(Background on this error at: https://sqlalche.me/e/20/e3q8) - Traceback (most recent call last):
[parameters: ('N',)]
WHERE subscribe.state = ?]
FROM subscribe 
[SQL: SELECT subscribe.id AS subscribe_id, subscribe.name AS subscribe_name, subscribe.year AS subscribe_year, subscribe.type AS subscribe_type, subscribe.keyword AS subscribe_keyword, subscribe.tmdbid AS subscribe_tmdbid, subscribe.imdbid AS subscribe_imdbid, subscribe.tvdbid AS subscribe_tvdbid, subscribe.doubanid AS subscribe_doubanid, subscribe.bangumiid AS subscribe_bangumiid, subscribe.season AS subscribe_season, subscribe.poster AS subscribe_poster, subscribe.backdrop AS subscribe_backdrop, subscribe.vote AS subscribe_vote, subscribe.description AS subscribe_description, subscribe.filter AS subscribe_filter, subscribe.include AS subscribe_include, subscribe.exclude AS subscribe_exclude, subscribe.quality AS subscribe_quality, subscribe.resolution AS subscribe_resolution, subscribe.effect AS subscribe_effect, subscribe.total_episode AS subscribe_total_episode, subscribe.start_episode AS subscribe_start_episode, subscribe.lack_episode AS subscribe_lack_episode, subscribe.note AS subscribe_note, subscribe.state AS subscribe_state, subscribe.last_update AS subscribe_last_update, subscribe.date AS subscribe_date, subscribe.username AS subscribe_username, subscribe.sites AS subscribe_sites, subscribe.downloader AS subscribe_downloader, subscribe.best_version AS subscribe_best_version, subscribe.current_priority AS subscribe_current_priority, subscribe.save_path AS subscribe_save_path, subscribe.search_imdbid AS subscribe_search_imdbid, subscribe.manual_total_episode AS subscribe_manual_total_episode, subscribe.custom_words AS subscribe_custom_words, subscribe.media_category AS subscribe_media_category, subscribe.filter_groups AS subscribe_filter_groups 
【ERROR】2024-12-01 19:29:10,472 - scheduler.py - 定时任务 新增订阅搜索 执行失败:(sqlite3.OperationalError) database is locked

(Background on this error at: https://sqlalche.me/e/20/e3q8)
[parameters: ('ourbits.club', 1, 0)]
 LIMIT ? OFFSET ?]
WHERE sitestatistic.domain = ?
FROM sitestatistic 
[SQL: SELECT sitestatistic.id AS sitestatistic_id, sitestatistic.domain AS sitestatistic_domain, sitestatistic.success AS sitestatistic_success, sitestatistic."fail" AS sitestatistic_fail, sitestatistic.seconds AS sitestatistic_seconds, sitestatistic.lst_state AS sitestatistic_lst_state, sitestatistic.lst_mod_date AS sitestatistic_lst_mod_date, sitestatistic.note AS sitestatistic_note 
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) database is locked
    cursor.execute(statement, parameters)
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/engine/default.py", line 941, in do_execute
    self.dialect.do_execute(
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1967, in _exec_single_context
    raise sqlalchemy_exception.with_traceback(exc_info[2]) from e
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 2355, in _handle_dbapi_exception
    self._handle_dbapi_exception(
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1986, in _exec_single_context
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
    return self._exec_single_context(
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1846, in _execute_context
          ^^^^^^^^^^^^^^^^^^^^^^
    ret = self._execute_context(
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1640, in _execute_clauseelement
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    return connection._execute_clauseelement(
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/sql/elements.py", line 515, in _execute_on_connection
           ^^^^^
    return meth(
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1418, in execute
             ^^^^^^^^^^^^^
    result = conn.execute(
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/orm/context.py", line 305, in orm_execute_statement
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    result: Result[Any] = compile_state_cls.orm_execute_statement(
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/orm/session.py", line 2247, in _execute_internal
           ^^^^^^^^^^^^^^^^^^^^^^^
    return self._execute_internal(
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/orm/session.py", line 2362, in execute
                                                  ^^^^^^^^^^^^^^^^^^^^^
    result: Union[ScalarResult[_T], Result[_T]] = self.session.execute(
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/orm/query.py", line 2827, in _iter
           ^^^^^^^^^^^^^^^^^^^^^
    return self.limit(1)._iter().first()  # type: ignore
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/orm/query.py", line 2728, in first
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    return db.query(SiteStatistic).filter(SiteStatistic.domain == domain).first()
  File "/app/app/db/models/sitestatistic.py", line 32, in get_by_domain
             ^^^^^^^^^^^^^^^^^^^^^
    result = func(*args, **kwargs)
  File "/app/app/db/__init__.py", line 177, in wrapper
    raise err
  File "/app/app/db/__init__.py", line 179, in wrapper
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    sta = SiteStatistic.get_by_domain(self._db, domain)
  File "/app/app/db/site_oper.py", line 179, in success
    SiteOper().success(domain=domain, seconds=seconds)
  File "/app/app/modules/indexer/__init__.py", line 179, in search_torrents
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    return self.search_torrents(site=site)
  File "/app/app/modules/indexer/__init__.py", line 226, in refresh_torrents
             ^^^^^^^^^^^^^^^^^^^^^
    result = func(*args, **kwargs)
  File "/app/app/chain/__init__.py", line 112, in run_module
Traceback (most recent call last):

The above exception was the direct cause of the following exception:

sqlite3.OperationalError: database is locked
    cursor.execute(statement, parameters)
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/engine/default.py", line 941, in do_execute
    self.dialect.do_execute(
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1967, in _exec_single_context
Traceback (most recent call last):
(Background on this error at: https://sqlalche.me/e/20/e3q8)
[parameters: ('ourbits.club', 1, 0)]
 LIMIT ? OFFSET ?]
WHERE sitestatistic.domain = ?
FROM sitestatistic 
[SQL: SELECT sitestatistic.id AS sitestatistic_id, sitestatistic.domain AS sitestatistic_domain, sitestatistic.success AS sitestatistic_success, sitestatistic."fail" AS sitestatistic_fail, sitestatistic.seconds AS sitestatistic_seconds, sitestatistic.lst_state AS sitestatistic_lst_state, sitestatistic.lst_mod_date AS sitestatistic_lst_mod_date, sitestatistic.note AS sitestatistic_note 
【ERROR】2024-12-01 19:29:05,169 - chain - 运行模块 IndexerModule.refresh_torrents 出错:(sqlite3.OperationalError) database is locked
【INFO】2024-12-01 19:27:55,079 - spider - 开始请求:https://ourbits.club/torrents.php
cddjr commented 2 days ago

重启mp试试看