Chia-Network / chia-blockchain

Chia blockchain python implementation (full node, farmer, harvester, timelord, and wallet)
Apache License 2.0
10.82k stars 2.03k forks source link

[Bug] Chia-cli upgraded to 2.1.2 = sqlite3.DatabaseError: database disk image is malformed #16609

Closed TCB13 closed 1 year ago

TCB13 commented 1 year ago

What happened?

I upgraded my system Debian 11 to v2.1.2 via apt upgrade and how it seems to be broken. After starting the wallet I get errors like this:

2023-10-12T20:04:56.651 full_node full_node_server        : ERROR    Exception: database disk image is malformed <class 'sqlite3.DatabaseError'>, closing connection PeerInfo(_ip=IPv4Address('93.176.187.111'), _port=8444). Traceback (most recent call last):
  File "chia/server/ws_connection.py", line 422, in _api_call
  File "asyncio/tasks.py", line 408, in wait_for
  File "chia/server/ws_connection.py", line 401, in wrapped_coroutine
  File "chia/full_node/full_node_api.py", line 136, in new_peak
  File "chia/full_node/full_node.py", line 729, in new_peak
  File "chia/full_node/full_node.py", line 590, in short_sync_batch
  File "chia/full_node/full_node.py", line 1414, in peak_post_processing
  File "chia/full_node/hint_store.py", line 46, in add_hints
  File "aiosqlite/core.py", line 216, in executemany
  File "aiosqlite/core.py", line 133, in _execute
  File "aiosqlite/core.py", line 106, in run
sqlite3.DatabaseError: database disk image is malformed

Tried to upgrade the DB, doesn't fix the issue:

~# chia db upgrade
conversion failed with error: output file is the same as the input /mnt/ssd/.chia/mainnet/db/blockchain_v2_mainnet.sqlite.

LEAVING PREVIOUS DB FILE UNTOUCHED /mnt/ssd/.chia/mainnet/db/blockchain_v2_mainnet.sqlite

Thanks.

Version

2.1.2

What platform are you using?

Linux

What ui mode are you using?

CLI

Relevant log output

No response

BrandtH22 commented 1 year ago

Hey @TCB13 , it appears the database is corrupt meaning you would either need to resync from scratch or use the official db snapshot torrent.

Since resyncing from scratch takes time here are the instructions for the torrent:

1. Download the torrent file from https://www.chia.net/downloads/#database-checkpoint
2. Use a torrent client to download the full db
3. Unpack/reassemble the torrent file that was downloaded (on windows I used 7zip, Mac and linux have built in tools that work for this)
4. Move the db to the correct folder (~\.chia\mainnet\db\) and update the name to "blockchain_v2_mainnet.sqlite" (removing the date information in the name)
5. Verify the config file (~\.chia\mainnet\config\config.yaml) has the correct value under the full_node section for `database_path: db/blockchain_v2_CHALLENGE.sqlite` (should only need to change the v1 to v2)
6. Launch chia and wait for a bit (the height to hash and peers files need to be built so this can take 5-10 minutes)
TCB13 commented 1 year ago

Hey @TCB13 , it appears the database is corrupt meaning you would either need to resync from scratch or use the official db snapshot torrent.

Yes it is corrupt indeed. Thanks for the tip. And now here am I downloading a 68 GB torrent that was made a week and an half ago.... More time / bandwidth / delays.

[#05b2fb 6.6GiB/68GiB(9%) CN:45 SD:30 DL:2.7MiB UL:30KiB(30MiB) ETA:6h24m35s]

I've noticed there are more people complaining about this same issue, how and why did this happen?

Why is it that chia upgrades break our setups often? This is the second time my database got screwed during upgrades. I've also experienced weird glitches such as having to restating the thing multiple times so it would run properly and countless dependency errors (before the apt repository).

Maybe it's just that it's completely unreasonable to implement a cryptocurrency in the joke of a language that Python is? Maybe it's about the fact that the leadership is more interested in bullshit like NFTs than in fixing the "core product".

I would really love to read an explanation from the project leadership because next time a screw up like this happens I'll most likely abandon the project and repurpose the storage for things that are actually useful.

wjblanke commented 1 year ago

We use sqlite for the managing the database. Our code doesn't influence how it handles bad shutdowns, etc. If it says the db is corrupted there isn't much we can do about it other than provide the db torrent. You can also make your own backups periodically. You should also check on the health of your drive.

TCB13 commented 1 year ago

We use sqlite for the managing the database. Our code doesn't influence how it handles bad shutdowns, etc. If it says the db is corrupted there isn't much we can do about it other than provide the db torrent. You can also make your own backups periodically. You should also check on the health of your drive.

That's bullshit, there were no bad shutdowns. I simply stopped the entire thing, upgraded via apt upgrade and this happened right after. I'm not the only one with this issue with this update. At least 4 other similar issues were open.

This upgrade corrupted the DB for multiple people, that's what happened here.