Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"DatabaseError: database disk image is malformed" after Tribler was terminated during the upgrade process #7002

Closed
kozlovsky opened this issue Aug 17, 2022 · 1 comment

Comments

@kozlovsky
Copy link
Contributor

When a new version of Tribler copies data files from a folder for a previous version (like, "7.11" -> "7.12"), the process of copying is not atomic. If Tribler is terminated during that process, the database file can be in a half-copied state.

If Tribler is launched after it was terminated during the file copying, the Tribler sees that the new state folder is already present and tries to use it. That results in the following error:

ErrorHandler.gui_error(): Traceback (most recent call last):
  File "C:\dev\tribler\src\tribler\gui\upgrade_manager.py", line 34, in run
    self._upgrade_state_dir(
  File "C:\dev\tribler\src\tribler\run_tribler_upgrader.py", line 40, in upgrade_state_dir
    upgrader.run()
  File "C:\dev\tribler\src\tribler\core\upgrade\upgrade.py", line 95, in run
    self.upgrade_pony_db_8to10()
  File "C:\dev\tribler\src\tribler\core\upgrade\upgrade.py", line 307, in upgrade_pony_db_8to10
    if not database_path.exists() or get_db_version(database_path) >= 10:
  File "C:\dev\tribler\src\tribler\core\upgrade\db8_to_db10.py", line 247, in get_db_version
    cursor.execute('SELECT value FROM MiscData WHERE name == "db_version"')
sqlite3.DatabaseError: database disk image is malformed

To prevent this type of error, the process of copying files to a new state folder should be atomic - files should be copied to a folder with a temporal name, and then the folder should be renamed to the proper name after all files are copied successfully.

@kozlovsky
Copy link
Contributor Author

Fixed in #7055

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

1 participant