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

Incomplete database not deleted after restore failure #4307

Open
gerryfrancis opened this issue Apr 26, 2022 · 8 comments
Open

Incomplete database not deleted after restore failure #4307

gerryfrancis opened this issue Apr 26, 2022 · 8 comments
Assignees
Labels
backup Backup transfer and 2nd device setup bug Something is not working

Comments

@gerryfrancis
Copy link
Contributor

  • Android version:
    Android 11.

  • Device:
    Fairphone FP2 (Lineage OS 18.1 build RQ3A.211001.001 from 2022-04-22).

  • Delta Chat version:
    1.29.1 (nightly built 2022-04-24).

  • Expected behavior:
    During setup: After the database restore process has failed due to insufficient disk space (OS error 28), the incompletely restored database is deleted from the device.

  • Actual behavior:
    During setup: After the database restore process has failed due to insufficient disk space (OS error 28), the incompletely restored database is not deleted from the device.

  • Steps to reproduce the problem:
    -- Restore a previously backed up database on a device with very low disk space to make the error occur.

  • Screenshots:
    N/A.

  • Logs:
    N/A.

  • Remark:
    I have no clue whether it makes a difference if a database is restored during setup or in "Preferences" in this regard.

@gerryfrancis
Copy link
Contributor Author

gerryfrancis commented Mar 14, 2023

To add: Even though the database has not been restored completely, new emails that were delivered to the Inbox before have been fetched right on, and I can see the notifications for them layed over the welcome screen. (The matter in this case was not too less disk space, of course.)

@link2xt link2xt transferred this issue from deltachat/deltachat-android Apr 4, 2023
@link2xt link2xt added the bug Something is not working label Apr 4, 2023
@link2xt
Copy link
Collaborator

link2xt commented Apr 4, 2023

This is not fixed yet, moving to the core.

@gerryfrancis
Copy link
Contributor Author

Even though the database has not been restored completely, new emails that were delivered to the Inbox before have been fetched right on, and I can see the notifications for them layed over the welcome screen.

FYI , this seems to be solved, but the core issue, this one, is still valid.

@link2xt
Copy link
Collaborator

link2xt commented Jul 25, 2023

So this is still an issue, if backup restore fails, the account with incomplete database is started anyway and user starts receiving notification even thought the backup is broken.

@flub flub added the backup Backup transfer and 2nd device setup label Jul 25, 2023
@gerryfrancis
Copy link
Contributor Author

FYI, I have stumbled over that issue once again just recently.

@iequidoo iequidoo self-assigned this Dec 3, 2023
iequidoo added a commit that referenced this issue Dec 6, 2023
This way we can't get an account with missing blobs if there's not enough disk space.

Also delete already unpacked files if all files weren't unpacked successfully. Still, there are some
minor problems remaining:
- If a db wasn't imported successfully, unpacked blobs aren't deleted because we don't know at which
  step the import failed and whether the db will reference the blobs after a restart.
- If `delete_and_reset_all_device_msgs()` fails, the whole `import_backup()` fails also, but after a
  restart delete_and_reset_all_device_msgs() isn't retried. Probably errors from it should be
  ignored at all, but let's postpone changing this for now.
iequidoo added a commit that referenced this issue Dec 6, 2023
This way we can't get an account with missing blobs if there's not enough disk space.

Also delete already unpacked files if all files weren't unpacked successfully. Still, there are some
minor problems remaining:
- If a db wasn't imported successfully, unpacked blobs aren't deleted because we don't know at which
  step the import failed and whether the db will reference the blobs after a restart.
- If `delete_and_reset_all_device_msgs()` fails, the whole `import_backup()` fails also, but after a
  restart delete_and_reset_all_device_msgs() isn't retried. Probably errors from it should be
  ignored at all, but let's postpone changing this for now.
@link2xt
Copy link
Collaborator

link2xt commented Dec 7, 2023

@iequidoo I have looked at #5086, but as there are no tests it is not clear if it is an improvement.

A fix for this issue I can imagine is to make account import/export a function of account manager, so account manager can unpack an account and only plug it into accounts.toml once it is complete. Otherwise if account import fails, an imported account folder will remain in accounts folder but can be garbage-collected, e.g. next time accounts.toml is reopened.
But then it is a large change for all the UIs and there is no way to get import events because there is no event-emitting account yet.

So "unconfigured" account probably should stay, but maybe think in terms of importing an account into a separate temporary folder and then replacing old account folder with a new one?

iequidoo added a commit that referenced this issue Dec 11, 2023
This way we can't get an account with missing blobs if there's not enough disk space.

Also delete already unpacked files if all files weren't unpacked successfully. Still, there are some
minor problems remaining:
- If a db wasn't imported successfully, unpacked blobs aren't deleted because we don't know at which
  step the import failed and whether the db will reference the blobs after a restart.
- If `delete_and_reset_all_device_msgs()` fails, the whole `import_backup()` fails also, but after a
  restart delete_and_reset_all_device_msgs() isn't retried. Probably errors from it should be
  ignored at all, but let's postpone changing this for now.
@iequidoo
Copy link
Collaborator

@iequidoo I have looked at #5086, but as there are no tests it is not clear if it is an improvement.

A fix for this issue I can imagine is to make account import/export a function of account manager, so account manager can unpack an account and only plug it into accounts.toml once it is complete. Otherwise if account import fails, an imported account folder will remain in accounts folder but can be garbage-collected, e.g. next time accounts.toml is reopened. But then it is a large change for all the UIs and there is no way to get import events because there is no event-emitting account yet.

