Hi all,
I’m facing a strange issue with Discourse + S3 storage.
When uploading avatars, I get an error like the one below — even though the file does exist on the S3 bucket and is accessible via a valid s3_cdn_url
.
Uploads for posts and attachments work perfectly. The only thing that fails is user avatar uploads.
Error message from gig.ovh/logs
Message (2 copies reported)
Could not find file in the store located at url: //gig.s3.ru-1.storage.selcloud.ru/original/1X/fd42dfa3362b66090450f2ae40f0917193fcd355.jpeg
Backtrace
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/activesupport-7.2.2.1/lib/active\_support/broadcast\_logger.rb:134\:in `block in error'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/activesupport-7.2.2.1/lib/active_support/broadcast_logger.rb:231:in `block in dispatch'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/activesupport-7.2.2.1/lib/active\_support/broadcast\_logger.rb:231\:in `each'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/activesupport-7.2.2.1/lib/active_support/broadcast_logger.rb:231:in `dispatch'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/activesupport-7.2.2.1/lib/active\_support/broadcast\_logger.rb:134\:in `error'
/var/www/discourse/app/models/optimized_image.rb:91:in `block in create\_for'
/var/www/discourse/app/models/optimized\_image.rb:19\:in `block (2 levels) in lock'
/var/www/discourse/lib/distributed_mutex.rb:53:in `block in synchronize'
/var/www/discourse/lib/distributed\_mutex.rb:49\:in `synchronize'
/var/www/discourse/lib/distributed_mutex.rb:49:in `synchronize'
/var/www/discourse/lib/distributed\_mutex.rb:34\:in `synchronize'
/var/www/discourse/app/models/optimized_image.rb:19:in `block in lock'
/var/www/discourse/lib/distributed\_mutex.rb:53\:in `block in synchronize'
/var/www/discourse/lib/distributed_mutex.rb:49:in `synchronize'
/var/www/discourse/lib/distributed\_mutex.rb:49\:in `synchronize'
/var/www/discourse/lib/distributed_mutex.rb:34:in `synchronize'
/var/www/discourse/app/models/optimized\_image.rb:18\:in `lock'
/var/www/discourse/app/models/optimized_image.rb:83:in `create\_for'
/var/www/discourse/app/models/upload.rb:151\:in `get_optimized_image'
/var/www/discourse/app/controllers/user_avatars_controller.rb:219:in `get\_optimized\_image'
/var/www/discourse/app/controllers/user\_avatars\_controller.rb:137\:in `show_in_site'
/var/www/discourse/app/controllers/user_avatars_controller.rb:90:in `block (2 levels) in show'
/var/www/discourse/lib/hijack.rb:68\:in `instance_eval'
/var/www/discourse/lib/hijack.rb:68:in `block (2 levels) in hijack'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/i18n-1.14.7/lib/i18n.rb:353\:in `with_locale'
/var/www/discourse/lib/hijack.rb:68:in `block in hijack'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.3.5/lib/concurrent-ruby/concurrent/promises.rb:911\:in `callback_on_resolution'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.3.5/lib/concurrent-ruby/concurrent/promises.rb:797:in `call\_callback'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.3.5/lib/concurrent-ruby/concurrent/promises.rb:803\:in `call_callbacks'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.3.5/lib/concurrent-ruby/concurrent/promises.rb:692:in `resolve\_with'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.3.5/lib/concurrent-ruby/concurrent/promises.rb:1325\:in `resolve'
/var/www/discourse/lib/scheduler/defer.rb:125:in `block in do\_work'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/rails\_multisite-6.1.0/lib/rails\_multisite/connection\_management/null\_instance.rb:49\:in `with_connection'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/rails_multisite-6.1.0/lib/rails_multisite/connection_management.rb:21:in `with\_connection'
/var/www/discourse/lib/scheduler/defer.rb:119\:in `do_work'
/var/www/discourse/lib/scheduler/defer.rb:105:in `block (2 levels) in start\_thread'
That is an S3 URL for the container
//gig.s3.ru-1.storage.selcloud.ru/original/1X/fd42dfa3362b66090450f2ae40f0917193fcd355.jpeg
The image is available at URL:
https://s3.gig.ovh/original/1X/fd42dfa3362b66090450f2ae40f0917193fcd355.jpeg
Additional Info
- Discourse version: (latest stable)
- External S3-compatible storage used (
enable_s3_uploads = true
) s3_cdn_url
is correctly configured and used- CDN URL successfully returns the file
- File is confirmed present at the expected S3 location
- Other uploads (images, attachments, etc.) work fine
- The error only occurs with user avatars
Question
What could cause Discourse to fail to retrieve the file for avatar processing while the exact file exists and is reachable via the correct CDN URL?
Is there something specific to avatar processing (like get_optimized_image
) that could be misconfigured or cached incorrectly?
Any suggestions or insight would be appreciated!
Thanks