From bbc0f59801ac8845e684148d0956b5c4c86f39e2 Mon Sep 17 00:00:00 2001 From: Varik Matevosyan Date: Thu, 21 Nov 2024 14:20:41 +0400 Subject: [PATCH] clean up db before running pg_upgrade --- model/lantern/lantern_server.rb | 34 ++++++++++++++++++- prog/lantern/lantern_server_nexus.rb | 17 ++++++---- rhizome/lantern/bin/exec_all | 2 +- rhizome/lantern/bin/setup_ssl | 2 +- rhizome/lantern/lib/common.rb | 11 +++--- spec/model/lantern/lantern_server_spec.rb | 9 ++++- .../prog/lantern/lantern_server_nexus_spec.rb | 10 ++++-- 7 files changed, 67 insertions(+), 18 deletions(-) diff --git a/model/lantern/lantern_server.rb b/model/lantern/lantern_server.rb index c08136002..121d3f57a 100644 --- a/model/lantern/lantern_server.rb +++ b/model/lantern/lantern_server.rb @@ -242,7 +242,7 @@ def prewarm_indexes_query end def list_all_databases - vm.sshable.cmd("sudo docker compose -f #{Config.compose_file} exec postgresql psql -U postgres -P \"footer=off\" -c 'SELECT datname from pg_database' | tail -n +3 | grep -v 'template0' | grep -v 'template1'") + vm.sshable.cmd("sudo docker compose -f #{Config.compose_file} exec postgresql psql -U postgres -t -c 'SELECT datname FROM pg_database WHERE datistemplate=FALSE'") .chomp .strip .split("\n") @@ -302,6 +302,38 @@ def start_container vm.sshable.cmd("sudo docker compose -f #{Config.compose_file} up -d") end + def prepare_database_for_upgrade + # drop lantern_extras extension because it has breaking binary changes + # drop all indexes which does not have `dim` specified in params or are old external indexes + # which use _experimental_index_path param + commands = < {"lantern_version" => "0.5.0", "extras_version" => "0.5.0", "minor_version" => "1", "pg_version" => 17}} expect(nx.strand).to receive(:stack).and_return([frame]).at_least(:once) expect(lantern_server).to receive(:container_image).and_return(image).at_least(:once) - expect(lantern_server.resource).to receive(:drop_ddl_log_trigger) + expect(lantern_server).to receive(:prepare_database_for_upgrade) expect(lantern_server.vm.sshable).to receive(:cmd).with("common/bin/daemonizer 'sudo lantern/bin/run_pg_upgrade' pg_upgrade", stdin: JSON.generate( container_image: lantern_server.container_image, pg_version: 17,