question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Database clean up resulting in crash

See original GitHub issue

The problem

The database clean up results in a crash. It seems this is related to the VACUUM operations on the database. I already reinstalled Python, Flexget + all dependencies and trashed my database. But the problem persists.

Steps to reproduce:

During its normal run flexget performs a database clean up. his can also be triggered manually by the command below. Both give similar output. $ flexget database clean

flexget.log:

2016-12-30 14:44 INFO     manager       SD        Running database cleanup.
2016-12-30 14:44 INFO     db_vacuum     SD        Running VACUUM on database to improve performance and decrease db size.
2016-12-30 14:44 CRITICAL task_queue                    Database error while running a task. Attempting to recover.
2016-12-30 14:44 CRITICAL manager                       An unexpected crash has occurred. Writing crash report to /Users/me/.flexget/crash_report.2016.12.30.144427043731.log. Please verify you are running the latest version of flexget by using "flexget -V" from CLI or by using version_checker plugin at http://flexget.com/wiki/Plugins/version_checker. You are currently using version 2.8.14

crash_report.2016.12.30.144427043731.log:

2016-12-30 14:44 INFO     manager                       Running database cleanup.
2016-12-30 14:44 INFO     db_vacuum                     Running VACUUM on database to improve performance and decrease db size.
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1182, in _execute_context
    context)
  File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 469, in do_execute
    cursor.execute(statement, parameters)
sqlite3.OperationalError: cannot VACUUM from within a transaction

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

Traceback (most recent call last):
  File "/usr/local/bin/flexget", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.6/site-packages/flexget/__init__.py", line 42, in main
    manager.start()
  File "/usr/local/lib/python3.6/site-packages/flexget/manager.py", line 327, in start
    self.handle_cli()
  File "/usr/local/lib/python3.6/site-packages/flexget/manager.py", line 354, in handle_cli
    options.cli_command_callback(self, command_options)
  File "/usr/local/lib/python3.6/site-packages/flexget/plugins/cli/database.py", line 16, in do_cli
    cleanup(manager)
  File "/usr/local/lib/python3.6/site-packages/flexget/plugins/cli/database.py", line 26, in cleanup
    manager.db_cleanup(force=True)
  File "/usr/local/lib/python3.6/site-packages/flexget/manager.py", line 896, in db_cleanup
    fire_event('manager.db_cleanup', self, session)
  File "/usr/local/lib/python3.6/site-packages/flexget/event.py", line 106, in fire_event
    result = event(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/flexget/event.py", line 23, in __call__
    return self.func(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/flexget/plugins/generic/db_vacuum.py", line 22, in on_cleanup
    session.execute('VACUUM')
  File "/usr/local/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 1107, in execute
    bind, close_with_result=True).execute(clause, params or {})
  File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 945, in execute
    return meth(self, multiparams, params)
  File "/usr/local/lib/python3.6/site-packages/sqlalchemy/sql/elements.py", line 263, in _execute_on_connection
    return connection._execute_clauseelement(self, multiparams, params)
  File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1053, in _execute_clauseelement
    compiled_sql, distilled_params
  File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1189, in _execute_context
    context)
  File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1393, in _handle_dbapi_exception
    exc_info
  File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 202, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb, cause=cause)
  File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 185, in reraise
    raise value.with_traceback(tb)
  File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1182, in _execute_context
    context)
  File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 469, in do_execute
    cursor.execute(statement, parameters)
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) cannot VACUUM from within a transaction [SQL: 'VACUUM']

Additional information:

  • Flexget Version: 2.8.14
  • Python Version: Python 3.6.0
  • Installation method: pip3
  • OS and version: macOS 10.12.2

Flexget dependencies:

  • pathlib 1.0.1
  • jsonschema 2.5.1
  • pyparsing 2.1.10
  • SQLAlchemy 1.1.4
  • path.py 9.0.1
  • guessit 2.0.4
  • flask 0.12
  • flask-cors 3.0.2
  • apscheduler 3.3.1
  • cherrypy 8.6.0
  • flask-compress 1.3.2
  • terminaltables 3.1.0
  • flask-login 0.4.0
  • PyRSS2Gen 1.1
  • html5lib 0.999999999
  • requests 2.12.4
  • flask-restful 0.3.5
  • pynzb 0.1.0
  • colorclass 2.2.0
  • beautifulsoup4 4.5.1
  • jinja2 2.8.1
  • PyYAML 3.12
  • future 0.16.0
  • python-dateutil 2.6.0
  • rpyc 3.3.0
  • FeedParser 5.2.1
  • flask-restplus 0.8.6
  • Safe 0.4

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:24 (17 by maintainers)

github_iconTop GitHub Comments

1reaction
liiightcommented, Jan 8, 2017

there’s a 2.7 log too above @paranoidi

0reactions
gazpachokingcommented, Jun 4, 2017

There is a change to this behavior in python 3.6.1, perhaps we should test again.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why Do Databases Crash And What To Do About It - Zmanda
1. Low Maintenance On Pre-Deployment Scripts · 2. The Database Is On The Wrong Server · 3. Unfriendly Application and Queries · 4....
Read more >
MSDB SQL Database Maintenance and Cleanup
To clean up database backup and restore tables history, we use the sp_delete_backuphistory stored procedure. This procedure requires the oldest ...
Read more >
Here are 7 reasons for why databases will crash and why you ...
1. LOW MAINTENANCE ON PRE-DEPLOYMENT SCRIPTS – · 2. DATABASE IS ON THE WRONG SERVER – · 3. YOUR APPLICATION AND QUERIES CAN...
Read more >
WSUS Cleanup wizard keeps crashing/timing out, result
Hi all,. Everytime I try to run the cleanup wizard WSUS crashes and I need to press Reset Server Node to get it...
Read more >
LO80487: CRASH DURING "PERFORM DATABASE CACHE ...
Domino server crash running "Perform Database Cache maintenance"
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found