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

Database disk image is malformed #5252

Closed
devos50 opened this issue Mar 27, 2020 · 34 comments
Closed

Database disk image is malformed #5252

devos50 opened this issue Mar 27, 2020 · 34 comments
Assignees
Milestone

Comments

@devos50
Copy link
Contributor

devos50 commented Mar 27, 2020

From the error reporter (7.5.0-RC2):

Traceback (most recent call last):
File "src\tribler-gui\tribler_gui\core_manager.py", line 106, in on_received_state
RuntimeError: database disk image is malformed
--LONG TEXT--
Traceback (most recent call last):
File "src\run_tribler.py", line 95, in start_tribler
File "src\tribler-core\tribler_core\session.py", line 440, in start
File "src\tribler-core\tribler_core\session.py", line 170, in load_ipv8_overlays
File "ipv8\attestation\trustchain\community.py", line 64, in __init__
File "ipv8\attestation\trustchain\database.py", line 43, in __init__
File "ipv8\attestation\trustchain\database.py", line 419, in open
File "ipv8\database.py", line 127, in open
File "ipv8\database.py", line 162, in _initial_statements
sqlite3.DatabaseError: database disk image is malformed
--CONTEXT--
{'message': 'Task exception was never retrieved', 'exception': DatabaseError('database disk image is malformed'), 'future': <Task finished coro=<start_tribler_core.<locals>.start_tribler() done, defined at src\run_tribler.py:64> exception=DatabaseError('database disk image is malformed')>}

Related to #1993

@devos50 devos50 added this to the V7.5: core refactoring milestone Mar 27, 2020
@qstokkink
Copy link
Contributor

What should we do when the database is corrupt beyond repair? Remove it?

@ichorid
Copy link
Contributor

ichorid commented Mar 27, 2020

In this case, we should mark the database corrupted and schedule a DB check on the next startup. Ideally, we should employ DB's own mechanisms for that.

@devos50
Copy link
Contributor Author

devos50 commented Apr 1, 2020

@ichorid do we want to fix this issue in 7.5?

@ichorid
Copy link
Contributor

ichorid commented Apr 1, 2020

There were only 2 bugreports with this kind of bug in the last few months. One should put some real effort to garble their SQLite database to produce this kind of error. It is alson not trivial to recover from it later. I would mark it a low-priority and moved to backlog.

@ichorid ichorid modified the milestones: V7.5: core refactoring, Backlog Apr 1, 2020
@devos50
Copy link
Contributor Author

devos50 commented Jul 20, 2020

On our (Proxmoxed) Mac, I now have a corrupt metadata.db, which is crashing consistently a few seconds after start-up. It errors with different kind of errors actually, depending on what the interactions with the database are. For example:

Traceback (most recent call last):
  File "ipv8/taskmanager.py", line 131, in done_cb
  File "tribler_core/modules/metadata_store/community/remote_query_community.py", line 149, in on_remote_select_response
  File "tribler_core/modules/metadata_store/store.py", line 287, in process_compressed_mdblob_threaded
  File "concurrent/futures/thread.py", line 57, in run
  File "tribler_core/modules/metadata_store/store.py", line 276, in _process_blob
  File "tribler_core/modules/metadata_store/store.py", line 295, in process_compressed_mdblob
  File "tribler_core/modules/metadata_store/store.py", line 328, in process_squashed_mdblob
  File "<string>", line 2, in process_payload
  File "pony/orm/core.py", line 515, in new_func
  File "tribler_core/modules/metadata_store/store.py", line 409, in process_payload
  File "pony/orm/core.py", line 3974, in get
  File "pony/orm/core.py", line 4077, in _find_one_
  File "pony/orm/core.py", line 4136, in _find_in_db_
  File "pony/orm/core.py", line 938, in _exec_sql
  File "pony/orm/core.py", line 1805, in prepare_connection_for_query_execution
  File "pony/orm/core.py", line 1891, in flush
  File "pony/orm/core.py", line 5393, in _save_
  File "pony/orm/core.py", line 5240, in _save_created_
  File "pony/utils/utils.py", line 106, in throw
pony.orm.core.UnexpectedError: Object ChannelMetadata[new:70] cannot be stored in the database. DatabaseError: database disk image is malformed

