From 5499272d15b47187a60f55550c2db6c50b8d2d20 Mon Sep 17 00:00:00 2001 From: creme Date: Mon, 10 Feb 2025 12:00:32 +0100 Subject: [PATCH] remove old clear-state script --- usr/local/bin/synapse-clear-state.sh | 78 ---------------------------- 1 file changed, 78 deletions(-) delete mode 100755 usr/local/bin/synapse-clear-state.sh diff --git a/usr/local/bin/synapse-clear-state.sh b/usr/local/bin/synapse-clear-state.sh deleted file mode 100755 index 693c9ab..0000000 --- a/usr/local/bin/synapse-clear-state.sh +++ /dev/null @@ -1,78 +0,0 @@ -#!/bin/sh -# -# THIS SCRIPT IS REPLACED BY "matrix-compress-state.sh" -# -# you dont need to stop synapse. -# -# from: https://jo-so.de/2018-03/Matrix.html#state_groups_stateaufrumen -# -# this script used: -# https://github.com/matrix-org/rust-synapse-compress-state -# -## start task via: -# $ sudo systemd-run --nice=4 -pCPUSchedulingPolicy=batch \ -# -pIOSchedulingClass=idle --uid=matrix-synapse --collect \ -# --unit=synapse-clear-state ~/bin/synapse_clear_state -# -## watch task-log via: -# $ journalctl -Stoday -u synapse-clear-state -f -# - -set -e -u - -username='matrix' -db='matrix' -conn_str="host=localhost user=$username dbname=$db application_name=state_compress" - -### - -export RUST_BACKTRACE=short LC_ALL=C.UTF-8 - -if which time >/dev/null -then - export TIME='%E elapsed %M rss' - time=time -else - time= -fi - -cd "$(mktemp -d)" -echo "Writing SQL files to $PWD" - -if [ $# -eq 0 ] -then - set -- $(psql -X -t -A -U "$username" -c 'SELECT room_id FROM state_groups - GROUP BY room_id ORDER BY count(*)' $db) -fi - -echo 'Disabling autovacuum on state_groups_state' -psql -X -q -b -U "$username" -c 'alter table state_groups_state set (autovacuum_enabled = false);' $db - -no=0 -for room in $* -do - echo '--------------------' - echo - - sql_file=state-compress-$((no += 1)).sql - echo "Writing SQL commands to $sql_file" - - $time synapse_compress_state -t -p "$conn_str" -o "$sql_file" -r "$room" -m 1000 - if test -s "$sql_file" - then - $time psql -X -q -b -U "$username" -c '\set ON_ERROR_STOP on' -f "$sql_file" $db - else - rm "$sql_file" - fi -done - -echo 'Enabling autovacuum on state_groups_state' -psql -X -q -b -U "$username" -c 'alter table state_groups_state set (autovacuum_enabled = true);' $db - -echo 'Running VACUUM and ANALYZE for state_groups_state ...' -#$time psql -X -q -b -U "$username" -c 'VACUUM FULL ANALYZE state_groups_state' $db -$time psql -X -q -b -U "$username" -c 'REINDEX (VERBOSE) DATABASE CONCURRENTLY' $db - -echo "All SQL scripts are in $PWD" - -exit 0