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

READY: Foreground DB upgrader #4480

Merged
merged 3 commits into from
May 15, 2019
Merged

Conversation

ichorid
Copy link
Contributor

@ichorid ichorid commented May 2, 2019

This PR moves 72 -> 73(Pony) upgrader out of the background thread to be run in the foreground at Tribler startup instead.

This greatly speed-ups the process by as we can use larger batches and disable disk synchronization during the upgrade process for the newly created DB. This is safe to do, since the old DB is read-only, and the conversion process can always be started from a clean slate if power fails during the upgrade process.
Disabling sync makes the upgrade process run on an HDD as fast as on an SSD. On my machine, a 400Mb tribler.sdb is converted in less than 1 minute.

To give users some control over the process, a "skip" button along with a text indicator of the state of the upgrade process are added to the "spinning gears" screen. Pressing the button produces a confirmation dialog. Even if a user decides to skip the conversion process, their personal channel will still be converted.
upgrader

Closes #4441
Closes #4439
Closes #4440

@ichorid ichorid force-pushed the f_offline_db_upgrade branch 2 times, most recently from 11c3a25 to 9160fd2 Compare May 2, 2019 17:01
@ichorid ichorid added this to the V7.3: Gigachannels milestone May 2, 2019
@ichorid ichorid force-pushed the f_offline_db_upgrade branch 4 times, most recently from 6420df6 to dc89fb0 Compare May 3, 2019 12:32
@ichorid ichorid changed the title Foreground DB upgrader READY: Foreground DB upgrader May 3, 2019
@ichorid ichorid requested review from devos50 and xoriole May 3, 2019 12:32
@ichorid ichorid marked this pull request as ready for review May 3, 2019 12:32
Tribler/Core/Modules/restapi/events_endpoint.py Outdated Show resolved Hide resolved
Tribler/Core/Modules/restapi/upgrader_endpoint.py Outdated Show resolved Hide resolved
Tribler/Core/Modules/restapi/upgrader_endpoint.py Outdated Show resolved Hide resolved
Tribler/Core/Session.py Outdated Show resolved Hide resolved
Tribler/Core/Upgrade/db72_to_pony.py Outdated Show resolved Hide resolved
Tribler/Core/Upgrade/db72_to_pony.py Show resolved Hide resolved
Tribler/Core/Upgrade/db72_to_pony.py Show resolved Hide resolved
Tribler/Core/Upgrade/upgrade.py Show resolved Hide resolved
Tribler/Test/Core/Upgrade/test_upgrader.py Outdated Show resolved Hide resolved
TriblerGUI/tribler_window.py Outdated Show resolved Hide resolved
@ichorid ichorid changed the title READY: Foreground DB upgrader WIP: Foreground DB upgrader May 4, 2019
@ichorid ichorid force-pushed the f_offline_db_upgrade branch 3 times, most recently from 5767373 to 3334159 Compare May 6, 2019 11:55
@ichorid ichorid changed the title WIP: Foreground DB upgrader READY: Foreground DB upgrader May 6, 2019
@ichorid ichorid requested a review from devos50 May 8, 2019 07:13
@devos50
Copy link
Contributor

devos50 commented May 13, 2019

@ichorid don't forget to address this Pylint issue:

120: W0612: (unused-variable), MetadataStore.__init__.sqlite_disable_sync: Unused variable 'sqlite_disable_sync'

@ichorid ichorid changed the title READY: Foreground DB upgrader WIP: Foreground DB upgrader May 14, 2019
@ichorid
Copy link
Contributor Author

ichorid commented May 14, 2019

@ichorid don't forget to address this Pylint issue:

120: W0612: (unused-variable), MetadataStore.__init__.sqlite_disable_sync: Unused variable 'sqlite_disable_sync'

That's intentional. This is Pony's way of plugging in code on DB startup. I've added a comment on this.

This commit makes DB upgrader from 72 to 73(Pony)
run in foreground (at the "spinning gears" screen).
"Skip" button is shown on the screen during the upgrading
process. A corresponding dialog window REST endpoint are added, too.
To speed up the upgrade process, disk synchronization is disabled.
This is safe since we don't touch the original database.
@ichorid ichorid changed the title WIP: Foreground DB upgrader READY: Foreground DB upgrader May 14, 2019
from Tribler.Test.tools import trial_timeout


class TestShutdownEndpoint(AbstractApiTest):
Copy link
Contributor

Choose a reason for hiding this comment

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

Please rename this endpoint and the docstring on the method test_upgrader_skip()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice (end)point! 😉

@ichorid ichorid merged commit 92257e1 into Tribler:devel May 15, 2019
@ichorid ichorid deleted the f_offline_db_upgrade branch May 15, 2019 20:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants