Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 1114a42

Browse files
committed
Remove Postgres 9.4 support (#5448)
2 parents 4c2ba4e + eba7caf commit 1114a42

File tree

10 files changed

+50
-79
lines changed

10 files changed

+50
-79
lines changed

.buildkite/docker-compose.py35.pg94.yaml

Lines changed: 0 additions & 21 deletions
This file was deleted.

.buildkite/pipeline.yml

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -115,23 +115,6 @@ steps:
115115
- exit_status: 2
116116
limit: 2
117117

118-
- label: ":python: 3.5 / :postgres: 9.4"
119-
env:
120-
TRIAL_FLAGS: "-j 4"
121-
command:
122-
- "bash -c 'python -m pip install tox && python -m tox -e py35-postgres,codecov'"
123-
plugins:
124-
- docker-compose#v2.1.0:
125-
run: testenv
126-
config:
127-
- .buildkite/docker-compose.py35.pg94.yaml
128-
retry:
129-
automatic:
130-
- exit_status: -1
131-
limit: 2
132-
- exit_status: 2
133-
limit: 2
134-
135118
- label: ":python: 3.5 / :postgres: 9.5"
136119
env:
137120
TRIAL_FLAGS: "-j 4"

CONTRIBUTING.rst

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,20 @@ use github's pull request workflow to review the contribution, and either ask
3030
you to make any refinements needed or merge it and make them ourselves. The
3131
changes will then land on master when we next do a release.
3232

33-
We use `CircleCI <https://circleci.com/gh/matrix-org>`_ and `Travis CI
34-
<https://travis-ci.org/matrix-org/synapse>`_ for continuous integration. All
35-
pull requests to synapse get automatically tested by Travis and CircleCI.
36-
If your change breaks the build, this will be shown in GitHub, so please
37-
keep an eye on the pull request for feedback.
33+
We use `CircleCI <https://circleci.com/gh/matrix-org>`_ and `Buildkite
34+
<https://buildkite.com/matrix-dot-org/synapse>`_ for continuous integration.
35+
Buildkite builds need to be authorised by a maintainer. If your change breaks
36+
the build, this will be shown in GitHub, so please keep an eye on the pull
37+
request for feedback.
3838

3939
To run unit tests in a local development environment, you can use:
4040

41-
- ``tox -e py27`` (requires tox to be installed by ``pip install tox``) for
42-
SQLite-backed Synapse on Python 2.7.
43-
- ``tox -e py35`` for SQLite-backed Synapse on Python 3.5.
41+
- ``tox -e py35`` (requires tox to be installed by ``pip install tox``)
42+
for SQLite-backed Synapse on Python 3.5.
4443
- ``tox -e py36`` for SQLite-backed Synapse on Python 3.6.
45-
- ``tox -e py27-postgres`` for PostgreSQL-backed Synapse on Python 2.7
44+
- ``tox -e py36-postgres`` for PostgreSQL-backed Synapse on Python 3.6
4645
(requires a running local PostgreSQL with access to create databases).
47-
- ``./test_postgresql.sh`` for PostgreSQL-backed Synapse on Python 2.7
46+
- ``./test_postgresql.sh`` for PostgreSQL-backed Synapse on Python 3.5
4847
(requires Docker). Entirely self-contained, recommended if you don't want to
4948
set up PostgreSQL yourself.
5049

UPGRADE.rst

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,33 @@ returned by the Client-Server API:
4949
# configured on port 443.
5050
curl -kv https://<host.name>/_matrix/client/versions 2>&1 | grep "Server:"
5151
52+
Upgrading to v1.1
53+
=================
54+
55+
Synapse 1.1 removes support for older Python and PostgreSQL versions, as
56+
outlined in `our deprecation notice <https://matrix.org/blog/2019/04/08/synapse-deprecating-postgres-9-4-and-python-2-x>`_.
57+
58+
Minimum Python Version
59+
----------------------
60+
61+
Synapse v1.1 has a minimum Python requirement of Python 3.5. Python 3.6 or
62+
Python 3.7 are recommended as they have improved internal string handling,
63+
significantly reducing memory usage.
64+
65+
If you use current versions of the Matrix.org-distributed Debian packages or
66+
Docker images, action is not required.
67+
68+
If you install Synapse in a Python virtual environment, please see "Upgrading to
69+
v0.34.0" for notes on setting up a new virtualenv under Python 3.
70+
71+
Minimum PostgreSQL Version
72+
--------------------------
73+
74+
If using PostgreSQL under Synapse, you will need to use PostgreSQL 9.5 or above.
75+
Please see the
76+
`PostgreSQL documentation <https://www.postgresql.org/docs/11/upgrading.html>`_
77+
for more details on upgrading your database.
78+
5279
Upgrading to v1.0
5380
=================
5481

@@ -71,11 +98,11 @@ server in a closed federation. This can be done in one of two ways:-
7198
* Configure a whitelist of server domains to trust via ``federation_certificate_verification_whitelist``.
7299

73100
See the `sample configuration file <docs/sample_config.yaml>`_
74-
for more details on these settings.
101+
for more details on these settings.
75102

76103
Email
77104
-----
78-
When a user requests a password reset, Synapse will send an email to the
105+
When a user requests a password reset, Synapse will send an email to the
79106
user to confirm the request.
80107

81108
Previous versions of Synapse delegated the job of sending this email to an

changelog.d/5448.removal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
PostgreSQL 9.4 is no longer supported. Synapse requires Postgres 9.5+ or above for Postgres support.

docker/Dockerfile-pgtests

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
FROM matrixdotorg/sytest:latest
44

55
# The Sytest image doesn't come with python, so install that
6-
RUN apt-get -qq install -y python python-dev python-pip
6+
RUN apt-get update && apt-get -qq install -y python3 python3-dev python3-pip
77

88
# We need tox to run the tests in run_pg_tests.sh
9-
RUN pip install tox
9+
RUN python3 -m pip install tox
1010

1111
ADD run_pg_tests.sh /pg_tests.sh
1212
ENTRYPOINT /pg_tests.sh

docker/run_pg_tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ su -c '/usr/lib/postgresql/9.6/bin/pg_ctl -w -D /var/lib/postgresql/data start'
1717
# Run the tests
1818
cd /src
1919
export TRIAL_FLAGS="-j 4"
20-
tox --workdir=/tmp -e py27-postgres
20+
tox --workdir=/tmp -e py35-postgres

docs/postgres.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Using Postgres
22
--------------
33

4-
Postgres version 9.4 or later is known to work.
4+
Postgres version 9.5 or later is known to work.
55

66
Install postgres client libraries
77
=================================
@@ -16,7 +16,7 @@ a postgres database.
1616
* For other pre-built packages, please consult the documentation from the
1717
relevant package.
1818

19-
* If you installed synapse `in a virtualenv
19+
* If you installed synapse `in a virtualenv
2020
<../INSTALL.md#installing-from-source>`_, you can install the library with::
2121

2222
~/synapse/env/bin/pip install matrix-synapse[postgres]

synapse/storage/engines/postgres.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ def on_new_connection(self, db_conn):
4545
# together. For example, version 8.1.5 will be returned as 80105
4646
self._version = db_conn.server_version
4747

48+
# Are we on a supported PostgreSQL version?
49+
if self._version < 90500:
50+
raise RuntimeError("Synapse requires PostgreSQL 9.5+ or above.")
51+
4852
db_conn.set_isolation_level(
4953
self.module.extensions.ISOLATION_LEVEL_REPEATABLE_READ
5054
)
@@ -64,9 +68,9 @@ def on_new_connection(self, db_conn):
6468
@property
6569
def can_native_upsert(self):
6670
"""
67-
Can we use native UPSERTs? This requires PostgreSQL 9.5+.
71+
Can we use native UPSERTs?
6872
"""
69-
return self._version >= 90500
73+
return True
7074

7175
def is_deadlock(self, error):
7276
if isinstance(error, self.module.DatabaseError):

synapse/storage/search.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -341,29 +341,7 @@ def store_search_entries_txn(self, txn, entries):
341341
for entry in entries
342342
)
343343

344-
# inserts to a GIN index are normally batched up into a pending
345-
# list, and then all committed together once the list gets to a
346-
# certain size. The trouble with that is that postgres (pre-9.5)
347-
# uses work_mem to determine the length of the list, and work_mem
348-
# is typically very large.
349-
#
350-
# We therefore reduce work_mem while we do the insert.
351-
#
352-
# (postgres 9.5 uses the separate gin_pending_list_limit setting,
353-
# so doesn't suffer the same problem, but changing work_mem will
354-
# be harmless)
355-
#
356-
# Note that we don't need to worry about restoring it on
357-
# exception, because exceptions will cause the transaction to be
358-
# rolled back, including the effects of the SET command.
359-
#
360-
# Also: we use SET rather than SET LOCAL because there's lots of
361-
# other stuff going on in this transaction, which want to have the
362-
# normal work_mem setting.
363-
364-
txn.execute("SET work_mem='256kB'")
365344
txn.executemany(sql, args)
366-
txn.execute("RESET work_mem")
367345

368346
elif isinstance(self.database_engine, Sqlite3Engine):
369347
sql = (

0 commit comments

Comments
 (0)