Matrix Docker Ansible eploy
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

54 lines
1.4 KiB

  1. {#
  2. SPDX-FileCopyrightText: 2024 MDAD Team and contributors
  3. SPDX-License-Identifier: AGPL-3.0-or-later
  4. #}
  5. #jinja2: lstrip_blocks: "True"
  6. #!/bin/bash
  7. # this script is used to workaround the https://github.com/matrix-org/rust-synapse-compress-state/issues/78,
  8. # and it is based on postgres' cli-non-interactive and https://github.com/matrix-org/rust-synapse-compress-state/issues/78#issuecomment-1409932869
  9. docker run \
  10. --rm \
  11. --user={{ matrix_synapse_auto_compressor_uid }}:{{ matrix_synapse_auto_compressor_gid }} \
  12. --cap-drop=ALL \
  13. --interactive \
  14. --network={{ matrix_synapse_auto_compressor_container_network }} \
  15. --env-file={{ matrix_synapse_auto_compressor_base_path }}/env \
  16. {{ matrix_synapse_auto_compressor_postgres_image }} \
  17. psql -h {{ matrix_synapse_auto_compressor_database_hostname }} \
  18. <<_EOF
  19. BEGIN;
  20. DELETE
  21. FROM state_compressor_state AS scs
  22. WHERE NOT EXISTS
  23. (SELECT *
  24. FROM rooms AS r
  25. WHERE r.room_id = scs.room_id);
  26. DELETE
  27. FROM state_compressor_state AS scs
  28. WHERE scs.room_id in
  29. (SELECT DISTINCT room_id
  30. FROM state_compressor_state AS scs2
  31. WHERE scs2.current_head IS NOT NULL
  32. AND NOT EXISTS
  33. (SELECT *
  34. FROM state_groups AS sg
  35. WHERE sg.id = scs2.current_head));
  36. DELETE
  37. FROM state_compressor_progress AS scp
  38. WHERE NOT EXISTS
  39. (SELECT *
  40. FROM state_compressor_state AS scs
  41. WHERE scs.room_id = scp.room_id);
  42. COMMIT;
  43. _EOF
  44. # vim: ft=sh