Rails ActiveStorage вариант IntegrityError для некоторых вариантов, но неизмененные изображения всегда показывают - PullRequest
1 голос
/ 24 февраля 2020

Моя производственная база данных использует S3 и ActiveRecord для хранения изображений.

С некоторого времени (может быть связано с обновлением rails 6, но я не уверен), многие старые изображения не показывают свои варианты. Некоторые более новые однако делают. Так что это не общая проблема.

Что меня удивляет, так это то, что не вариантное изображение всегда показывает

<p>
  Variant, does not show
</p>
<%= image_tag @asset.image.variant(resize_to_fit: [200,200]) %>
<hr>
<p>
  Original, shows
</p>
<%= image_tag @asset.image %>
<hr>

Журнал показывает:

  ActiveStorage::Blob Load (0.6ms)  SELECT "active_storage_blobs".* FROM "active_storage_blobs" WHERE "active_storage_blobs"."id" = $1 LIMIT $2  [["id", 23], ["LIMIT", 1]]
  S3 Storage (46.9ms) Checked if file exists at key: variants/assets/images/000/000/057/original/HOMEpg_PromoProd_990x660_microsite-Xplory.png/571109d233f5604a00cda0d8b8112d86e0bda9ff3c03f83cd9b25edbaf2dbed8 (no)
  S3 Storage (320.9ms) Downloaded file from key: assets/images/000/000/057/original/HOMEpg_PromoProd_990x660_microsite-Xplory.png
Completed 500 Internal Server Error in 374ms (ActiveRecord: 0.6ms | Allocations: 29916)



ActiveStorage::IntegrityError (ActiveStorage::IntegrityError):