I also thought in this direction, but it looked complicated to me and i decided just to improve the existing code. Although there are no tests yet (so it may degrade easily), i think that for now it can be useful:

  • The account manager is not used everywhere, at least not in deltachat-repl.
  • Unpacking all blobs before importing a db looks better, at least all things happen in a well-defined order.

So "unconfigured" account probably should stay, but maybe think in terms of importing an account into a separate temporary folder and then replacing old account folder with a new one?

I could try to implement this as the next step.

iequidoo added a commit that referenced this issue Jul 19, 2024
This way we can't get an account with missing blobs if there's not enough disk space.

Also delete already unpacked files if all files weren't unpacked successfully. Still, there are some
minor problems remaining:
- If a db wasn't imported successfully, unpacked blobs aren't deleted because we don't know at which
  step the import failed and whether the db will reference the blobs after a restart.
- If `delete_and_reset_all_device_msgs()` fails, the whole `import_backup()` fails also, but after a
  restart delete_and_reset_all_device_msgs() isn't retried. Probably errors from it should be
  ignored at all.
iequidoo added a commit that referenced this issue Jul 19, 2024
This way we can't get an account with missing blobs if there's not enough disk space.

Also delete already unpacked files if all files weren't unpacked successfully. Still, there are some
minor problems remaining:
- If a db wasn't imported successfully, unpacked blobs aren't deleted because we don't know at which
  step the import failed and whether the db will reference the blobs after a restart.
- If `delete_and_reset_all_device_msgs()` fails, the whole `import_backup()` fails also, but after a
  restart delete_and_reset_all_device_msgs() isn't retried. Probably errors from it should be
  ignored at all.
iequidoo added a commit that referenced this issue Jul 19, 2024
This way we can't get an account with missing blobs if there's not enough disk space.

Also delete already unpacked files if all files weren't unpacked successfully. Still, there are some
minor problems remaining:
- If a db wasn't imported successfully, unpacked blobs aren't deleted because we don't know at which
  step the import failed and whether the db will reference the blobs after a restart.
- If `delete_and_reset_all_device_msgs()` fails, the whole `import_backup()` fails also, but after a
  restart delete_and_reset_all_device_msgs() isn't retried. Probably errors from it should be
  ignored at all.
iequidoo added a commit that referenced this issue Jul 19, 2024
This way we can't get an account with missing blobs if there's not enough disk space.

Also delete already unpacked files if all files weren't unpacked successfully. Still, there are some
minor problems remaining:
- If a db wasn't imported successfully, unpacked blobs aren't deleted because we don't know at which
  step the import failed and whether the db will reference the blobs after a restart.
- If `delete_and_reset_all_device_msgs()` fails, the whole `import_backup()` fails also, but after a
  restart delete_and_reset_all_device_msgs() isn't retried. Probably errors from it should be
  ignored at all.
iequidoo added a commit that referenced this issue Jul 22, 2024
This way we can't get an account with missing blobs if there's not enough disk space.

Also delete already unpacked files if all files weren't unpacked successfully. Still, there are some
minor problems remaining:
- If a db wasn't imported successfully, unpacked blobs aren't deleted because we don't know at which
  step the import failed and whether the db will reference the blobs after a restart.
- If `delete_and_reset_all_device_msgs()` fails, the whole `import_backup()` fails also, but after a
  restart delete_and_reset_all_device_msgs() isn't retried. Probably errors from it should be
  ignored at all.
iequidoo added a commit that referenced this issue Jul 23, 2024
This way we can't get an account with missing blobs if there's not enough disk space.

Also delete already unpacked files if all files weren't unpacked successfully. Still, there are some
minor problems remaining:
- If a db wasn't imported successfully, unpacked blobs aren't deleted because we don't know at which
  step the import failed and whether the db will reference the blobs after restart.
- If `delete_and_reset_all_device_msgs()` fails, the whole `import_backup()` fails also, but after a
  restart delete_and_reset_all_device_msgs() isn't retried. Probably errors from it should be
  ignored at all.
iequidoo added a commit that referenced this issue Jul 28, 2024
This way we can't get an account with missing blobs if there's not enough disk space.

Also delete already unpacked files if all files weren't unpacked successfully. Still, there are some
minor problems remaining:
- If a db wasn't imported successfully, unpacked blobs aren't deleted because we don't know at which
  step the import failed and whether the db will reference the blobs after restart.
- If `delete_and_reset_all_device_msgs()` fails, the whole `import_backup()` fails also, but after a
  restart delete_and_reset_all_device_msgs() isn't retried. Probably errors from it should be
  ignored at all.
iequidoo added a commit that referenced this issue Jul 28, 2024
This way we can't get an account with missing blobs if there's not enough disk space.

Also delete already unpacked files if all files weren't unpacked successfully. Still, there are some
minor problems remaining:
- If a db wasn't imported successfully, unpacked blobs aren't deleted because we don't know at which
  step the import failed and whether the db will reference the blobs after restart.
- If `delete_and_reset_all_device_msgs()` fails, the whole `import_backup()` fails also, but after a
  restart delete_and_reset_all_device_msgs() isn't retried. Probably errors from it should be
  ignored at all.
@iequidoo
Copy link
Collaborator

Not sure this may be closed, now i don't understand who should call Accounts::remove_account() if a backup restoration fails. If it's the app, it should enumerate all accounts and remove unconfigured ones e.g. on startup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backup Backup transfer and 2nd device setup bug Something is not working
Projects
None yet
Development

No branches or pull requests

4 participants