mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-12-26 08:59:24 -05:00
Fix error handling during insertion of client IPs (#9051)
You can't continue using a transaction once an exception has been raised, so catching and dropping the error here is pointless and just causes more errors.
This commit is contained in:
parent
195adf4025
commit
fa5f5cbc74
1
changelog.d/9051.bugfix
Normal file
1
changelog.d/9051.bugfix
Normal file
@ -0,0 +1 @@
|
|||||||
|
Fix error handling during insertion of client IPs into the database.
|
@ -470,15 +470,10 @@ class ClientIpStore(ClientIpWorkerStore):
|
|||||||
for entry in to_update.items():
|
for entry in to_update.items():
|
||||||
(user_id, access_token, ip), (user_agent, device_id, last_seen) = entry
|
(user_id, access_token, ip), (user_agent, device_id, last_seen) = entry
|
||||||
|
|
||||||
try:
|
|
||||||
self.db_pool.simple_upsert_txn(
|
self.db_pool.simple_upsert_txn(
|
||||||
txn,
|
txn,
|
||||||
table="user_ips",
|
table="user_ips",
|
||||||
keyvalues={
|
keyvalues={"user_id": user_id, "access_token": access_token, "ip": ip},
|
||||||
"user_id": user_id,
|
|
||||||
"access_token": access_token,
|
|
||||||
"ip": ip,
|
|
||||||
},
|
|
||||||
values={
|
values={
|
||||||
"user_agent": user_agent,
|
"user_agent": user_agent,
|
||||||
"device_id": device_id,
|
"device_id": device_id,
|
||||||
@ -503,9 +498,6 @@ class ClientIpStore(ClientIpWorkerStore):
|
|||||||
"ip": ip,
|
"ip": ip,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
except Exception as e:
|
|
||||||
# Failed to upsert, log and continue
|
|
||||||
logger.error("Failed to insert client IP %r: %r", entry, e)
|
|
||||||
|
|
||||||
async def get_last_client_ip_by_device(
|
async def get_last_client_ip_by_device(
|
||||||
self, user_id: str, device_id: Optional[str]
|
self, user_id: str, device_id: Optional[str]
|
||||||
|
Loading…
Reference in New Issue
Block a user