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

Commit 64f4f50

Browse files
authored
Merge pull request #9766 from matrix-org/rav/drop_py35
Require py36, Postgres 9.6, and sqlite 3.22
2 parents 88b9414 + 9e167d9 commit 64f4f50

File tree

13 files changed

+24
-111
lines changed

13 files changed

+24
-111
lines changed

.buildkite/scripts/test_old_deps.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22

3-
# this script is run by buildkite in a plain `xenial` container; it installs the
3+
# this script is run by buildkite in a plain `bionic` container; it installs the
44
# minimal requirements for tox and hands over to the py3-old tox environment.
55

66
set -ex

changelog.d/9766.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Synapse now requires Python 3.6 or later. It also requires Postgres 9.6 or later or SQLite 3.22 or later.

scripts-dev/build_debian_packages

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,9 @@ import threading
1818
from concurrent.futures import ThreadPoolExecutor
1919

2020
DISTS = (
21-
"debian:stretch",
2221
"debian:buster",
2322
"debian:bullseye",
2423
"debian:sid",
25-
"ubuntu:xenial",
2624
"ubuntu:bionic",
2725
"ubuntu:focal",
2826
"ubuntu:groovy",

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def exec_file(path_segments):
123123
zip_safe=False,
124124
long_description=long_description,
125125
long_description_content_type="text/x-rst",
126-
python_requires="~=3.5",
126+
python_requires="~=3.6",
127127
classifiers=[
128128
"Development Status :: 5 - Production/Stable",
129129
"Topic :: Communications :: Chat",

synapse/storage/database.py

Lines changed: 6 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -2059,69 +2059,18 @@ def make_in_list_sql_clause(
20592059
KV = TypeVar("KV")
20602060

20612061

2062-
def make_tuple_comparison_clause(
2063-
database_engine: BaseDatabaseEngine, keys: List[Tuple[str, KV]]
2064-
) -> Tuple[str, List[KV]]:
2062+
def make_tuple_comparison_clause(keys: List[Tuple[str, KV]]) -> Tuple[str, List[KV]]:
20652063
"""Returns a tuple comparison SQL clause
20662064
2067-
Depending what the SQL engine supports, builds a SQL clause that looks like either
2068-
"(a, b) > (?, ?)", or "(a > ?) OR (a == ? AND b > ?)".
2065+
Builds a SQL clause that looks like "(a, b) > (?, ?)"
20692066
20702067
Args:
2071-
database_engine
20722068
keys: A set of (column, value) pairs to be compared.
20732069
20742070
Returns:
20752071
A tuple of SQL query and the args
20762072
"""
2077-
if database_engine.supports_tuple_comparison:
2078-
return (
2079-
"(%s) > (%s)" % (",".join(k[0] for k in keys), ",".join("?" for _ in keys)),
2080-
[k[1] for k in keys],
2081-
)
2082-
2083-
# we want to build a clause
2084-
# (a > ?) OR
2085-
# (a == ? AND b > ?) OR
2086-
# (a == ? AND b == ? AND c > ?)
2087-
# ...
2088-
# (a == ? AND b == ? AND ... AND z > ?)
2089-
#
2090-
# or, equivalently:
2091-
#
2092-
# (a > ? OR (a == ? AND
2093-
# (b > ? OR (b == ? AND
2094-
# ...
2095-
# (y > ? OR (y == ? AND
2096-
# z > ?
2097-
# ))
2098-
# ...
2099-
# ))
2100-
# ))
2101-
#
2102-
# which itself is equivalent to (and apparently easier for the query optimiser):
2103-
#
2104-
# (a >= ? AND (a > ? OR
2105-
# (b >= ? AND (b > ? OR
2106-
# ...
2107-
# (y >= ? AND (y > ? OR
2108-
# z > ?
2109-
# ))
2110-
# ...
2111-
# ))
2112-
# ))
2113-
#
2114-
#
2115-
2116-
clause = ""
2117-
args = [] # type: List[KV]
2118-
for k, v in keys[:-1]:
2119-
clause = clause + "(%s >= ? AND (%s > ? OR " % (k, k)
2120-
args.extend([v, v])
2121-
2122-
(k, v) = keys[-1]
2123-
clause += "%s > ?" % (k,)
2124-
args.append(v)
2125-
2126-
clause += "))" * (len(keys) - 1)
2127-
return clause, args
2073+
return (
2074+
"(%s) > (%s)" % (",".join(k[0] for k in keys), ",".join("?" for _ in keys)),
2075+
[k[1] for k in keys],
2076+
)

synapse/storage/databases/main/client_ips.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,6 @@ def _devices_last_seen_update_txn(txn):
298298
# times, which is fine.
299299

300300
where_clause, where_args = make_tuple_comparison_clause(
301-
self.database_engine,
302301
[("user_id", last_user_id), ("device_id", last_device_id)],
303302
)
304303

synapse/storage/databases/main/devices.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -985,7 +985,7 @@ async def _remove_duplicate_outbound_pokes(self, progress, batch_size):
985985

986986
def _txn(txn):
987987
clause, args = make_tuple_comparison_clause(
988-
self.db_pool.engine, [(x, last_row[x]) for x in KEY_COLS]
988+
[(x, last_row[x]) for x in KEY_COLS]
989989
)
990990
sql = """
991991
SELECT stream_id, destination, user_id, device_id, MAX(ts) AS ts

synapse/storage/databases/main/events_bg_updates.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,6 @@ def _calculate_chain_cover_txn(
838838
# We want to do a `(topological_ordering, stream_ordering) > (?,?)`
839839
# comparison, but that is not supported on older SQLite versions
840840
tuple_clause, tuple_args = make_tuple_comparison_clause(
841-
self.database_engine,
842841
[
843842
("events.room_id", last_room_id),
844843
("topological_ordering", last_depth),

synapse/storage/engines/_base.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,6 @@ def can_native_upsert(self) -> bool:
4242
"""
4343
...
4444

45-
@property
46-
@abc.abstractmethod
47-
def supports_tuple_comparison(self) -> bool:
48-
"""
49-
Do we support comparing tuples, i.e. `(a, b) > (c, d)`?
50-
"""
51-
...
52-
5345
@property
5446
@abc.abstractmethod
5547
def supports_using_any_list(self) -> bool:

synapse/storage/engines/postgres.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ def check_database(self, db_conn, allow_outdated_version: bool = False):
4747
self._version = db_conn.server_version
4848

4949
# Are we on a supported PostgreSQL version?
50-
if not allow_outdated_version and self._version < 90500:
51-
raise RuntimeError("Synapse requires PostgreSQL 9.5+ or above.")
50+
if not allow_outdated_version and self._version < 90600:
51+
raise RuntimeError("Synapse requires PostgreSQL 9.6 or above.")
5252

5353
with db_conn.cursor() as txn:
5454
txn.execute("SHOW SERVER_ENCODING")
@@ -129,13 +129,6 @@ def can_native_upsert(self):
129129
"""
130130
return True
131131

132-
@property
133-
def supports_tuple_comparison(self):
134-
"""
135-
Do we support comparing tuples, i.e. `(a, b) > (c, d)`?
136-
"""
137-
return True
138-
139132
@property
140133
def supports_using_any_list(self):
141134
"""Do we support using `a = ANY(?)` and passing a list"""

0 commit comments

Comments
 (0)