activestorage (6.0.2.1) lib/active_storage/downloader.rb:39:in `verify_integrity_of'
activestorage (6.0.2.1) lib/active_storage/downloader.rb:14:in `block in open'
activestorage (6.0.2.1) lib/active_storage/downloader.rb:24:in `open_tempfile'
activestorage (6.0.2.1) lib/active_storage/downloader.rb:12:in `open'
activestorage (6.0.2.1) lib/active_storage/service.rb:86:in `open'
activestorage (6.0.2.1) app/models/active_storage/blob.rb:219:in `open'
activestorage (6.0.2.1) app/models/active_storage/variant.rb:99:in `process'
activestorage (6.0.2.1) app/models/active_storage/variant.rb:67:in `processed'
activestorage (6.0.2.1) app/controllers/active_storage/representations_controller.rb:12:in `show'
actionpack (6.0.2.1) lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
actionpack (6.0.2.1) lib/abstract_controller/base.rb:196:in `process_action'
actionpack (6.0.2.1) lib/action_controller/metal/rendering.rb:30:in `process_action'
actionpack (6.0.2.1) lib/abstract_controller/callbacks.rb:42:in `block in process_action'
activesupport (6.0.2.1) lib/active_support/callbacks.rb:135:in `run_callbacks'
actionpack (6.0.2.1) lib/abstract_controller/callbacks.rb:41:in `process_action'
actionpack (6.0.2.1) lib/action_controller/metal/rescue.rb:22:in `process_action'
actionpack (6.0.2.1) lib/action_controller/metal/instrumentation.rb:33:in `block in process_action'
activesupport (6.0.2.1) lib/active_support/notifications.rb:180:in `block in instrument'
activesupport (6.0.2.1) lib/active_support/notifications/instrumenter.rb:24:in `instrument'
activesupport (6.0.2.1) lib/active_support/notifications.rb:180:in `instrument'
actionpack (6.0.2.1) lib/action_controller/metal/instrumentation.rb:32:in `process_action'
actionpack (6.0.2.1) lib/action_controller/metal/params_wrapper.rb:245:in `process_action'
activerecord (6.0.2.1) lib/active_record/railties/controller_runtime.rb:27:in `process_action'
actionpack (6.0.2.1) lib/abstract_controller/base.rb:136:in `process'
actionview (6.0.2.1) lib/action_view/rendering.rb:39:in `process'
actionpack (6.0.2.1) lib/action_controller/metal.rb:191:in `dispatch'
actionpack (6.0.2.1) lib/action_controller/metal.rb:252:in `dispatch'
actionpack (6.0.2.1) lib/action_dispatch/routing/route_set.rb:51:in `dispatch'
actionpack (6.0.2.1) lib/action_dispatch/routing/route_set.rb:33:in `serve'
actionpack (6.0.2.1) lib/action_dispatch/journey/router.rb:49:in `block in serve'
actionpack (6.0.2.1) lib/action_dispatch/journey/router.rb:32:in `each'
actionpack (6.0.2.1) lib/action_dispatch/journey/router.rb:32:in `serve'
actionpack (6.0.2.1) lib/action_dispatch/routing/route_set.rb:837:in `call'
rack (2.1.2) lib/rack/tempfile_reaper.rb:17:in `call'
rack (2.1.2) lib/rack/etag.rb:27:in `call'
rack (2.1.2) lib/rack/conditional_get.rb:27:in `call'
rack (2.1.2) lib/rack/head.rb:14:in `call'
actionpack (6.0.2.1) lib/action_dispatch/http/content_security_policy.rb:18:in `call'
rack (2.1.2) lib/rack/session/abstract/id.rb:269:in `context'
rack (2.1.2) lib/rack/session/abstract/id.rb:263:in `call'
actionpack (6.0.2.1) lib/action_dispatch/middleware/cookies.rb:648:in `call'
activerecord (6.0.2.1) lib/active_record/migration.rb:567:in `call'
actionpack (6.0.2.1) lib/action_dispatch/middleware/callbacks.rb:27:in `block in call'
activesupport (6.0.2.1) lib/active_support/callbacks.rb:135:in `run_callbacks'
actionpack (6.0.2.1) lib/action_dispatch/middleware/callbacks.rb:26:in `call'
actionpack (6.0.2.1) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (6.0.2.1) lib/action_dispatch/middleware/actionable_exceptions.rb:17:in `call'
actionpack (6.0.2.1) lib/action_dispatch/middleware/debug_exceptions.rb:32:in `call'
web-console (4.0.1) lib/web_console/middleware.rb:132:in `call_app'
web-console (4.0.1) lib/web_console/middleware.rb:28:in `block in call'
web-console (4.0.1) lib/web_console/middleware.rb:17:in `catch'
web-console (4.0.1) lib/web_console/middleware.rb:17:in `call'
actionpack (6.0.2.1) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
railties (6.0.2.1) lib/rails/rack/logger.rb:38:in `call_app'
railties (6.0.2.1) lib/rails/rack/logger.rb:26:in `block in call'
activesupport (6.0.2.1) lib/active_support/tagged_logging.rb:80:in `block in tagged'
activesupport (6.0.2.1) lib/active_support/tagged_logging.rb:28:in `tagged'
activesupport (6.0.2.1) lib/active_support/tagged_logging.rb:80:in `tagged'
railties (6.0.2.1) lib/rails/rack/logger.rb:26:in `call'
sprockets-rails (3.2.1) lib/sprockets/rails/quiet_assets.rb:13:in `call'
actionpack (6.0.2.1) lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
request_store (1.5.0) lib/request_store/middleware.rb:19:in `call'
actionpack (6.0.2.1) lib/action_dispatch/middleware/request_id.rb:27:in `call'
rack (2.1.2) lib/rack/method_override.rb:24:in `call'
rack (2.1.2) lib/rack/runtime.rb:24:in `call'
activesupport (6.0.2.1) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
actionpack (6.0.2.1) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (6.0.2.1) lib/action_dispatch/middleware/static.rb:126:in `call'
rack (2.1.2) lib/rack/sendfile.rb:113:in `call'
actionpack (6.0.2.1) lib/action_dispatch/middleware/host_authorization.rb:83:in `call'
webpacker (4.2.2) lib/webpacker/dev_server_proxy.rb:23:in `perform_request'
rack-proxy (0.6.5) lib/rack/proxy.rb:57:in `call'
railties (6.0.2.1) lib/rails/engine.rb:526:in `call'
puma (3.12.2) lib/puma/configuration.rb:227:in `call'
puma (3.12.2) lib/puma/server.rb:674:in `handle_request'
puma (3.12.2) lib/puma/server.rb:476:in `process_client'
puma (3.12.2) lib/puma/server.rb:334:in `block in run'
puma (3.12.2) lib/puma/thread_pool.rb:135:in `block in spawn_thread'

Я исследовал IntegrityError, но и понимаю, о чем идет речь, но это все.

Итак, прежде всего я хотел бы понять, что здесь происходит и почему варианты нарушены. Во-вторых, я хотел бы знать, могу ли я каким-то образом исправить это ...

Я использую vips, но я раскомментировал это, и это ничего не изменило.

...