Remove Postgres 9.4 support (#5448)

This commit is contained in:
Amber Brown 2019-06-18 00:59:00 +10:00 committed by GitHub
parent 6840ebeef8
commit eba7caf09f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 50 additions and 79 deletions

View File

@ -1,21 +0,0 @@
version: '3.1'
services:
postgres:
image: postgres:9.4
environment:
POSTGRES_PASSWORD: postgres
testenv:
image: python:3.5
depends_on:
- postgres
env_file: .env
environment:
SYNAPSE_POSTGRES_HOST: postgres
SYNAPSE_POSTGRES_USER: postgres
SYNAPSE_POSTGRES_PASSWORD: postgres
working_dir: /app
volumes:
- ..:/app

View File

@ -116,23 +116,6 @@ steps:
- exit_status: 2 - exit_status: 2
limit: 2 limit: 2
- label: ":python: 3.5 / :postgres: 9.4"
env:
TRIAL_FLAGS: "-j 4"
command:
- "bash -c 'python -m pip install tox && python -m tox -e py35-postgres,codecov'"
plugins:
- docker-compose#v2.1.0:
run: testenv
config:
- .buildkite/docker-compose.py35.pg94.yaml
retry:
automatic:
- exit_status: -1
limit: 2
- exit_status: 2
limit: 2
- label: ":python: 3.5 / :postgres: 9.5" - label: ":python: 3.5 / :postgres: 9.5"
env: env:
TRIAL_FLAGS: "-j 4" TRIAL_FLAGS: "-j 4"

View File

@ -30,21 +30,20 @@ use github's pull request workflow to review the contribution, and either ask
you to make any refinements needed or merge it and make them ourselves. The you to make any refinements needed or merge it and make them ourselves. The
changes will then land on master when we next do a release. changes will then land on master when we next do a release.
We use `CircleCI <https://circleci.com/gh/matrix-org>`_ and `Travis CI We use `CircleCI <https://circleci.com/gh/matrix-org>`_ and `Buildkite
<https://travis-ci.org/matrix-org/synapse>`_ for continuous integration. All <https://buildkite.com/matrix-dot-org/synapse>`_ for continuous integration.
pull requests to synapse get automatically tested by Travis and CircleCI. Buildkite builds need to be authorised by a maintainer. If your change breaks
If your change breaks the build, this will be shown in GitHub, so please the build, this will be shown in GitHub, so please keep an eye on the pull
keep an eye on the pull request for feedback. request for feedback.
To run unit tests in a local development environment, you can use: To run unit tests in a local development environment, you can use:
- ``tox -e py27`` (requires tox to be installed by ``pip install tox``) for - ``tox -e py35`` (requires tox to be installed by ``pip install tox``)
SQLite-backed Synapse on Python 2.7. for SQLite-backed Synapse on Python 3.5.
- ``tox -e py35`` for SQLite-backed Synapse on Python 3.5.
- ``tox -e py36`` for SQLite-backed Synapse on Python 3.6. - ``tox -e py36`` for SQLite-backed Synapse on Python 3.6.
- ``tox -e py27-postgres`` for PostgreSQL-backed Synapse on Python 2.7 - ``tox -e py36-postgres`` for PostgreSQL-backed Synapse on Python 3.6
(requires a running local PostgreSQL with access to create databases). (requires a running local PostgreSQL with access to create databases).
- ``./test_postgresql.sh`` for PostgreSQL-backed Synapse on Python 2.7 - ``./test_postgresql.sh`` for PostgreSQL-backed Synapse on Python 3.5
(requires Docker). Entirely self-contained, recommended if you don't want to (requires Docker). Entirely self-contained, recommended if you don't want to
set up PostgreSQL yourself. set up PostgreSQL yourself.

View File

@ -49,6 +49,33 @@ returned by the Client-Server API:
# configured on port 443. # configured on port 443.
curl -kv https://<host.name>/_matrix/client/versions 2>&1 | grep "Server:" curl -kv https://<host.name>/_matrix/client/versions 2>&1 | grep "Server:"
Upgrading to v1.1
=================
Synapse 1.1 removes support for older Python and PostgreSQL versions, as
outlined in `our deprecation notice <https://matrix.org/blog/2019/04/08/synapse-deprecating-postgres-9-4-and-python-2-x>`_.
Minimum Python Version
----------------------
Synapse v1.1 has a minimum Python requirement of Python 3.5. Python 3.6 or
Python 3.7 are recommended as they have improved internal string handling,
significantly reducing memory usage.
If you use current versions of the Matrix.org-distributed Debian packages or
Docker images, action is not required.
If you install Synapse in a Python virtual environment, please see "Upgrading to
v0.34.0" for notes on setting up a new virtualenv under Python 3.
Minimum PostgreSQL Version
--------------------------
If using PostgreSQL under Synapse, you will need to use PostgreSQL 9.5 or above.
Please see the
`PostgreSQL documentation <https://www.postgresql.org/docs/11/upgrading.html>`_
for more details on upgrading your database.
Upgrading to v1.0 Upgrading to v1.0
================= =================
@ -71,11 +98,11 @@ server in a closed federation. This can be done in one of two ways:-
* Configure a whitelist of server domains to trust via ``federation_certificate_verification_whitelist``. * Configure a whitelist of server domains to trust via ``federation_certificate_verification_whitelist``.
See the `sample configuration file <docs/sample_config.yaml>`_ See the `sample configuration file <docs/sample_config.yaml>`_
for more details on these settings. for more details on these settings.
Email Email
----- -----
When a user requests a password reset, Synapse will send an email to the When a user requests a password reset, Synapse will send an email to the
user to confirm the request. user to confirm the request.
Previous versions of Synapse delegated the job of sending this email to an Previous versions of Synapse delegated the job of sending this email to an

1
changelog.d/5448.removal Normal file
View File

@ -0,0 +1 @@
PostgreSQL 9.4 is no longer supported. Synapse requires Postgres 9.5+ or above for Postgres support.

View File

@ -3,10 +3,10 @@
FROM matrixdotorg/sytest:latest FROM matrixdotorg/sytest:latest
# The Sytest image doesn't come with python, so install that # The Sytest image doesn't come with python, so install that
RUN apt-get -qq install -y python python-dev python-pip RUN apt-get update && apt-get -qq install -y python3 python3-dev python3-pip
# We need tox to run the tests in run_pg_tests.sh # We need tox to run the tests in run_pg_tests.sh
RUN pip install tox RUN python3 -m pip install tox
ADD run_pg_tests.sh /pg_tests.sh ADD run_pg_tests.sh /pg_tests.sh
ENTRYPOINT /pg_tests.sh ENTRYPOINT /pg_tests.sh

View File

@ -17,4 +17,4 @@ su -c '/usr/lib/postgresql/9.6/bin/pg_ctl -w -D /var/lib/postgresql/data start'
# Run the tests # Run the tests
cd /src cd /src
export TRIAL_FLAGS="-j 4" export TRIAL_FLAGS="-j 4"
tox --workdir=/tmp -e py27-postgres tox --workdir=/tmp -e py35-postgres

View File

@ -1,7 +1,7 @@
Using Postgres Using Postgres
-------------- --------------
Postgres version 9.4 or later is known to work. Postgres version 9.5 or later is known to work.
Install postgres client libraries Install postgres client libraries
================================= =================================
@ -16,7 +16,7 @@ a postgres database.
* For other pre-built packages, please consult the documentation from the * For other pre-built packages, please consult the documentation from the
relevant package. relevant package.
* If you installed synapse `in a virtualenv * If you installed synapse `in a virtualenv
<../INSTALL.md#installing-from-source>`_, you can install the library with:: <../INSTALL.md#installing-from-source>`_, you can install the library with::
~/synapse/env/bin/pip install matrix-synapse[postgres] ~/synapse/env/bin/pip install matrix-synapse[postgres]

View File

@ -45,6 +45,10 @@ class PostgresEngine(object):
# together. For example, version 8.1.5 will be returned as 80105 # together. For example, version 8.1.5 will be returned as 80105
self._version = db_conn.server_version self._version = db_conn.server_version
# Are we on a supported PostgreSQL version?
if self._version < 90500:
raise RuntimeError("Synapse requires PostgreSQL 9.5+ or above.")
db_conn.set_isolation_level( db_conn.set_isolation_level(
self.module.extensions.ISOLATION_LEVEL_REPEATABLE_READ self.module.extensions.ISOLATION_LEVEL_REPEATABLE_READ
) )
@ -64,9 +68,9 @@ class PostgresEngine(object):
@property @property
def can_native_upsert(self): def can_native_upsert(self):
""" """
Can we use native UPSERTs? This requires PostgreSQL 9.5+. Can we use native UPSERTs?
""" """
return self._version >= 90500 return True
def is_deadlock(self, error): def is_deadlock(self, error):
if isinstance(error, self.module.DatabaseError): if isinstance(error, self.module.DatabaseError):

View File

@ -341,29 +341,7 @@ class SearchStore(BackgroundUpdateStore):
for entry in entries for entry in entries
) )
# inserts to a GIN index are normally batched up into a pending
# list, and then all committed together once the list gets to a
# certain size. The trouble with that is that postgres (pre-9.5)
# uses work_mem to determine the length of the list, and work_mem
# is typically very large.
#
# We therefore reduce work_mem while we do the insert.
#
# (postgres 9.5 uses the separate gin_pending_list_limit setting,
# so doesn't suffer the same problem, but changing work_mem will
# be harmless)
#
# Note that we don't need to worry about restoring it on
# exception, because exceptions will cause the transaction to be
# rolled back, including the effects of the SET command.
#
# Also: we use SET rather than SET LOCAL because there's lots of
# other stuff going on in this transaction, which want to have the
# normal work_mem setting.
txn.execute("SET work_mem='256kB'")
txn.executemany(sql, args) txn.executemany(sql, args)
txn.execute("RESET work_mem")
elif isinstance(self.database_engine, Sqlite3Engine): elif isinstance(self.database_engine, Sqlite3Engine):
sql = ( sql = (