-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Remote dynamic thumbnails are stored at the wrong location #5913
Comments
This seems to fix it: diff --git a/synapse/rest/media/v1/media_repository.py b/synapse/rest/media/v1/media_repository.py
index cf5759e9a6..28073dec4c 100644
--- a/synapse/rest/media/v1/media_repository.py
+++ b/synapse/rest/media/v1/media_repository.py
@@ -526,7 +526,7 @@ def generate_remote_exact_thumbnail(
try:
file_info = FileInfo(
server_name=server_name,
- file_id=media_id,
+ file_id=file_id,
thumbnail=True,
thumbnail_width=t_width,
thumbnail_height=t_height, |
thanks @rkfg. Do you know if this is a recent regression, or if it has always always been a problem? Would you be able to make a PR for your patch? (A regression test would be very helpful too, though I appreciate that may need more time than you have.) |
Eh, no idea if it's recent but I noticed that thumbnails didn't load after I cleaned up the cache and database. Didn't have time to dig deeper back then and enabling dynamic thumbnails "fixed" it. But recently I noticed that avatars take too much time to load like 1-1.5 minutes (if they were not cached) so I decided to take a look. I suspected S3 being slow at first but then noticed a big CPU usage and in the end solved it. I'd like to make a PR but it needs too much hassle for a one-liner so I'm not really excited to do that. Feel free to make that patch yourself, I don't even need to be mentioned. The fix is too trivial. Hope it will help you reduce the load on matrix.org. |
understood, but that means it has to wait for someone else to have time to do it :( |
I think basically because the |
(edit: this is bogus) |
I think it was mostly that, possibly also so that we could decide where we wanted it on disk (e.g. dedupe the media, or something) |
@rkfg I'm very confused here. I agree that something looks bogus, but I cannot reproduce the issue at all. Any hints? |
(I have |
As far as I can tell, the file that you suggest patching ( |
Do the thumbnail files appear at the correct location? Maybe there were changes between my version and current develop, I can't really test. Is this happening on 1.3.1? |
yes, they appear at the location given by the filesystem_id. I'm testing on current develop, but I don't think this code has been touched in months. |
It's called when that option is off for me, I cleared the remote media tables and removed the files after applying the fix and it worked. The thumbnails were stored under the wrong names before, I checked the timestamps to make sure they're fresh. Does this fix break them for you then? Something has to change after applying it! |
I'm just reluctant to change code without understanding what we're changing.
Is it possible that the thumbnails were generated in the wrong place when |
It's possible, yes. Now that I think about it I really didn't test that case. When there's a database record already for a certain file it won't be regenerated even if the actual file is missing, correct? Then I already had those incorrectly named thumbnails and nuking the tables and data hid the issue. |
I fixed the issue description and steps to reproduce. |
hopefully fixed by #5915 then. Thanks all. |
Description
The remote thumbnails path and filename are derived from
media_id
when they're generated and stored withdynamic_thumbnails
set totrue
. The said thumbnails are looked up byfilesystem_id
which fails every time. Synapse uses a lot of CPU regenerating the thumbnails all the time. Whendynamic_thumbnails
option is then turned off Synapse can't find the thumbnails generated when the said option was turned on and just returns 404.Steps to reproduce
dynamic_thumbnails
totrue
dynamic_thumbnails
tofalse
Local media thumbnails are generated and retrieved just fine. For example, I'm trying to retrieve a media with id
zOUYnsGQKLQypwBoQkRpnkXh
and corresponding filesystem idWFzEWtlvXlCaZShcaIthgzrG
. The media itself is stored at/var/lib/matrix-synapse/media/bc/remote_content/matrix.org/WF/zE/WtlvXlCaZShcaIthgzrG
and I can retrieve it from my server. The thumbnail should be located at/var/lib/matrix-synapse/media/bc/remote_thumbnail/matrix.org/WF/zE/WtlvXlCaZShcaIthgzrG/30-30-image-png
but it's actually stored at/var/lib/matrix-synapse/media/bc/remote_thumbnail/matrix.org/zO/UY/nsGQKLQypwBoQkRpnkXh/30-30-image-png
. Why do we even need two identifiers? It confuses things pretty much (it's hard to find an offending file in the storage if you know its id without looking it up in the database) and doesn't add any security.Version information
Version: 1.3.1+buster1
Install method: apt repository
The text was updated successfully, but these errors were encountered: