Skip to content

Reload database when extracting database over it #704

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

Closed
wants to merge 19 commits into from
Closed

Reload database when extracting database over it #704

wants to merge 19 commits into from

Conversation

samuel-w
Copy link
Contributor

@samuel-w samuel-w commented Nov 7, 2020

Still clears archivemodel for some reason, need to fix that.
Edit: It happens only sometimes. Probably race condition.

Fixes #703

@samuel-w
Copy link
Contributor Author

samuel-w commented Nov 7, 2020

No race condition after all, it was caused by the bottom archive being selected which doesn't have the archive model data, creating the appearance that the archivemodel got cleared.

@samuel-w samuel-w marked this pull request as ready for review November 7, 2020 23:15
@samuel-w samuel-w marked this pull request as draft November 7, 2020 23:33
@samuel-w samuel-w marked this pull request as ready for review November 10, 2020 08:40
@samuel-w samuel-w marked this pull request as draft December 6, 2020 21:16
@samuel-w
Copy link
Contributor Author

samuel-w commented Dec 6, 2020

I think I can do this differently through renaming the db on restarting Vorta.

@codecov-io
Copy link

codecov-io commented Dec 13, 2020

Codecov Report

Merging #704 (622543e) into master (824707c) will decrease coverage by 0.24%.
The diff coverage is 34.28%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #704      +/-   ##
==========================================
- Coverage   70.32%   70.07%   -0.25%     
==========================================
  Files          56       56              
  Lines        3791     3820      +29     
