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

Commit 12fb065

Browse files
committed
Remove code which updates application_services_state.last_txn
This column is unused as of #12209, so let's stop writing to it.
1 parent a00462d commit 12fb065

File tree

4 files changed

+11
-30
lines changed

4 files changed

+11
-30
lines changed

changelog.d/12680.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Remove code which updates unused database column `application_services_state.last_txn`.

synapse/storage/databases/main/appservice.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -296,14 +296,6 @@ async def complete_appservice_txn(
296296
"""
297297

298298
def _complete_appservice_txn(txn: LoggingTransaction) -> None:
299-
# Set current txn_id for AS to 'txn_id'
300-
self.db_pool.simple_upsert_txn(
301-
txn,
302-
"application_services_state",
303-
{"as_id": service.id},
304-
{"last_txn": txn_id},
305-
)
306-
307299
# Delete txn
308300
self.db_pool.simple_delete_txn(
309301
txn,

synapse/storage/schema/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,16 @@
6161
6262
Changes in SCHEMA_VERSION = 69:
6363
- We now write to `device_lists_changes_in_room` table.
64-
- Use sequence to generate future `application_services_txns.txn_id`s
64+
- We now use a PostgreSQL sequence to generate future txn_ids for
65+
`application_services_txns`. `application_services_state.last_txn` is no longer
66+
updated.
6567
"""
6668

6769

6870
SCHEMA_COMPAT_VERSION = (
6971
# We now assume that `device_lists_changes_in_room` has been filled out for
7072
# recent device_list_updates.
73+
# ... and that `application_services_state.last_txn` is not used.
7174
69
7275
)
7376
"""Limit on how far the synapse codebase can be rolled back without breaking db compat

tests/storage/test_appservice.py

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import json
1515
import os
1616
import tempfile
17-
from typing import List, Optional, cast
17+
from typing import List, cast
1818
from unittest.mock import Mock
1919

2020
import yaml
@@ -149,15 +149,12 @@ def _add_service(self, url, as_token, id) -> None:
149149
outfile.write(yaml.dump(as_yaml))
150150
self.as_yaml_files.append(as_token)
151151

152-
def _set_state(
153-
self, id: str, state: ApplicationServiceState, txn: Optional[int] = None
154-
):
152+
def _set_state(self, id: str, state: ApplicationServiceState):
155153
return self.db_pool.runOperation(
156154
self.engine.convert_param_style(
157-
"INSERT INTO application_services_state(as_id, state, last_txn) "
158-
"VALUES(?,?,?)"
155+
"INSERT INTO application_services_state(as_id, state) VALUES(?,?)"
159156
),
160-
(id, state.value, txn),
157+
(id, state.value),
161158
)
162159

163160
def _insert_txn(self, as_id, txn_id, events):
@@ -280,17 +277,6 @@ def test_complete_appservice_txn_first_txn(
280277
self.store.complete_appservice_txn(txn_id=txn_id, service=service)
281278
)
282279

283-
res = self.get_success(
284-
self.db_pool.runQuery(
285-
self.engine.convert_param_style(
286-
"SELECT last_txn FROM application_services_state WHERE as_id=?"
287-
),
288-
(service.id,),
289-
)
290-
)
291-
self.assertEqual(1, len(res))
292-
self.assertEqual(txn_id, res[0][0])
293-
294280
res = self.get_success(
295281
self.db_pool.runQuery(
296282
self.engine.convert_param_style(
@@ -316,14 +302,13 @@ def test_complete_appservice_txn_updates_last_txn_state(
316302
res = self.get_success(
317303
self.db_pool.runQuery(
318304
self.engine.convert_param_style(
319-
"SELECT last_txn, state FROM application_services_state WHERE as_id=?"
305+
"SELECT state FROM application_services_state WHERE as_id=?"
320306
),
321307
(service.id,),
322308
)
323309
)
324310
self.assertEqual(1, len(res))
325-
self.assertEqual(txn_id, res[0][0])
326-
self.assertEqual(ApplicationServiceState.UP.value, res[0][1])
311+
self.assertEqual(ApplicationServiceState.UP.value, res[0][0])
327312

328313
res = self.get_success(
329314
self.db_pool.runQuery(

0 commit comments

Comments
 (0)