-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
devices table has case-sensitive user_id which leads to not removing devices from user #16474
Comments
See also #3599. |
briefly:
As a result there are problems:
|
table sizes now:
I was selecting stale devices by getting user_id, device_id pair from:
after deleting those I have found that some of the messages in device_inbox are still being present. can one clean manually device_inbox if user_id,device_id is not present in devices? |
for now I want to manually convert user_id to lowercase in devices inbox, probably one could add a trigger before insert which would do lowercase of user_id but it won't solve the bug itself| or changing the type of user_id column to citext (but, in all fairness this should be done by synapse team as a migration). sadly, I don't have enough time finding what causes adding user_id with different case in devices. and I'm afraid that this bug could interfere with other tables too, so it would be better if it would be possible finding the source of the problem and not fixing holes by patching db. |
Note that usernames are case sensitive, except during login If, and only if, there are not ambiguous users. It is a bit unclear how these entries could have been added in the first place. Maybe a client issue is involved? But it isn't really clear. |
yep, there probably is some client issue as those users are lowercase in users table, but they have case in devices.
will this work? and by work i mean it wouldn't harm the inner synapse logic |
(I notice from the description that LDAP auth is in use. LDAP auth has been sloppy with username cases in the past, so I'd reckon it's worth a look there to see if that might be part of the reason.) |
Ah, looks like the LDAP provider had a bug around case sensitivity: matrix-org/matrix-synapse-ldap3#163 and matrix-org/matrix-synapse-ldap3#168. Hopefully that means therefore this issue is fixed (albeit the stale entries in the DB that haven't been cleaned up)? |
the question stands still: |
Description
When I was searching for reasons of device_inbox bloat. I've found that there are many devices in device table which have last_seen null.
those devices had wrong case in user_id f.e. @user:domain | master signing key but @ User:domain | Element Android...
If one uses admin api to logout device last_seen is set to null but the device is not being removed from devices table.
iff name is lowercase everything works fine. there seems to be a problem that case-insensitive names start being case sensitive
and a problem that case-sensitive user_ids appeared in devices when they shouldn't.
if i match user_id case from devices, delete devices api it returns: {"errcode":"M_NOT_FOUND","error":"Unknown user"}
Steps to reproduce
don't know how to reproduce this reliably as I don't know how new devices are being created in table and what leads to this behaviour.
probably this bug could affect other tables too.
Homeserver
personal
Synapse Version
1.94
Installation Method
Debian packages from packages.matrix.org
Database
postgresql, single instanse
Workers
Multiple workers
Platform
debian linux 11
Configuration
i have device retention in logs and ldap auth
Relevant log output
no logs for now
Anything else that would be useful to know?
matrix-synapse-ldap3/oldstable,now 0.1.4+git20201015+a3c7a9f-1 all [installed]
The text was updated successfully, but these errors were encountered: