Open IvanBelyakoff opened 1 year ago
We should also check for available disk space on password change. It's the same process.
@jrainville it it something for your team?
IMO we could improve the error message here to inform the user of how much disk space the app needs to complete the re-encryption.
We currently have the following re-encryption flows that could fail:
@jrainville it it something for your team?
Could be us or wallet. Or Alex since he has experience with DB re-encryption
cc @jrainville @alexjba
I made some tests. Found an old shared-account
, which was v3-encrypted.
I think it's not worth now to fix this issue.
2*(<file.db>.size()
, but that's just an estimation. The worst case that's possible here is that we successfully re-encrypt the main DB, but fail to re-encrypt the wallet DB. Then the DBs will end up in conflict state. But:
Disk full
error is unlikely in this case, because main DB is usually larger than the wallet DB.Input:
Some commands I used for testing on MacOS:
# Create an file with 8 millions of blocks with 1k bytes block size, i.e. ~8Gb.
# There's a simpler command `mkfile`, but it doesn't occupy any actual space on disk.
> dd if=/dev/zero of=temp_1m bs=1k count=8m seek=0
# Check free space on disk
> df -H
# Check file space occupied on disk
du -sh <filename>
> df -H
Filesystem Size Used Avail Capacity iused ifree %iused Mounted on
/dev/disk3s1s1 995G 15G 76M 100% 387k 739k 34% /
NO SPACE LEFT ON DEVICE
.One or more databases not created
ERR 2024-04-04 13:04:36.435+01:00 error: topics="accounts-service" tid=1526368 file=service.nim:656 procName=verifyDatabasePassword errDesription="One or more databases not created"
DBG 2024-04-04 13:04:36.437+01:00 Account logged in topics="accounts-service" tid=1526368 file=service.nim:676
failed to open db failed to set `journal_mode` pragma: disk I/O error: no space left on device
ERROR[04-04|13:04:36.868|github.com/status-im/status-go/mobile/status.go:236] failed to update node config fleet key-uid=0x6c1dbb3634e25a69cea733f9c9051a9aeda6019a432b1031cd326a7b9fed2a4e error="Failed to migrate db file: Failed to migrate v3 db to v4: failed to set `journal_mode` pragma: disk I/O error: no space left on device"
ERR 2024-04-04 13:04:36.869+01:00 node.login topics="signals-manager" tid=1526368 file=signals_manager.nim:54 error="Failed to migrate db file: Failed to migrate v3 db to v4: failed to set `journal_mode` pragma: disk I/O error: no space left on device"
ERR 2024-04-04 13:04:36.869+01:00 login error topics="app-controller" tid=1526368 file=module.nim:458 methodName=onNodeLogin errDesription="Failed to migrate db file: Failed to migrate v3 db to v4: failed to set `journal_mode` pragma: disk I/O error: no space left on device"
> dd if=/dev/zero of=temp_1m bs=1k count=8m seek=0
8388608+0 records in
8388608+0 records out
8589934592 bytes transferred in 63.340697 secs (135614778 bytes/sec)
> df -H
Filesystem Size Used Avail Capacity iused ifree %iused Mounted on
/dev/disk3s1s1 995G 15G 2081M 88% 387k 20M 2% /
DATABASE OR DISK FULL
DBG 2024-04-04 13:08:36.577+01:00 primary_action topics="app-controller" tid=1526368 file=module.nim:207 currFlow=AppLogin currState=LoginKeycardEnterPassword
One or more databases not created
ERR 2024-04-04 13:08:36.585+01:00 error: topics="accounts-service" tid=1526368 file=service.nim:656 procName=verifyDatabasePassword errDesription="One or more databases not created"
DBG 2024-04-04 13:08:36.585+01:00 Account logged in topics="accounts-service" tid=1526368 file=service.nim:676
ERROR[04-04|13:09:07.985|github.com/status-im/status-go/mobile/status.go:236] failed to update node config fleet key-uid=0x6c1dbb3634e25a69cea733f9c9051a9aeda6019a432b1031cd326a7b9fed2a4e error="Failed to migrate db file: Failed to migrate v3 db to v4: database or disk is full"
ERR 2024-04-04 13:09:07.997+01:00 node.login topics="signals-manager" tid=1526368 file=signals_manager.nim:54 error="Failed to migrate db file: Failed to migrate v3 db to v4: database or disk is full"
ERR 2024-04-04 13:09:07.998+01:00 login error topics="app-controller" tid=1526368 file=module.nim:458 methodName=onNodeLogin errDesription="Failed to migrate db file: Failed to migrate v3 db to v4: database or disk is full"
Free up space.
> df -H
Filesystem Size Used Avail Capacity iused ifree %iused Mounted on
/dev/disk3s1s1 995G 15G 11G 59% 387k 104M 0% /
Nice investigation!
I think it's not worth now to fix this issue.
I agree with you! It's ok since the error message is saying there's no disk space (If the user is not intimidated by the first part of the error). Maybe we can work in that direction and improve the message.
BTW, we have the same flows on password change. That might happen more often than the migration, but we should see a similar error there.
I moved this to 2.30 and reduced the priority, since the problem is only visual and does not corrupt the DBs
Starting 0.13 for the first time caused "re-encryption" to happen, which failed at the end due to insufficient disk space.
Description
We should pre-calculate the available disk space to be sufficient before starting DB migration/re-encryption and not proceed until enough space.