add reseting of synapse_state_compressor to purge script

This commit is contained in:
HF 2022-08-27 11:36:50 +02:00
parent b89246f73c
commit fa065cd52b

View File

@ -1,6 +1,7 @@
#!/bin/sh
# Do various clean-up tasks in matrix postgresql database
# run as cron job all 6h or so
# run with argument reset every month or every week
# URL to connect to matrix
MATRIXURL="http://localhost:8008"
@ -34,6 +35,25 @@ then
psql -t postgresql://${SQLUSER}:${SQLPASSWD}@localhost/${SQLDB} -c "insert into access_tokens(id, user_id, token, device_id, last_validated, used) values (${TOKENID}, '${ADMINID}', '${TOKEN}', 'SQLCLEANER', 1656788062940, 'f')"
fi
[ "${1}" = "reset" ] && {
# reset state_auto_compressor
echo "-- Reset rust-synapse-compress-state"
psql -t postgresql://${SQLUSER}:${SQLPASSWD}@localhost/${SQLDB} -c "drop table state_compressor_state; drop table state_compressor_progress; drop table state_compressor_total_progress;"
}
# purge events in a room - just for reference - ignore this block
# TODO provide a function that purges a room and also its state_groups
#ROOM="scTbMproDsaihhGesQ:pixelplanet.fun"
#DELURL="${MATRIXURL}/_synapse/admin/v1/purge_history/!${ROOM}"
#curl --insecure -XPOST -H "Authorization: Bearer ${TOKEN}" -H "Content-Type: application/json" -d "{\"delete_local_events\": true, \"purge_up_to_ts\": 1660340843343}" ${DELURL}
# and its status check
#DELURL="${MATRIXURL}/_synapse/admin/v1/purge_history_status/MtGGeIGbsYTqdCUF"
#curl --insecure -XGET -H "Authorization: Bearer ${TOKEN}" ${DELURL}
# Remember that if you delete a room, it's state groups are still around
# https://github.com/erikjohnston/synapse-find-unreferenced-state-groups
#exit
# -----------------------------------------------------------------
# Disable ratelimit
echo "--Disabling ratelimit for admin user ${ADMINID}..."
RATEURL="${MATRIXURL}/_synapse/admin/v1/users/${ADMINID}/override_ratelimit"
@ -90,3 +110,5 @@ time psql -t postgresql://${SQLUSER}:${SQLPASSWD}@localhost/${SQLDB} -c "SELECT
[ -n "${BASH_VERSION}" ] && set +H
psql postgresql://${SQLUSER}:${SQLPASSWD}@localhost/${SQLDB} -c "SELECT nspname || '.' || relname AS \"relation\", pg_size_pretty(pg_total_relation_size(c.oid)) AS \"total_size\" FROM pg_class c LEFT JOIN pg_namespace n ON (n.oid = c.relnamespace) WHERE nspname NOT IN ('pg_catalog', 'information_schema') AND c.relkind <> 'i' AND nspname !~ '^pg_toast' ORDER BY pg_total_relation_size(c.oid) DESC LIMIT 20;"