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

Remove Postgres 9.4 support #5448

Merged
merged 14 commits into from
Jun 17, 2019
21 changes: 0 additions & 21 deletions .buildkite/docker-compose.py35.pg94.yaml

This file was deleted.

17 changes: 0 additions & 17 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,23 +116,6 @@ steps:
- exit_status: 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"
env:
TRIAL_FLAGS: "-j 4"
Expand Down
19 changes: 9 additions & 10 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
changes will then land on master when we next do a release.

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

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
SQLite-backed Synapse on Python 2.7.
- ``tox -e py35`` for SQLite-backed Synapse on Python 3.5.
- ``tox -e py35`` (requires tox to be installed by ``pip install tox``)
for SQLite-backed Synapse on Python 3.5.
- ``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).
- ``./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
set up PostgreSQL yourself.

Expand Down
31 changes: 29 additions & 2 deletions UPGRADE.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,33 @@ returned by the Client-Server API:
# configured on port 443.
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
=================

Expand All @@ -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``.

See the `sample configuration file <docs/sample_config.yaml>`_
for more details on these settings.
for more details on these settings.

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.

Previous versions of Synapse delegated the job of sending this email to an
Expand Down
1 change: 1 addition & 0 deletions changelog.d/5448.removal
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PostgreSQL 9.4 is no longer supported. Synapse requires Postgres 9.5+ or above for Postgres support.
4 changes: 2 additions & 2 deletions docker/Dockerfile-pgtests
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
FROM matrixdotorg/sytest:latest

# 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
RUN pip install tox
RUN python3 -m pip install tox

ADD run_pg_tests.sh /pg_tests.sh
ENTRYPOINT /pg_tests.sh
2 changes: 1 addition & 1 deletion docker/run_pg_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ su -c '/usr/lib/postgresql/9.6/bin/pg_ctl -w -D /var/lib/postgresql/data start'
# Run the tests
cd /src
export TRIAL_FLAGS="-j 4"
tox --workdir=/tmp -e py27-postgres
tox --workdir=/tmp -e py35-postgres
4 changes: 2 additions & 2 deletions docs/postgres.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
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
=================================
Expand All @@ -16,7 +16,7 @@ a postgres database.
* For other pre-built packages, please consult the documentation from the
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::

~/synapse/env/bin/pip install matrix-synapse[postgres]
Expand Down
8 changes: 6 additions & 2 deletions synapse/storage/engines/postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ def on_new_connection(self, db_conn):
# together. For example, version 8.1.5 will be returned as 80105
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(
self.module.extensions.ISOLATION_LEVEL_REPEATABLE_READ
)
Expand All @@ -64,9 +68,9 @@ def on_new_connection(self, db_conn):
@property
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):
if isinstance(error, self.module.DatabaseError):
Expand Down
22 changes: 0 additions & 22 deletions synapse/storage/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,29 +341,7 @@ def store_search_entries_txn(self, txn, 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.execute("RESET work_mem")

elif isinstance(self.database_engine, Sqlite3Engine):
sql = (
Expand Down