Skip to content

Commit 74e0579

Browse files
committed
rust-synapse-compress-state
1 parent e51bc32 commit 74e0579

File tree

7 files changed

+187
-0
lines changed

7 files changed

+187
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ helm repo add code-tool https://code-tool.github.io/matrix-stack/
1616
1. `webhook` - for webhook from slack-compatible clients to matrix chat
1717
1. `matrix-alertmanager-receiver` - for webhook from Prometheus Alertmanager to matrix chat
1818
1. `livekit-jwt` - for LiveKit management service
19+
1. `compress-state` - experimental tools that attempt to reduce the number of rows in the state_groups_state table inside of a Synapse Postgresql database
1920

2021

2122
## Visualisation

charts/compress-state/Chart.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
apiVersion: v2
3+
name: compress-state
4+
description: Run rust-synapse-compress-state as a Kubernetes Job/CronJob
5+
type: application
6+
version: 0.0.1
7+
appVersion: "v0.1.4"
8+
sources:
9+
- https://github.com/matrix-org/rust-synapse-compress-state
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{{- define "synapse-compress-state.fullname" -}}
2+
{{ printf "%s-%s" .Release.Name "compress-state" }}
3+
{{- end }}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
{{- if .Values.cron.enabled }}
2+
apiVersion: batch/v1
3+
kind: CronJob
4+
metadata:
5+
name: {{ include "synapse-compress-state.fullname" . }}
6+
labels:
7+
app.kubernetes.io/name: synapse-compress-state
8+
app.kubernetes.io/instance: {{ .Release.Name }}
9+
annotations:
10+
argocd.argoproj.io/sync-wave: "5"
11+
spec:
12+
successfulJobsHistoryLimit: 1
13+
failedJobsHistoryLimit: 3
14+
concurrencyPolicy: Forbid
15+
schedule: {{ .Values.cron.schedule | quote }}
16+
jobTemplate:
17+
spec:
18+
activeDeadlineSeconds: {{ .Values.cron.activeDeadlineSeconds }}
19+
backoffLimit: 1
20+
parallelism: 1
21+
template:
22+
metadata:
23+
labels:
24+
app.kubernetes.io/name: synapse-compress-state
25+
app.kubernetes.io/instance: {{ .Release.Name }}
26+
annotations:
27+
argocd.argoproj.io/sync-wave: "5"
28+
spec:
29+
activeDeadlineSeconds: {{ .Values.activeDeadlineSeconds }}
30+
restartPolicy: Never
31+
containers:
32+
- name: compress
33+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.appVersion }}"
34+
imagePullPolicy: {{ .Values.image.pullPolicy }}
35+
args:
36+
- "--postgres-url=$(DATABASE_URL)"
37+
- "--chunk-size={{ .Values.cmdArgs.chunkSize }}"
38+
- "--min-state-groups={{ .Values.cmdArgs.minStateGroups }}"
39+
{{- if .Values.cmdArgs.progress }}
40+
- "--progress"
41+
{{- end }}
42+
#
43+
env:
44+
- name: DATABASE_URL
45+
valueFrom:
46+
secretKeyRef:
47+
{{- if .Values.existingSecret.name }}
48+
name: {{ .Values.existingSecret.name }}
49+
key: {{ .Values.existingSecret.databaseUrlKey }}
50+
{{- else }}
51+
name: {{ include "synapse-compress-state.fullname" . }}
52+
key: DATABASE_URL
53+
{{- end }}
54+
resources:
55+
{{ toYaml .Values.resources | nindent 16 }}
56+
{{- if .Values.nodeSelector }}
57+
nodeSelector:
58+
{{ toYaml .Values.nodeSelector | nindent 12 }}
59+
{{- end }}
60+
{{- if .Values.tolerations }}
61+
tolerations:
62+
{{ toYaml .Values.tolerations | nindent 12 }}
63+
{{- end }}
64+
{{- if .Values.affinity }}
65+
affinity:
66+
{{ toYaml .Values.affinity | nindent 12 }}
67+
{{- end }}
68+
{{- end }}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{{- if .Values.job.enabled }}
2+
apiVersion: batch/v1
3+
kind: Job
4+
metadata:
5+
name: {{ include "synapse-compress-state.fullname" . }}
6+
labels:
7+
app.kubernetes.io/name: synapse-compress-state
8+
app.kubernetes.io/instance: {{ .Release.Name }}
9+
annotations:
10+
argocd.argoproj.io/sync-wave: "5"
11+
spec:
12+
backoffLimit: {{ .Values.job.backoffLimit }}
13+
{{- if .Values.job.ttlSecondsAfterFinished }}
14+
ttlSecondsAfterFinished: {{ .Values.job.ttlSecondsAfterFinished }}
15+
{{- end }}
16+
template:
17+
metadata:
18+
labels:
19+
app.kubernetes.io/name: synapse-compress-state
20+
spec:
21+
restartPolicy: Never
22+
containers:
23+
- name: compress
24+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.appVersion }}"
25+
imagePullPolicy: {{ .Values.image.pullPolicy }}
26+
args:
27+
- "--postgres-url=$(DATABASE_URL)"
28+
- "--chunk-size={{ .Values.cmdArgs.chunkSize }}"
29+
- "--min-state-groups={{ .Values.cmdArgs.minStateGroups }}"
30+
{{- if .Values.cmdArgs.progress }}
31+
- "--progress"
32+
{{- end }}
33+
env:
34+
- name: DATABASE_URL
35+
valueFrom:
36+
secretKeyRef:
37+
{{- if .Values.existingSecret.name }}
38+
name: {{ .Values.existingSecret.name }}
39+
key: {{ .Values.existingSecret.databaseUrlKey }}
40+
{{- else }}
41+
name: {{ include "synapse-compress-state.fullname" . }}
42+
key: DATABASE_URL
43+
{{- end }}
44+
resources:
45+
{{ toYaml .Values.resources | nindent 12 }}
46+
{{- if .Values.nodeSelector }}
47+
nodeSelector:
48+
{{ toYaml .Values.nodeSelector | nindent 8 }}
49+
{{- end }}
50+
{{- if .Values.tolerations }}
51+
tolerations:
52+
{{ toYaml .Values.tolerations | nindent 8 }}
53+
{{- end }}
54+
{{- if .Values.affinity }}
55+
affinity:
56+
{{ toYaml .Values.affinity | nindent 8 }}
57+
{{- end }}
58+
{{- end }}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{{- if not .Values.existingSecret.name }}
2+
apiVersion: v1
3+
kind: Secret
4+
metadata:
5+
name: {{ include "synapse-compress-state.fullname" . }}
6+
type: Opaque
7+
data:
8+
DATABASE_URL: {{ $v | toString | b64enc }}
9+
{{- end }}

charts/compress-state/values.yaml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
enabled: false
2+
3+
image:
4+
repository: "ghcr.io/matrix-org/rust-synapse-compress-state"
5+
# tag: latest
6+
tag: "v0.1.4"
7+
pullPolicy: IfNotPresent
8+
9+
# postgresql://user:pass@localhost/synapse
10+
# or
11+
# user=postgres dbname=matrix-synapse host=/var/run/postgresql
12+
databaseUrl: ''
13+
14+
existingSecret:
15+
#name: synapse-db
16+
name: ''
17+
databaseUrlKey: database_url
18+
19+
cmdArgs:
20+
chunkSize: 500
21+
minStateGroups: 100
22+
progress: true
23+
24+
# choose one of Job or CronJob
25+
cron:
26+
enabled: false
27+
schedule: "1 4 * * *"
28+
activeDeadlineSeconds: 1000
29+
30+
# choose one of Job or CronJob
31+
job:
32+
enabled: false
33+
backoffLimit: 0
34+
ttlSecondsAfterFinished: 3600
35+
36+
resources: {}
37+
nodeSelector: {}
38+
tolerations: []
39+
affinity: {}

0 commit comments

Comments
 (0)