The Matrix protocol assumes that each user will have at most one cross-signing key of a given type (master, self_signing, user_signing) at a time.
However, it is possible for clients to replace the existing keys with further calls to POST /_matrix/client/v3/keys/device_signing/upload. When that happens, Synapse appears to just add the new key to e2e_cross_signing_keys without deleting the old one. Some matrix.org users have accumulated over 2000 keys of each type.
This is redundant data which we have no business keeping (and it sucks up disk space).
There also seems to be a codepath somewhere where we end up with multiple copies of a key for a remote user get stored in the database.
Ideally the e2e_cross_signing_keys table should be UNIQUE in (user_id, keytype).
The Matrix protocol assumes that each user will have at most one cross-signing key of a given type (
master
,self_signing
,user_signing
) at a time.However, it is possible for clients to replace the existing keys with further calls to
POST /_matrix/client/v3/keys/device_signing/upload
. When that happens, Synapse appears to just add the new key toe2e_cross_signing_keys
without deleting the old one. Somematrix.org
users have accumulated over 2000 keys of each type.This is redundant data which we have no business keeping (and it sucks up disk space).
There also seems to be a codepath somewhere where we end up with multiple copies of a key for a remote user get stored in the database.
Ideally the
e2e_cross_signing_keys
table should beUNIQUE
in(user_id, keytype)
.