==========================================
+ Hits         2666     2677      +11     
- Misses       1125     1143      +18     
Impacted Files Coverage Δ
src/vorta/__main__.py 0.00% <0.00%> (ø)
src/vorta/views/archive_tab.py 76.70% <0.00%> (-0.69%) ⬇️
src/vorta/views/main_window.py 77.10% <25.00%> (-1.29%) ⬇️
src/vorta/views/misc_tab.py 80.85% <38.46%> (-16.21%) ⬇️
src/vorta/borg/borg_thread.py 75.53% <50.00%> (-1.27%) ⬇️
src/vorta/models.py 79.61% <50.00%> (-0.59%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 824707c...622543e. Read the comment docs.

@samuel-w samuel-w changed the title Fix crash when restoring settings.db Reload database when extracting files Feb 27, 2021
@samuel-w samuel-w marked this pull request as ready for review February 27, 2021 23:22
Should always trigger on db extract, breaks if we ever change database name.
Will trigger if any filename contains "settings.db", I just don't want it to trigger every time since reloading all tabs might be slow.
@samuel-w samuel-w changed the title Reload database when extracting files Reload database when extracting database over it Feb 27, 2021
@samuel-w
Copy link
Contributor Author

Since disagreement == too heated now, are you going to merge this or should I just not bother?
This kind of stuff is why I left as a maintainer.

@m3nu
Copy link
Contributor

m3nu commented Feb 28, 2021

I wont merge this because:

  • it runs for every single line of logs, but is rarely needed. Especially for extract it’s critical to keep it fast.
  • the issue of overwriting files that are currently in use is common to pretty much every other app. You cant filter for every single possibility.

Sorry if you did the work for nothing or disagree with the above. As mentioned in the contributor docs, it’s best to discuss new features before actually coding them.

I realize that choosing features based on incomplete information will be opinionated. I dont have a better way right now. Using Github Discussions with the upvote feature is an attempt to make it more democratic.

@samuel-w
Copy link
Contributor Author

samuel-w commented Mar 1, 2021

I don't find a crash during an operation (extract) acceptable.
This only runs for extract commands only, filtering out for only settings.db. As long as settings.db is called settings.db there is no problem.

What solution do you propose to prevent crashing when extracting settings.db?

@samuel-w
Copy link
Contributor Author

samuel-w commented Mar 1, 2021

Also, during an extract, most time is taken by disk IO. CPU time is not a limiting factor.

@samuel-w
Copy link
Contributor Author

samuel-w commented Mar 1, 2021

I did an experiment, comparing speed with and without.

Setup:
200k random files, 100B size each.
Extracted to /tmp, to increase IO speed.
Time measured using python time module, time.time().
87.15 seconds with this code, 88.04 seconds without. Removing the if statement reduced speed, so the difference is most likely random error, meaning the difference is not measurable.

My conclusion is that there is very to no difference on time one if statement will do to extraction speed.

Copy link
Contributor

@m3nu m3nu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't find a crash during an operation (extract) acceptable.
This only runs for extract commands only, filtering out for only settings.db. As long as settings.db is called settings.db there is no problem.

What solution do you propose to prevent crashing when extracting settings.db?

Just don't overwrite the files of an active program. 😄 Can you remove your Chrome/Firefox profile while using it? Why would this be a feature?

@@ -252,6 +253,12 @@ def get_misc_settings():
return settings


def connect_db():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason to not have init_db() only?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bump. Is connect_db() even needed? Why not move it all to init_db()? For tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I tried to remove it and it broke the tests. I could try to change the test code, but based on past experience changing it makes things worse.

@m3nu
Copy link
Contributor

m3nu commented Mar 1, 2021

@samuel-w , I'm about to merge #898. Please help to review, if possible. This is the feature with the most feedback and most usage.

@samuel-w
Copy link
Contributor Author

samuel-w commented Mar 1, 2021

For a web browser that only really writes to a downloads folder, yes it would make sense to crash.
But for a backup program that backs up all user data, if you include the backup program's settings, it would be unacceptable to the average user. It's inconvenient to have to make a new user to restore my data.

This is not really a feature, its fixing a bug where:
I backup my entire home directory (all of my data).
I restore my home directory (all of my data).
Vorta crashes.

@m3nu
Copy link
Contributor

m3nu commented Mar 1, 2021

I backup my entire home directory (all of my data).
I restore my home directory (all of my data).
Vorta crashes.

We can't support this because you can't do a restore of your home folder while logged in. You need to log in as root, restore /home/samuel, maybe fix permissions and then log in as samuel again.

I'm sure you got it working for Vorta's DB, but what if users overwrite other files they have open?

@samuel-w
Copy link
Contributor Author

samuel-w commented Mar 1, 2021

If restoring a home folder, its typically from a blank slate, with no other programs open other than maybe a web browser and terminal.
I'd expect other programs to behave weirdly, not the program I am using to restore.
I was actually surprised that no one ran a full restore in Vorta before.

Firefox actually handles restoration well, they put each profile in a folder with a random name to prevent crashing, and read a file to determine which one to use. I could do that instead of reloading everything.

On startup:
Generate alphanumeric string
Add string to database name (settings-63f31d.db)
Save suffix to file that is read once every startup (name.txt)

On extract db:
name.txt overwritten, old db with different suffix restored, no crash since still using old db.
User instructed to restart to load old settings

@m3nu
Copy link
Contributor

m3nu commented Mar 1, 2021

Restarting isn't enough. As long as you have a desktop env going, files will be used. The steps to restore a full home folder are:

  1. Log out
  2. Log in as root or some other admin user
  3. Restore other user's home folder. Can be done with Vorta.
  4. Fix permissions if needed. macOS will do this automatically if a new user is created that already has a home folder (e.g. after restore)
  5. Log in as restored user

If you think I'm lying, please get a second opinion. We won't encourage anyone to overwrite their home folder, while logged in.

Restoring may work for a simple Linux desktop without much stuff open, but it will cause problems on macOS for sure.

Even if Firefox uses a random profile name, the backup you did before will still use the same name. They don't do it for that.

@samuel-w
Copy link
Contributor Author

samuel-w commented Mar 1, 2021

The original issue was done in Linux.
I don't want to encourage overwriting the home folder either and this doesn't do it. It just prevents a crash from overwriting settings.db. You can't "train" people by having Vorta crash, they'll just file another bug report and get annoyed at the software.
In the end, all I want to prevent is the crash from overwriting settings.db.
It might not even come from a full restore, since sometime I mess up my settings and need to restore my settings.db. Yes, I could mount my archive, copy the file, and then unmount it, but in my experience extracting one file is faster and more automated.

@m3nu
Copy link
Contributor

m3nu commented Mar 1, 2021

Sounds like this mostly solves your own problem. Problem is that eventually you will move on and then I'm stuck maintaining your code that doesn't serve anyone and that I can't remember why it's there.

Myself, I sometimes rename settings.db in case I break something, I just rename it back.

@samuel-w
Copy link
Contributor Author

samuel-w commented Mar 1, 2021

Additionally, Windows backup software does not have this issue. It just restores the data. No other accounts needed.
Also, the scenario I gave was just my scenario, clearly @aromanelli also has a use for this.

Going to repeat my point: You can't "train" people by having Vorta crash, they'll just file another bug report and get annoyed at the software.
In the end, all I want to prevent is the crash from overwriting settings.db through restoring a backup, any kind of backup. Vorta's whole point is to be a user friendly way to backup and restore data. This fulfills Vorta's purpose.

@m3nu
Copy link
Contributor

m3nu commented Mar 1, 2021

Please accept that I don't want to merge such a feature. Arguing here is very tiring and I'd rather do something productive while working on this project.

@samuel-w
Copy link
Contributor Author

samuel-w commented Mar 1, 2021

Just remember, I am a volunteer.

@samuel-w samuel-w closed this Mar 1, 2021
@aromanelli
Copy link

Please accept that I don't want to merge such a feature. Arguing here is very tiring and I'd rather do something productive while working on this project.

No disrespect, realize you are a volunteer, but you are on the wrong side of this. The whole point of Vorta is not to just make a Linux nerd's job easier, its to allow people migrating over from Windows be able to use a powerful backup/restore engine in an easy-to-use way, so that its not impossible for them to use it.

Your justifications are not valid. No developer should ever advocate for the purposeful crashing of the app and try to write it off as a training issue. To be blunt, that's just bad programming. Your program should always handle all edge-cases. Always.

Please reconsider, even if it means you have to "remember" the patch for any new work later down the line. That's part of the job description for a programmer, and I would hope that the person creating the patch would include documentation in-line to help out with any future bug fixes.

And finally, you really want to have Windows do something that Linux can't? Really?

Apologies if the above seems harsh, but like I said, you are really on the wrong side of this and are just arguing so that you do not have to do work. If you were a paid employee, that would get you fired. Since you are not paid, its totally in your sphere of control to decide what Vorta means and how it and you perceived by others.

Take care.

@Hofer-Julian
Copy link
Collaborator

Is today attack-the-maintainer-day?
You have no say in what Vorta's job is nor is it your decision what other people invest their free time in.

I know that you think you commented with best intentions, but if you want open source to improve, you'd be advised to stop.

@aromanelli
Copy link

Is today attack-the-maintainer-day?
You have no say in what Vorta's job is nor is it your decision what other people invest their free time in.

I know that you think you commented with best intentions, but if you want open source to improve, you'd be advised to stop.

We're not arguing to save our souls, but yours. Defending open source through bad decision making does not support open source. Its about making products that expands the usage of software to the masses, not justify enclosure by the elite.

NO programmer should justify the crashing of an app as a 'training issue'. Open or closed sourced.

@borgbase borgbase locked as resolved and limited conversation to collaborators Mar 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

'python3.7 killed by SIGABRT' when extracting ~/.var/app/com.borgbase.Vorta
5 participants