I will save this database image.

@xoriole
Copy link
Contributor

xoriole commented Oct 21, 2020

Adding one more stack trace from the error reporter for this issue

Traceback (most recent call last):
File "src\tribler-gui\tribler_gui\core_manager.py", line 68, in on_core_finished
RuntimeError: The Tribler core has unexpectedly finished with exit code -1073741819 and status: 1!

[PID:7780] 2020-10-22 00:24:14,067 - ERROR <taskmanager:135> RemoteQueryCommunity.done_cb(): Task resulted in error: database disk image is malformed
Traceback (most recent call last):
File "lib\site-packages\pony\orm\dbapiprovider.py", line 55, in wrap_dbapi_exceptions
File "lib\site-packages\pony\orm\dbapiprovider.py", line 279, in execute
sqlite3.DatabaseError: database disk image is malformed

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "ipv8\taskmanager.py", line 131, in done_cb
File "src\tribler-core\tribler_core\modules\metadata_store\community\remote_query_community.py", line 149, in on_remote_select_response
File "src\tribler-core\tribler_core\modules\metadata_store\store.py", line 287, in process_compressed_mdblob_threaded
File "lib\concurrent\futures\thread.py", line 57, in run
File "src\tribler-core\tribler_core\modules\metadata_store\store.py", line 278, in _process_blob
File "lib\site-packages\pony\orm\core.py", line 476, in __exit__
File "lib\site-packages\pony\orm\core.py", line 490, in _commit_or_rollback
File "lib\site-packages\pony\orm\core.py", line 381, in commit
File "lib\site-packages\pony\orm\core.py", line 370, in rollback_and_reraise
File "lib\site-packages\pony\utils\utils.py", line 95, in reraise
File "lib\site-packages\pony\orm\core.py", line 379, in commit
File "lib\site-packages\pony\orm\core.py", line 1896, in flush
File "lib\site-packages\pony\orm\core.py", line 5421, in _save_
File "lib\site-packages\pony\orm\core.py", line 5330, in _save_updated_
File "lib\site-packages\pony\orm\core.py", line 949, in _exec_sql
File "lib\site-packages\pony\orm\core.py", line 1784, in reconnect
File "lib\site-packages\pony\utils\utils.py", line 95, in reraise
File "lib\site-packages\pony\orm\core.py", line 947, in _exec_sql
File "<string>", line 2, in execute
File "lib\site-packages\pony\orm\dbapiprovider.py", line 74, in wrap_dbapi_exceptions
pony.orm.dbapiprovider.DatabaseError: database disk image is malformed

(Timestamp: 1603293855257, traceback timestamp: 1603293854068)

7.5.2 7.5.3

@ichorid
Copy link
Contributor

ichorid commented Oct 22, 2020

Most probably, DB corruption is a result of interrupted/crashed DB upgrade/conversion procedure. Safety measures are disabled doing DB upgrade for speed.

@xoriole
Copy link
Contributor

xoriole commented Oct 22, 2020

Looking at the uptime and the logs
7.5.2 - 1318.8 seconds
7.5.3 - 179.57 seconds

I'm not sure if it was during upgrade

@ghost
Copy link

ghost commented Nov 3, 2020

Sentry issue: TRIBLER-3

@ichorid
Copy link
Contributor

ichorid commented Nov 3, 2020

I'll try fixing it for 7.6. @devos50 , could you please send me the corrupted DB if it is not that big?

@ichorid ichorid self-assigned this Nov 3, 2020
@devos50
Copy link
Contributor Author

devos50 commented Nov 3, 2020

@ichorid it seems that I saved that database on our server named "proxmox" and on the VM with ID 105. You can find the corrupt metadata database in the following path: /Users/tribler/tribler-failing-metadata/db/7.5/sqlite/metadata.db.

@sentry-for-tribler
Copy link

Related error, a user commented: "Even with the tribler update, tribler keeps crashing on my Mac with this error message. It has been this way for the past 4 months and the releases from then. Thanks."
Probably we need to provide an option to re-create the database from scratch for these cases

@ichorid
Copy link
Contributor

ichorid commented Nov 5, 2020

Probably we need to provide an option to re-create the database from scratch for these cases

