diff --git a/CHANGES.md b/CHANGES.md
index f1a9d58e4d..22684420a4 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,3 +1,62 @@
+Synapse 0.99.2rc1 (2019-02-27)
+==============================
+
+Features
+--------
+
+- Added an HAProxy example in the reverse proxy documentation. Contributed by Benoît S. (“Benpro”). ([\#4541](https://github.com/matrix-org/synapse/issues/4541))
+- Add basic optional sentry integration. ([\#4632](https://github.com/matrix-org/synapse/issues/4632), [\#4694](https://github.com/matrix-org/synapse/issues/4694))
+- Transfer bans on room upgrade. ([\#4642](https://github.com/matrix-org/synapse/issues/4642))
+- Add configurable room list publishing rules. ([\#4647](https://github.com/matrix-org/synapse/issues/4647))
+- Support .well-known delegation when issuing certificates through ACME. ([\#4652](https://github.com/matrix-org/synapse/issues/4652))
+- Allow registration and login to be handled by a worker instance. ([\#4666](https://github.com/matrix-org/synapse/issues/4666), [\#4670](https://github.com/matrix-org/synapse/issues/4670), [\#4682](https://github.com/matrix-org/synapse/issues/4682))
+- Reduce the overhead of creating outbound federation connections over TLS by caching the TLS client options. ([\#4674](https://github.com/matrix-org/synapse/issues/4674))
+- Add prometheus metrics for number of outgoing EDUs, by type. ([\#4695](https://github.com/matrix-org/synapse/issues/4695))
+- Return correct error code when inviting a remote user to a room whose homeserver does not support the room version. ([\#4721](https://github.com/matrix-org/synapse/issues/4721))
+- Prevent showing rooms to other servers that were set to not federate. ([\#4746](https://github.com/matrix-org/synapse/issues/4746))
+
+
+Bugfixes
+--------
+
+- Fix possible exception when paginating. ([\#4263](https://github.com/matrix-org/synapse/issues/4263))
+- The dependency checker now correctly reports a version mismatch for optional
+ dependencies, instead of reporting the dependency missing. ([\#4450](https://github.com/matrix-org/synapse/issues/4450))
+- Set CORS headers on .well-known requests. ([\#4651](https://github.com/matrix-org/synapse/issues/4651))
+- Fix kicking guest users on guest access revocation in worker mode. ([\#4667](https://github.com/matrix-org/synapse/issues/4667))
+- Fix an issue in the database migration script where the
+ `e2e_room_keys.is_verified` column wasn't considered as
+ a boolean. ([\#4680](https://github.com/matrix-org/synapse/issues/4680))
+- Fix TaskStopped exceptions in logs when outbound requests time out. ([\#4690](https://github.com/matrix-org/synapse/issues/4690))
+- Fix ACME config for python 2. ([\#4717](https://github.com/matrix-org/synapse/issues/4717))
+- Fix paginating over federation persisting incorrect state. ([\#4718](https://github.com/matrix-org/synapse/issues/4718))
+
+
+Internal Changes
+----------------
+
+- Run `black` to reformat user directory code. ([\#4635](https://github.com/matrix-org/synapse/issues/4635))
+- Reduce number of exceptions we log. ([\#4643](https://github.com/matrix-org/synapse/issues/4643), [\#4668](https://github.com/matrix-org/synapse/issues/4668))
+- Introduce upsert batching functionality in the database layer. ([\#4644](https://github.com/matrix-org/synapse/issues/4644))
+- Fix various spelling mistakes. ([\#4657](https://github.com/matrix-org/synapse/issues/4657))
+- Cleanup request exception logging. ([\#4669](https://github.com/matrix-org/synapse/issues/4669), [\#4737](https://github.com/matrix-org/synapse/issues/4737), [\#4738](https://github.com/matrix-org/synapse/issues/4738))
+- Improve replication performance by reducing cache invalidation traffic. ([\#4671](https://github.com/matrix-org/synapse/issues/4671), [\#4715](https://github.com/matrix-org/synapse/issues/4715), [\#4748](https://github.com/matrix-org/synapse/issues/4748))
+- Test against Postgres 9.5 as well as 9.4. ([\#4676](https://github.com/matrix-org/synapse/issues/4676))
+- Run unit tests against python 3.7. ([\#4677](https://github.com/matrix-org/synapse/issues/4677))
+- Attempt to clarify installation instructions/config. ([\#4681](https://github.com/matrix-org/synapse/issues/4681))
+- Clean up gitignores. ([\#4688](https://github.com/matrix-org/synapse/issues/4688))
+- Minor tweaks to acme docs. ([\#4689](https://github.com/matrix-org/synapse/issues/4689))
+- Improve the logging in the pusher process. ([\#4691](https://github.com/matrix-org/synapse/issues/4691))
+- Better checks on newsfragments. ([\#4698](https://github.com/matrix-org/synapse/issues/4698), [\#4750](https://github.com/matrix-org/synapse/issues/4750))
+- Avoid some redundant work when processing read receipts. ([\#4706](https://github.com/matrix-org/synapse/issues/4706))
+- Run `push_receipts_to_remotes` as background job. ([\#4707](https://github.com/matrix-org/synapse/issues/4707))
+- Add prometheus metrics for number of badge update pushes. ([\#4709](https://github.com/matrix-org/synapse/issues/4709))
+- Reduce pusher logging on startup ([\#4716](https://github.com/matrix-org/synapse/issues/4716))
+- Don't log exceptions when failing to fetch remote server keys. ([\#4722](https://github.com/matrix-org/synapse/issues/4722))
+- Correctly proxy exception in frontend_proxy worker. ([\#4723](https://github.com/matrix-org/synapse/issues/4723))
+- Add database version to phonehome stats. ([\#4753](https://github.com/matrix-org/synapse/issues/4753))
+
+
Synapse 0.99.1.1 (2019-02-14)
=============================
diff --git a/changelog.d/4263.bugfix b/changelog.d/4263.bugfix
deleted file mode 100644
index 3dc1d7c732..0000000000
--- a/changelog.d/4263.bugfix
+++ /dev/null
@@ -1 +0,0 @@
-Prevent crash on pagination.
diff --git a/changelog.d/4450.bugfix b/changelog.d/4450.bugfix
deleted file mode 100644
index b194e94c15..0000000000
--- a/changelog.d/4450.bugfix
+++ /dev/null
@@ -1,2 +0,0 @@
-The dependency checker now correctly reports a version mismatch for optional
-dependencies, instead of reporting the dependency missing.
diff --git a/changelog.d/4541.feature b/changelog.d/4541.feature
deleted file mode 100644
index 1d0e7bdfdc..0000000000
--- a/changelog.d/4541.feature
+++ /dev/null
@@ -1 +0,0 @@
-Added an HAProxy example in the reverse proxy documentation. Contributed by Benoît S. (“Benpro”).
diff --git a/changelog.d/4632.feature b/changelog.d/4632.feature
deleted file mode 100644
index d053ab5a25..0000000000
--- a/changelog.d/4632.feature
+++ /dev/null
@@ -1 +0,0 @@
-Add basic optional sentry integration
diff --git a/changelog.d/4635.misc b/changelog.d/4635.misc
deleted file mode 100644
index 0f45957b84..0000000000
--- a/changelog.d/4635.misc
+++ /dev/null
@@ -1 +0,0 @@
-Run `black` to reformat user directory code.
diff --git a/changelog.d/4642.feature b/changelog.d/4642.feature
deleted file mode 100644
index bfbf95bcbb..0000000000
--- a/changelog.d/4642.feature
+++ /dev/null
@@ -1 +0,0 @@
-Transfer bans on room upgrade.
\ No newline at end of file
diff --git a/changelog.d/4643.misc b/changelog.d/4643.misc
deleted file mode 100644
index 556cdd2240..0000000000
--- a/changelog.d/4643.misc
+++ /dev/null
@@ -1 +0,0 @@
-Reduce number of exceptions we log
diff --git a/changelog.d/4644.misc b/changelog.d/4644.misc
deleted file mode 100644
index 84137c3412..0000000000
--- a/changelog.d/4644.misc
+++ /dev/null
@@ -1 +0,0 @@
-Introduce upsert batching functionality in the database layer.
diff --git a/changelog.d/4647.feature b/changelog.d/4647.feature
deleted file mode 100644
index 5a5b1dcebb..0000000000
--- a/changelog.d/4647.feature
+++ /dev/null
@@ -1 +0,0 @@
-Add configurable room list publishing rules
diff --git a/changelog.d/4651.bugfix b/changelog.d/4651.bugfix
deleted file mode 100644
index 15cb1e58c4..0000000000
--- a/changelog.d/4651.bugfix
+++ /dev/null
@@ -1 +0,0 @@
-Set CORS headers on .well-known requests
diff --git a/changelog.d/4652.feature b/changelog.d/4652.feature
deleted file mode 100644
index ebe6880b21..0000000000
--- a/changelog.d/4652.feature
+++ /dev/null
@@ -1 +0,0 @@
-Support .well-known delegation when issuing certificates through ACME.
diff --git a/changelog.d/4657.misc b/changelog.d/4657.misc
deleted file mode 100644
index 8872765819..0000000000
--- a/changelog.d/4657.misc
+++ /dev/null
@@ -1 +0,0 @@
-Fix various spelling mistakes.
diff --git a/changelog.d/4666.feature b/changelog.d/4666.feature
deleted file mode 100644
index b3a3915eb0..0000000000
--- a/changelog.d/4666.feature
+++ /dev/null
@@ -1 +0,0 @@
-Allow registration and login to be handled by a worker instance.
diff --git a/changelog.d/4667.bugfix b/changelog.d/4667.bugfix
deleted file mode 100644
index 33ad00c137..0000000000
--- a/changelog.d/4667.bugfix
+++ /dev/null
@@ -1 +0,0 @@
-Fix kicking guest users on guest access revocation in worker mode.
diff --git a/changelog.d/4668.misc b/changelog.d/4668.misc
deleted file mode 100644
index 556cdd2240..0000000000
--- a/changelog.d/4668.misc
+++ /dev/null
@@ -1 +0,0 @@
-Reduce number of exceptions we log
diff --git a/changelog.d/4669.misc b/changelog.d/4669.misc
deleted file mode 100644
index d5d0e27731..0000000000
--- a/changelog.d/4669.misc
+++ /dev/null
@@ -1 +0,0 @@
-Cleanup request exception logging.
diff --git a/changelog.d/4670.feature b/changelog.d/4670.feature
deleted file mode 100644
index b3a3915eb0..0000000000
--- a/changelog.d/4670.feature
+++ /dev/null
@@ -1 +0,0 @@
-Allow registration and login to be handled by a worker instance.
diff --git a/changelog.d/4671.misc b/changelog.d/4671.misc
deleted file mode 100644
index 4dc18378e7..0000000000
--- a/changelog.d/4671.misc
+++ /dev/null
@@ -1 +0,0 @@
-Improve replication performance by reducing cache invalidation traffic.
diff --git a/changelog.d/4674.feature b/changelog.d/4674.feature
deleted file mode 100644
index 84630bb201..0000000000
--- a/changelog.d/4674.feature
+++ /dev/null
@@ -1 +0,0 @@
-Reduce the overhead of creating outbound federation connections over TLS by caching the TLS client options.
diff --git a/changelog.d/4676.misc b/changelog.d/4676.misc
deleted file mode 100644
index a250558e69..0000000000
--- a/changelog.d/4676.misc
+++ /dev/null
@@ -1 +0,0 @@
-Test against Postgres 9.5 as well as 9.4
diff --git a/changelog.d/4677.misc b/changelog.d/4677.misc
deleted file mode 100644
index 6f4596be4a..0000000000
--- a/changelog.d/4677.misc
+++ /dev/null
@@ -1 +0,0 @@
-Run unit tests against python 3.7.
diff --git a/changelog.d/4680.bugfix b/changelog.d/4680.bugfix
deleted file mode 100644
index 4aad8ecde3..0000000000
--- a/changelog.d/4680.bugfix
+++ /dev/null
@@ -1,3 +0,0 @@
-Fix an issue in the database migration script where the
-`e2e_room_keys.is_verified` column wasn't considered as
-a boolean
diff --git a/changelog.d/4681.misc b/changelog.d/4681.misc
deleted file mode 100644
index 37d3588804..0000000000
--- a/changelog.d/4681.misc
+++ /dev/null
@@ -1 +0,0 @@
-Attempt to clarify installation instructions/config
diff --git a/changelog.d/4682.feature b/changelog.d/4682.feature
deleted file mode 100644
index b3a3915eb0..0000000000
--- a/changelog.d/4682.feature
+++ /dev/null
@@ -1 +0,0 @@
-Allow registration and login to be handled by a worker instance.
diff --git a/changelog.d/4688.misc b/changelog.d/4688.misc
deleted file mode 100644
index 24cd2eb424..0000000000
--- a/changelog.d/4688.misc
+++ /dev/null
@@ -1 +0,0 @@
-Clean up gitignores
diff --git a/changelog.d/4689.misc b/changelog.d/4689.misc
deleted file mode 100644
index 15c4d9404b..0000000000
--- a/changelog.d/4689.misc
+++ /dev/null
@@ -1 +0,0 @@
-Minor tweaks to acme docs.
diff --git a/changelog.d/4690.bugfix b/changelog.d/4690.bugfix
deleted file mode 100644
index e4cfc5e413..0000000000
--- a/changelog.d/4690.bugfix
+++ /dev/null
@@ -1 +0,0 @@
-Fix TaskStopped exceptions in logs when outbound requests time out.
\ No newline at end of file
diff --git a/changelog.d/4691.misc b/changelog.d/4691.misc
deleted file mode 100644
index 8eb825edf0..0000000000
--- a/changelog.d/4691.misc
+++ /dev/null
@@ -1 +0,0 @@
-Improve the logging in the pusher process.
diff --git a/changelog.d/4694.feature b/changelog.d/4694.feature
deleted file mode 100644
index d053ab5a25..0000000000
--- a/changelog.d/4694.feature
+++ /dev/null
@@ -1 +0,0 @@
-Add basic optional sentry integration
diff --git a/changelog.d/4695.feature b/changelog.d/4695.feature
deleted file mode 100644
index 3816c9dec8..0000000000
--- a/changelog.d/4695.feature
+++ /dev/null
@@ -1 +0,0 @@
-Add prometheus metrics for number of outgoing EDUs, by type.
diff --git a/changelog.d/4698.misc b/changelog.d/4698.misc
deleted file mode 100644
index d17b19bec5..0000000000
--- a/changelog.d/4698.misc
+++ /dev/null
@@ -1 +0,0 @@
-Better checks on newsfragments
diff --git a/changelog.d/4706.misc b/changelog.d/4706.misc
deleted file mode 100644
index 73d1ddcc56..0000000000
--- a/changelog.d/4706.misc
+++ /dev/null
@@ -1 +0,0 @@
-Avoid some redundant work when processing read receipts
diff --git a/changelog.d/4707.misc b/changelog.d/4707.misc
deleted file mode 100644
index ef0772b9af..0000000000
--- a/changelog.d/4707.misc
+++ /dev/null
@@ -1 +0,0 @@
-Run push_receipts_to_remotes as background job.
diff --git a/changelog.d/4709.misc b/changelog.d/4709.misc
deleted file mode 100644
index ca47a6f327..0000000000
--- a/changelog.d/4709.misc
+++ /dev/null
@@ -1 +0,0 @@
-Add prometheus metrics for number of badge update pushes.
diff --git a/changelog.d/4715.misc b/changelog.d/4715.misc
deleted file mode 100644
index 4dc18378e7..0000000000
--- a/changelog.d/4715.misc
+++ /dev/null
@@ -1 +0,0 @@
-Improve replication performance by reducing cache invalidation traffic.
diff --git a/changelog.d/4716.misc b/changelog.d/4716.misc
deleted file mode 100644
index 5935f3af24..0000000000
--- a/changelog.d/4716.misc
+++ /dev/null
@@ -1 +0,0 @@
-Reduce pusher logging on startup
diff --git a/changelog.d/4717.bugfix b/changelog.d/4717.bugfix
deleted file mode 100644
index 79ab231477..0000000000
--- a/changelog.d/4717.bugfix
+++ /dev/null
@@ -1 +0,0 @@
-Fix ACME config for python 2.
diff --git a/changelog.d/4718.bugfix b/changelog.d/4718.bugfix
deleted file mode 100644
index a7d1963ee1..0000000000
--- a/changelog.d/4718.bugfix
+++ /dev/null
@@ -1 +0,0 @@
-Fix paginating over federation persisting incorrect state.
diff --git a/changelog.d/4721.feature b/changelog.d/4721.feature
deleted file mode 100644
index f932843ce7..0000000000
--- a/changelog.d/4721.feature
+++ /dev/null
@@ -1 +0,0 @@
-Return correct error code when inviting a remote user to a room whose homeserver does not support the room version.
diff --git a/changelog.d/4722.misc b/changelog.d/4722.misc
deleted file mode 100644
index e9158c4dc2..0000000000
--- a/changelog.d/4722.misc
+++ /dev/null
@@ -1 +0,0 @@
-Don't log exceptions when failing to fetch remote server keys
diff --git a/changelog.d/4723.misc b/changelog.d/4723.misc
deleted file mode 100644
index 96958036ca..0000000000
--- a/changelog.d/4723.misc
+++ /dev/null
@@ -1 +0,0 @@
-Correctly proxy exception in frontend_proxy worker
diff --git a/changelog.d/4737.misc b/changelog.d/4737.misc
deleted file mode 100644
index d5d0e27731..0000000000
--- a/changelog.d/4737.misc
+++ /dev/null
@@ -1 +0,0 @@
-Cleanup request exception logging.
diff --git a/changelog.d/4738.misc b/changelog.d/4738.misc
deleted file mode 100644
index d5d0e27731..0000000000
--- a/changelog.d/4738.misc
+++ /dev/null
@@ -1 +0,0 @@
-Cleanup request exception logging.
diff --git a/changelog.d/4746.feature b/changelog.d/4746.feature
deleted file mode 100644
index 97c253eccf..0000000000
--- a/changelog.d/4746.feature
+++ /dev/null
@@ -1 +0,0 @@
-Prevent showing rooms to other servers that were set to not federate.
\ No newline at end of file
diff --git a/debian/changelog b/debian/changelog
index 7631406a68..8a59c708d7 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,8 +1,9 @@
-matrix-synapse-py3 (0.99.2) UNRELEASED; urgency=medium
+matrix-synapse-py3 (0.99.2rc1) stable; urgency=medium
* Fix overwriting of config settings on upgrade.
+ * New synapse release 0.99.2rc1.
- -- Synapse Packaging team <packages@matrix.org> Wed, 20 Feb 2019 17:11:25 +0000
+ -- Synapse Packaging team <packages@matrix.org> Wed, 27 Feb 2019 10:45:58 +0000
matrix-synapse-py3 (0.99.1.1) stable; urgency=medium
diff --git a/docs/reverse_proxy.rst b/docs/reverse_proxy.rst
index 242935a62f..4706061eba 100644
--- a/docs/reverse_proxy.rst
+++ b/docs/reverse_proxy.rst
@@ -79,7 +79,7 @@ Let's assume that we expect clients to connect to our server at
SSLEngine on
ServerName example.com;
- <Location />
+ <Location /_matrix>
ProxyPass http://127.0.0.1:8008/_matrix nocanon
ProxyPassReverse http://127.0.0.1:8008/_matrix
</Location>
diff --git a/scripts-dev/check-newsfragment b/scripts-dev/check-newsfragment
index 5da093e168..e4a22bae61 100755
--- a/scripts-dev/check-newsfragment
+++ b/scripts-dev/check-newsfragment
@@ -6,7 +6,8 @@
set -e
# make sure that origin/develop is up to date
-git fetch origin develop
+git remote set-branches --add origin develop
+git fetch --depth=1 origin develop
UPSTREAM=origin/develop
@@ -25,11 +26,15 @@ if git diff --name-only $UPSTREAM... | grep -qv '^develop/'; then
tox -e check-newsfragment
fi
+echo
+echo "--------------------------"
+echo
+
# check that any new newsfiles on this branch end with a full stop.
-for f in git diff --name-only $UPSTREAM... -- changelog.d; do
+for f in `git diff --name-only $UPSTREAM... -- changelog.d`; do
lastchar=`tr -d '\n' < $f | tail -c 1`
if [ $lastchar != '.' ]; then
- echo "Newsfragment $f does not end with a '.'" >&2
+ echo -e "\e[31mERROR: newsfragment $f does not end with a '.'\e[39m" >&2
exit 1
fi
done
diff --git a/synapse/__init__.py b/synapse/__init__.py
index 2004375f98..29b1fe4c03 100644
--- a/synapse/__init__.py
+++ b/synapse/__init__.py
@@ -27,4 +27,4 @@ try:
except ImportError:
pass
-__version__ = "0.99.1.1"
+__version__ = "0.99.2rc1"
diff --git a/synapse/app/homeserver.py b/synapse/app/homeserver.py
index 05a97979ec..e8b6cc3114 100755
--- a/synapse/app/homeserver.py
+++ b/synapse/app/homeserver.py
@@ -555,6 +555,9 @@ def run(hs):
stats["memory_rss"] += process.memory_info().rss
stats["cpu_average"] += int(process.cpu_percent(interval=None))
+ stats["database_engine"] = hs.get_datastore().database_engine_name
+ stats["database_server_version"] = hs.get_datastore().get_server_version()
+
logger.info("Reporting stats to matrix.org: %s" % (stats,))
try:
yield hs.get_simple_http_client().put_json(
diff --git a/synapse/replication/tcp/protocol.py b/synapse/replication/tcp/protocol.py
index 6123c995b9..49ae5b3355 100644
--- a/synapse/replication/tcp/protocol.py
+++ b/synapse/replication/tcp/protocol.py
@@ -268,7 +268,17 @@ class BaseReplicationStreamProtocol(LineOnlyReceiver):
if "\n" in string:
raise Exception("Unexpected newline in command: %r", string)
- self.sendLine(string.encode("utf-8"))
+ encoded_string = string.encode("utf-8")
+
+ if len(encoded_string) > self.MAX_LENGTH:
+ raise Exception(
+ "Failed to send command %s as too long (%d > %d)" % (
+ cmd.NAME,
+ len(encoded_string), self.MAX_LENGTH,
+ )
+ )
+
+ self.sendLine(encoded_string)
self.last_sent_command = self.clock.time_msec()
@@ -361,6 +371,11 @@ class BaseReplicationStreamProtocol(LineOnlyReceiver):
def id(self):
return "%s-%s" % (self.name, self.conn_id)
+ def lineLengthExceeded(self, line):
+ """Called when we receive a line that is above the maximum line length
+ """
+ self.send_error("Line length exceeded")
+
class ServerReplicationStreamProtocol(BaseReplicationStreamProtocol):
VALID_INBOUND_COMMANDS = VALID_CLIENT_COMMANDS
diff --git a/synapse/storage/_base.py b/synapse/storage/_base.py
index 5a80eef211..a0333d5309 100644
--- a/synapse/storage/_base.py
+++ b/synapse/storage/_base.py
@@ -30,6 +30,7 @@ from synapse.api.errors import StoreError
from synapse.metrics.background_process_metrics import run_as_background_process
from synapse.storage.engines import PostgresEngine, Sqlite3Engine
from synapse.types import get_domain_from_id
+from synapse.util import batch_iter
from synapse.util.caches.descriptors import Cache
from synapse.util.logcontext import LoggingContext, PreserveLoggingContext
from synapse.util.stringutils import exception_to_unicode
@@ -1327,10 +1328,16 @@ class SQLBaseStore(object):
"""
txn.call_after(self._invalidate_state_caches, room_id, members_changed)
- keys = itertools.chain([room_id], members_changed)
- self._send_invalidation_to_replication(
- txn, _CURRENT_STATE_CACHE_NAME, keys,
- )
+ # We need to be careful that the size of the `members_changed` list
+ # isn't so large that it causes problems sending over replication, so we
+ # send them in chunks.
+ # Max line length is 16K, and max user ID length is 255, so 50 should
+ # be safe.
+ for chunk in batch_iter(members_changed, 50):
+ keys = itertools.chain([room_id], chunk)
+ self._send_invalidation_to_replication(
+ txn, _CURRENT_STATE_CACHE_NAME, keys,
+ )
def _invalidate_state_caches(self, room_id, members_changed):
"""Invalidates caches that are based on the current state, but does
@@ -1596,6 +1603,14 @@ class SQLBaseStore(object):
return cls.cursor_to_dict(txn)
+ @property
+ def database_engine_name(self):
+ return self.database_engine.module.__name__
+
+ def get_server_version(self):
+ """Returns a string describing the server version number"""
+ return self.database_engine.server_version
+
class _RollbackButIsFineException(Exception):
""" This exception is used to rollback a transaction without implying
diff --git a/synapse/storage/engines/postgres.py b/synapse/storage/engines/postgres.py
index 4004427c7b..dc3238501c 100644
--- a/synapse/storage/engines/postgres.py
+++ b/synapse/storage/engines/postgres.py
@@ -23,6 +23,7 @@ class PostgresEngine(object):
self.module = database_module
self.module.extensions.register_type(self.module.extensions.UNICODE)
self.synchronous_commit = database_config.get("synchronous_commit", True)
+ self._version = None # unknown as yet
def check_database(self, txn):
txn.execute("SHOW SERVER_ENCODING")
@@ -87,3 +88,27 @@ class PostgresEngine(object):
"""
txn.execute("SELECT nextval('state_group_id_seq')")
return txn.fetchone()[0]
+
+ @property
+ def server_version(self):
+ """Returns a string giving the server version. For example: '8.1.5'
+
+ Returns:
+ string
+ """
+ # note that this is a bit of a hack because it relies on on_new_connection
+ # having been called at least once. Still, that should be a safe bet here.
+ numver = self._version
+ assert numver is not None
+
+ # https://www.postgresql.org/docs/current/libpq-status.html#LIBPQ-PQSERVERVERSION
+ if numver >= 100000:
+ return "%i.%i" % (
+ numver / 10000, numver % 10000,
+ )
+ else:
+ return "%i.%i.%i" % (
+ numver / 10000,
+ (numver % 10000) / 100,
+ numver % 100,
+ )
diff --git a/synapse/storage/engines/sqlite.py b/synapse/storage/engines/sqlite.py
index 059ab81055..1bcd5b99a4 100644
--- a/synapse/storage/engines/sqlite.py
+++ b/synapse/storage/engines/sqlite.py
@@ -70,6 +70,15 @@ class Sqlite3Engine(object):
self._current_state_group_id += 1
return self._current_state_group_id
+ @property
+ def server_version(self):
+ """Gets a string giving the server version. For example: '3.22.0'
+
+ Returns:
+ string
+ """
+ return "%i.%i.%i" % self.module.sqlite_version_info
+
# Following functions taken from: https://github.com/coleifer/peewee
|