From 3ca6a6db1fc53d3de1700ea416f673f7418455e7 Mon Sep 17 00:00:00 2001 From: drew2a Date: Tue, 25 Jan 2022 12:35:36 +0100 Subject: [PATCH] Add upgrade procedure --- src/tribler-core/run_tribler_upgrader.py | 11 ++- .../tools/data/upgrade_databases/pony_v13.db | Bin 0 -> 135168 bytes .../tools/data/upgrade_databases/tags_v13.db | Bin 0 -> 57344 bytes .../tribler_core/upgrade/config_converter.py | 1 + .../upgrade/tests/test_upgrader.py | 91 +++++++++++------- .../tribler_core/upgrade/upgrade.py | 52 +++++++++- 6 files changed, 116 insertions(+), 39 deletions(-) create mode 100644 src/tribler-core/tribler_core/tests/tools/data/upgrade_databases/pony_v13.db create mode 100644 src/tribler-core/tribler_core/tests/tools/data/upgrade_databases/tags_v13.db diff --git a/src/tribler-core/run_tribler_upgrader.py b/src/tribler-core/run_tribler_upgrader.py index 66adef70c7f..e88dd30de99 100755 --- a/src/tribler-core/run_tribler_upgrader.py +++ b/src/tribler-core/run_tribler_upgrader.py @@ -1,3 +1,4 @@ +import logging import signal import sys @@ -10,10 +11,13 @@ from tribler_core.upgrade.upgrade import TriblerUpgrader from tribler_core.utilities.path_util import Path +logger = logging.getLogger(__name__) + def upgrade_state_dir(root_state_dir: Path, update_status_callback=None, interrupt_upgrade_event=None): + logger.info('Upgrade state dir') # Before any upgrade, prepare a separate state directory for the update version so it does not # affect the older version state directory. This allows for safe rollback. version_history = VersionHistory(root_state_dir) @@ -21,6 +25,7 @@ def upgrade_state_dir(root_state_dir: Path, version_history.save_if_necessary() state_dir = version_history.code_version.directory if not state_dir.exists(): + logger.info('State dir does not exist. Exit upgrade procedure.') return config = TriblerConfig.load(file=state_dir / CONFIG_FILE_NAME, state_dir=state_dir, reset_config_on_error=True) @@ -37,15 +42,19 @@ def upgrade_state_dir(root_state_dir: Path, if __name__ == "__main__": - + logger.info('Run') _upgrade_interrupted_event = [] + def interrupt_upgrade(*_): + logger.info('Interrupt upgrade') _upgrade_interrupted_event.append(True) + def upgrade_interrupted(): return bool(_upgrade_interrupted_event) + signal.signal(signal.SIGINT, interrupt_upgrade) signal.signal(signal.SIGTERM, interrupt_upgrade) _root_state_dir = Path(sys.argv[1]) diff --git a/src/tribler-core/tribler_core/tests/tools/data/upgrade_databases/pony_v13.db b/src/tribler-core/tribler_core/tests/tools/data/upgrade_databases/pony_v13.db new file mode 100644 index 0000000000000000000000000000000000000000..442e0a6b2e763daab5f3d96b84a76575762c2c95 GIT binary patch literal 135168 zcmeI)Piz}keg|+;lsOVDiFO=k;y7}~qZ-n{a#nJzx>>_@DQWB_LXkE_*)aliFd|3N ztf-+(4rSRv(Nf9oUUn~w2D$ICXi>D6y)97ey+BXB>}~hl1)4ns$fdvc<`3UUGos^e z&@S;MY>P8*=KcA+|1*NuAC+v^Qnp&{J=0Y_NS#ZKjHLcbQBtW?hW=iqzrp7+eHjf7 z=x18^p7b@7djCoB47)i04ZG%Y{+p?Hr+z;1tI6Mv=O%tK@o?+Omg9C@)3pq@ZPs_K zHb1C&0qZ=V<^}MBw^yoqp{6Uv@~Zx^qMjOws#MB~ni!R;%&B6Us&-VmD9QKkr9Yo_ z&CRBjcxPh3TYm0ph2@fddeS*XQC*?Ny`)$i+7y}Y8YN26jH zZ?~S?4OL?$T-8fDiL4aXR|>28JdaqQ92BvDJ22vh)#6&A`c(Nyf6DO0?9Wqi#8kDM z_UNswY~4$zcy)K4HL1ZHX4h@;VDL8?{QYOfjtKbt74Tzo*) z$WNP1`@o_zl}br3l=-PG({6U#Rwt~IoOb)oto+fnL?a>N#3CGBbl;HVyEEzD#jrEg zcTC5zng=anru^`O74OGmI(Ok@&xyOk>omfBtWo$Es@i9{bCNtWlm5{s++Vm%_^pNswOX49@4yVeV%)wZ{7$FLhhZt??i6L))TuKE|Mq#GusYA+`xxj^}wj?Z6s zrI4wq0htQ#iOoqrRC_)_^AM$dDL!r6*=p^WogE?R$pJ|Rx5TC#25QgFO7a~__T%5pS9yI}+qL^Qy) z_bgiV?Cr+~ckFG)b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khm=$`Ec)qV?cE!nt3qtSR^1PLVw@ImX;-HbiDtdp-*- zn=0X5bG$0%6~5fll*fhA20cES3oB`!*OwRCuduh@;|1*ftyn;DyA@Z!hF?HG^VHge z0>(79Z(m5(mgcYUtR2mYS+j+d;<9$K;RrXxWbKb8X-`XRPV9~I2`s2equz41?CoQR z?*%#M4-03Hh0f0HMka3MfI42W_JhhsO{rF%6j%4&mE;>Y(!I%OQjJ!fEzrZ*{NpPL ziTS~^b9N){nby40dCBKR?bFMA#n<~Vnj8&~VN&#cIw2Vfnw{%d+jfJRrq$k?SN6A^ z*1T9kF<3iR*6nvBd3N?>S!r1mrq0&a? z=pPrWwT(ha@phv@pt7-EEI&~0*VdQ90d|h}w0VUZfJ@t}yR$+&oF#;|wPhdDAUb)3T#egFBQ(zfEOA!^7pNn5B1#4-sUib=Vv%9x%h)=4b3naJY(*DS-yY_+Y zzVJ3q(JS~I!eZ%fRihWscANHC^cG-;zU|OxCv3m0!+m4lYTGUGOY&t+lBDKML0Ody|7@KbDE-L9I;2-Jj!qNJlN%AK%>Ccx2 z?5o(r)VLkhRe$;!w4;jLAG4PVw_fZ*aXS?Wpvm;+!h%w%Dkn}a#-F|!fBJ)j(~Gfj z--^HbR_xWc78cm=|BvK-6JT%}0uX=z1Rwwb2tWV=5P$##ATUG% F{{t|md_n*K literal 0 HcmV?d00001 diff --git a/src/tribler-core/tribler_core/tests/tools/data/upgrade_databases/tags_v13.db b/src/tribler-core/tribler_core/tests/tools/data/upgrade_databases/tags_v13.db new file mode 100644 index 0000000000000000000000000000000000000000..18d8c6dd61a47861137e6f347562beb95263740b GIT binary patch literal 57344 zcmeI&&u`jh9LI6HO>hE*w2C4ha(QA2t*GgwDu=1+rG$7DDuEOnt+~u{!KJ7K6Jn2{s%kmc?>j$Kv<@othXfyj(04C=Rsy znyzclh0rujm#>_BO(#QsSewqspKAH4N!Nb-rJUXRTgz^I)wZ5({gwNctL6U4e#wc< zpV@Zi*UefcFBdT(fB*srAbw_BxgMr@*L$4k5UAOQ1 z184jj$7|R6xl-LOI<_cRkL=gNTD*ZJYE@yyH?zb;OYO=kd}?G2GoRN#cS7$?*N?9h z|9o$99H)3#v9IkbE!3ecISR*qVb{e;y?k7(pNW_DnJAt*wQ^N%er#8reYIvd9=|I~ zy4s{#b42yDQW16gXS;4!OLilE7&Tydgo3K%$gbG3>P6`%tYPnBuIVwbC;*l?t(IS%+OnG1B5PkvdYUf$bT4JT%~WJ;GYM-tyo7! z(d)X`6RYyJJWaAK@sn>pMk+#4gVKeA&6N3KZ*_v=`ALuTlwt1f>Z7xnzK#!REbQp5 z+u7;84c>W|?tGN0`%!%$;!pQ!h{@(XrDeaU9k+kN%Mga85vAbfB*srAb7->8) """ - old_db_sample = TESTS_DATA_DIR / 'upgrade_databases' / 'pony_v8.db' - old_database_path = state_dir / 'sqlite' / 'metadata.db' - shutil.copyfile(old_db_sample, old_database_path) + tags_path = state_dir / 'sqlite/tags.db' + + _copy(source_name='pony_v8.db', target=mds_path) + _copy(source_name='tags_v13.db', target=tags_path) upgrader.run() - mds = MetadataStore(old_database_path, channels_dir, trustchain_keypair) + mds = MetadataStore(mds_path, channels_dir, trustchain_keypair) db = mds._db # pylint: disable=protected-access existing_indexes = [ @@ -80,7 +94,7 @@ def test_upgrade_pony_db_complete(upgrader, channels_dir, state_dir, trustchain_ with db_session: assert mds.TorrentMetadata.select().count() == 23 assert mds.ChannelMetadata.select().count() == 2 - assert int(mds.MiscData.get(name="db_version").value) == CURRENT_DB_VERSION + assert mds.get_value("db_version") == str(CURRENT_DB_VERSION) for index_name in existing_indexes: assert list(db.execute(f'PRAGMA index_info("{index_name}")')) for index_name in removed_indexes: @@ -112,57 +126,65 @@ def test_delete_noncompliant_state(tmpdir): assert CHANNEL_DIR_NAME_LENGTH == len(pstate.get('state', 'metainfo')['info']['name']) -def test_upgrade_pony_8to10(upgrader, channels_dir, state_dir, trustchain_keypair): # pylint: disable=W0621 - old_db_sample = TESTS_DATA_DIR / 'upgrade_databases' / 'pony_v8.db' - database_path = state_dir / 'sqlite' / 'metadata.db' - shutil.copyfile(old_db_sample, database_path) +def test_upgrade_pony_8to10(upgrader, channels_dir, mds_path, trustchain_keypair): # pylint: disable=W0621 + _copy('pony_v8.db', mds_path) upgrader.upgrade_pony_db_8to10() - mds = MetadataStore(database_path, channels_dir, trustchain_keypair, check_tables=False, db_version=10) + mds = MetadataStore(mds_path, channels_dir, trustchain_keypair, check_tables=False, db_version=10) with db_session: - assert int(mds.MiscData.get(name="db_version").value) == 10 + assert mds.get_value("db_version") == '10' assert mds.ChannelNode.select().count() == 23 mds.shutdown() @pytest.mark.asyncio -async def test_upgrade_pony_10to11(upgrader, channels_dir, state_dir, trustchain_keypair): - old_db_sample = TESTS_DATA_DIR / 'upgrade_databases' / 'pony_v10.db' - database_path = state_dir / 'sqlite' / 'metadata.db' - shutil.copyfile(old_db_sample, database_path) +async def test_upgrade_pony_10to11(upgrader, channels_dir, mds_path, trustchain_keypair): + _copy('pony_v10.db', mds_path) upgrader.upgrade_pony_db_10to11() - mds = MetadataStore(database_path, channels_dir, trustchain_keypair, check_tables=False, db_version=11) + mds = MetadataStore(mds_path, channels_dir, trustchain_keypair, check_tables=False, db_version=11) with db_session: # pylint: disable=protected-access assert upgrader.column_exists_in_table(mds._db, 'TorrentState', 'self_checked') - assert int(mds.MiscData.get(name="db_version").value) == 11 + assert mds.get_value("db_version") == '11' mds.shutdown() -def test_upgrade_pony11to12(upgrader, channels_dir, state_dir, trustchain_keypair): - old_db_sample = TESTS_DATA_DIR / 'upgrade_databases' / 'pony_v11.db' - database_path = state_dir / 'sqlite' / 'metadata.db' - shutil.copyfile(old_db_sample, database_path) +def test_upgrade_pony11to12(upgrader, channels_dir, mds_path, trustchain_keypair): + _copy('pony_v11.db', mds_path) upgrader.upgrade_pony_db_11to12() - mds = MetadataStore(database_path, channels_dir, trustchain_keypair, check_tables=False, db_version=11) + mds = MetadataStore(mds_path, channels_dir, trustchain_keypair, check_tables=False, db_version=11) with db_session: # pylint: disable=protected-access assert upgrader.column_exists_in_table(mds._db, 'ChannelNode', 'json_text') assert upgrader.column_exists_in_table(mds._db, 'ChannelNode', 'binary_data') assert upgrader.column_exists_in_table(mds._db, 'ChannelNode', 'data_type') - assert int(mds.MiscData.get(name="db_version").value) == 12 + assert mds.get_value("db_version") == '12' mds.shutdown() -def test_upgrade_pony12to13(upgrader, channels_dir, state_dir, trustchain_keypair): # pylint: disable=W0621 - old_db_sample = TESTS_DATA_DIR / 'upgrade_databases' / 'pony_v12.db' - database_path = state_dir / 'sqlite' / 'metadata.db' - shutil.copyfile(old_db_sample, database_path) +def test_upgrade_pony13to14(upgrader: TriblerUpgrader, state_dir, channels_dir, trustchain_keypair, mds_path): + tags_path = state_dir / 'sqlite/tags.db' + + _copy(source_name='pony_v13.db', target=mds_path) + _copy(source_name='tags_v13.db', target=tags_path) + + upgrader.upgrade_pony_db_13to14() + mds = MetadataStore(mds_path, channels_dir, trustchain_keypair, check_tables=False) + tags = TagDatabase(str(tags_path), check_tables=False) + + with db_session: + assert upgrader.column_exists_in_table(mds._db, 'ChannelNode', 'tag_version') + assert upgrader.column_exists_in_table(tags.instance, 'TorrentTagOp', 'auto_generated') + assert mds.get_value('db_version') == '14' + + +def test_upgrade_pony12to13(upgrader, channels_dir, mds_path, trustchain_keypair): # pylint: disable=W0621 + _copy('pony_v12.db', mds_path) upgrader.upgrade_pony_db_12to13() - mds = MetadataStore(database_path, channels_dir, trustchain_keypair, check_tables=False, db_version=12) + mds = MetadataStore(mds_path, channels_dir, trustchain_keypair, check_tables=False, db_version=12) db = mds._db # pylint: disable=protected-access existing_indexes = [ @@ -187,7 +209,7 @@ def test_upgrade_pony12to13(upgrader, channels_dir, state_dir, trustchain_keypai with db_session: assert mds.TorrentMetadata.select().count() == 23 assert mds.ChannelMetadata.select().count() == 2 - assert int(mds.MiscData.get(name="db_version").value) == CURRENT_DB_VERSION + assert mds.get_value("db_version") == '13' for index_name in existing_indexes: assert list(db.execute(f'PRAGMA index_info("{index_name}")')), index_name for index_name in removed_indexes: @@ -216,13 +238,12 @@ def test_calc_progress(): @pytest.mark.asyncio -async def test_upgrade_bw_accounting_db_8to9(upgrader, channels_dir, state_dir, trustchain_keypair): - old_db_sample = TESTS_DATA_DIR / 'upgrade_databases' / 'bandwidth_v8.db' - database_path = state_dir / 'sqlite' / 'bandwidth.db' - shutil.copyfile(old_db_sample, database_path) +async def test_upgrade_bw_accounting_db_8to9(upgrader, state_dir, trustchain_keypair): + bandwidth_path = state_dir / 'sqlite/bandwidth.db' + _copy('bandwidth_v8.db', bandwidth_path) upgrader.upgrade_bw_accounting_db_8to9() - db = BandwidthDatabase(database_path, trustchain_keypair.key.pk) + db = BandwidthDatabase(bandwidth_path, trustchain_keypair.key.pk) with db_session: assert not list(select(tx for tx in db.BandwidthTransaction)) assert not list(select(item for item in db.BandwidthHistory)) diff --git a/src/tribler-core/tribler_core/upgrade/upgrade.py b/src/tribler-core/tribler_core/upgrade/upgrade.py index 834c6087208..caede9f28bd 100644 --- a/src/tribler-core/tribler_core/upgrade/upgrade.py +++ b/src/tribler-core/tribler_core/upgrade/upgrade.py @@ -2,6 +2,8 @@ import os import shutil from configparser import MissingSectionHeaderError, ParsingError +from types import SimpleNamespace +from typing import Optional from ipv8.keyvault.private.libnaclkey import LibNaCLSK @@ -17,11 +19,13 @@ sql_create_partial_index_channelnode_subscribed, sql_create_partial_index_torrentstate_last_check, ) +from tribler_core.components.tag.db.tag_db import TagDatabase from tribler_core.upgrade.config_converter import convert_config_to_tribler76 from tribler_core.upgrade.db8_to_db10 import PonyToPonyMigration, get_db_version from tribler_core.utilities.configparser import CallbackConfigParser from tribler_core.utilities.path_util import Path +# pylint: disable=protected-access def cleanup_noncompliant_channel_torrents(state_dir): logger = logging.getLogger(__name__) @@ -87,6 +91,7 @@ def run(self): """ Run the upgrader if it is enabled in the config. """ + self._logger.info('Run') self.upgrade_pony_db_8to10() self.upgrade_pony_db_10to11() @@ -94,6 +99,22 @@ def run(self): self.upgrade_bw_accounting_db_8to9() self.upgrade_pony_db_11to12() self.upgrade_pony_db_12to13() + self.upgrade_pony_db_13to14() + + def upgrade_pony_db_13to14(self): + mds_path = self.state_dir / STATEDIR_DB_DIR / 'metadata.db' + tagdb_path = self.state_dir / STATEDIR_DB_DIR / 'tags.db' + + mds = MetadataStore(mds_path, self.channels_dir, self.trustchain_keypair, disable_sync=True, + check_tables=False, db_version=13) if mds_path.exists() else None + tagdb = TagDatabase(str(tagdb_path), check_tables=False) if tagdb_path.exists() else None + + self.do_upgrade_pony_db_13to14(mds, tagdb) + + if mds: + mds.shutdown() + if tagdb: + tagdb.shutdown() def upgrade_pony_db_12to13(self): """ @@ -149,6 +170,7 @@ def upgrade_bw_accounting_db_8to9(self): database_path = self.state_dir / STATEDIR_DB_DIR / 'bandwidth.db' if not database_path.exists() or get_db_version(database_path) >= 9: return # No need to update if the database does not exist or is already updated + self._logger.info('bw8->9') db = BandwidthDatabase(database_path, self.trustchain_keypair.key.pk) # Wipe all transactions and bandwidth history @@ -183,7 +205,7 @@ def do_upgrade_pony_db_12to13(self, mds): db_version = mds.MiscData.get(name="db_version") if int(db_version.value) != from_version: return - + self._logger.info(f'{from_version}->{to_version}') db.execute('DROP INDEX IF EXISTS idx_channelnode__public_key') db.execute('DROP INDEX IF EXISTS idx_channelnode__status') db.execute('DROP INDEX IF EXISTS idx_channelnode__size') @@ -206,6 +228,29 @@ def do_upgrade_pony_db_12to13(self, mds): db_version.value = str(to_version) + def do_upgrade_pony_db_13to14(self, mds: Optional[MetadataStore], tags: Optional[TagDatabase]): + def _alter(db, table_name, column_name, column_type): + if not self.column_exists_in_table(db, table_name, column_name): + db.execute(f'ALTER TABLE "{table_name}" ADD "{column_name}" {column_type} DEFAULT 0') + + if not mds: + return + + version = SimpleNamespace(current='13', next='14') + with db_session: + db_version = mds.get_value(key='db_version') + if db_version != version.current: + return + + self._logger.info(f'{version.current}->{version.next}') + + _alter(db=mds._db, table_name='ChannelNode', column_name='tag_version', column_type='INT') + _alter(db=tags.instance, table_name='TorrentTagOp', column_name='auto_generated', column_type='BOOLEAN') + + tags.instance.commit() + mds._db.commit() + mds.set_value(key='db_version', value=version.next) + def do_upgrade_pony_db_11to12(self, mds): from_version = 11 to_version = 12 @@ -214,7 +259,7 @@ def do_upgrade_pony_db_11to12(self, mds): db_version = mds.MiscData.get(name="db_version") if int(db_version.value) != from_version: return - + self._logger.info(f'{from_version}->{to_version}') # Just in case, we skip altering table if the column is somehow already there table_name = "ChannelNode" new_columns = [("json_text", "TEXT1"), @@ -238,6 +283,7 @@ def do_upgrade_pony_db_10to11(self, mds): db_version = mds.MiscData.get(name="db_version") if int(db_version.value) != from_version: return + self._logger.info(f'{from_version}->{to_version}') # Just in case, we skip altering table if the column is somehow already there table_name = "TorrentState" @@ -260,7 +306,7 @@ def upgrade_pony_db_8to10(self): if not database_path.exists() or get_db_version(database_path) >= 10: # Either no old db exists, or the old db version is up to date - nothing to do return - + self._logger.info('8->10') # Otherwise, start upgrading self.update_status("STARTING") tmp_database_path = database_path.parent / 'metadata_upgraded.db'