thanks for suggestion, @sentry-for-tribler bot! 😉

Jokes aside, I'm going to add a subsystem to schedule a DB check after this kind of crashes.

@rgoshko
Copy link

rgoshko commented Nov 6, 2020

Got the same issue today when my Mac mini unexpectedly rebooted:

Traceback (most recent call last):
  File "tribler_gui/core_manager.py", line 123, in on_received_state
RuntimeError: database disk image is malformed
--LONG TEXT--
Traceback (most recent call last):
  File "pony/orm/dbapiprovider.py", line 53, in wrap_dbapi_exceptions
  File "pony/orm/dbapiprovider.py", line 269, in execute
sqlite3.DatabaseError: database disk image is malformed

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "run_tribler.py", line 81, in start_tribler
  File "tribler_core/session.py", line 425, in start
  File "tribler_core/modules/metadata_store/store.py", line 135, in __init__
  File "pony/orm/core.py", line 1138, in generate_mapping
  File "<string>", line 2, in check_tables
  File "pony/orm/core.py", line 528, in new_func
  File "pony/orm/core.py", line 1211, in check_tables
  File "pony/orm/dbschema.py", line 78, in check_tables
  File "<string>", line 2, in execute
  File "pony/orm/dbapiprovider.py", line 69, in wrap_dbapi_exceptions
pony.orm.dbapiprovider.DatabaseError: database disk image is malformed

--CONTEXT--
{'message': 'Task exception was never retrieved', 'exception': DatabaseError('database disk image is malformed'), 'future': <Task finished name='Task-1' coro=<start_tribler_core.<locals>.start_tribler() done, defined at run_tribler.py:50> exception=DatabaseError('database disk image is malformed')>}`

I am unsure which db file is "bad", in ~/.Tribler/7.5/sqlite I have the following two db files from today:

32829440 6 Nov 11:28 metadata.db 404717568 6 Nov 11:27 trustchain.db

Thanks.

@ichorid
Copy link
Contributor

ichorid commented Nov 6, 2020

@rgoshko , thanks for reporting! It is caused by metadata.db. Only that one is handled by Pony ORM in 7.5.x series.

You can try to recover it by creating a dump. Or just delete it (but you will lose your personal channel).

We will add a procedure to handle this kind of failures in 7.6.

@rgoshko
Copy link

rgoshko commented Nov 9, 2020

Thanks @ichorid , I removed the metadata.db file and I am back up and running now.

@sentry-for-tribler
Copy link

Sentry issue: TRIBLER-2F

@sentry-for-tribler
Copy link

Sentry issue: TRIBLER-55

@ichorid
Copy link
Contributor

ichorid commented Oct 12, 2021

related to #1993

@drew2a drew2a changed the title [7.5.0-RC2] database disk image is malformed Database disk image is malformed Nov 22, 2021
@sentry-for-tribler
Copy link

Sentry issue: TRIBLER-9T

@sentry-for-tribler
Copy link

Sentry issue: TRIBLER-A7

@sentry-for-tribler
Copy link

Sentry issue: TRIBLER-AE

@sentry-for-tribler
Copy link

sentry-for-tribler bot commented Mar 7, 2022

7.11:
Sentry issue: TRIBLER-DJ

@sentry-for-tribler
Copy link

Sentry issue: TRIBLER-DH

@sentry-for-tribler
Copy link

Sentry issue: TRIBLER-11R

@sentry-for-tribler
Copy link

Sentry issue: TRIBLER-15F

@sentry-for-tribler
Copy link

Sentry issue: TRIBLER-15Y

@sentry-for-tribler
Copy link

Sentry issue: TRIBLER-15X

@sentry-for-tribler
Copy link

Sentry issue: TRIBLER-15Q

Copy link

Sentry issue: TRIBLER-1EF

@kozlovsky kozlovsky modified the milestones: Backlog, 7.13.1 Nov 20, 2023
Copy link

Sentry issue: TRIBLER-1F3

Copy link

Sentry issue: TRIBLER-1F2

Copy link

Sentry issue: TRIBLER-1FE

@kozlovsky
Copy link
Contributor

Fixed in #7628

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

No branches or pull requests

7 participants