Jobs::ProcessPost 실행 중
명령줄에서 재현할 수 있습니다:
반면, 다음 방법으로 성공적으로 접근할 수 있습니다:
다음과 관련이 있을 것 같습니다:
committed 01:28PM - 23 May 22 UTC
Previously, with the default `editing_grace_period`, hotlinked images were pulle… d 5 minutes after a post is created. This delay was added to reduce the chance of automated edits clashing with user edits.
This commit refactors things so that we can pull hotlinked images immediately. URLs are immediately updated in the post's `cooked` HTML. The post's raw markdown is updated later, after the `editing_grace_period`.
This involves a number of behind-the-scenes changes including:
- Schedule Jobs::PullHotlinkedImages immediately after Jobs::ProcessPost. Move scheduling to after the `update_column` call to avoid race conditions
- Move raw changes into a separate job, which is delayed until after the ninja-edit window
- Move disable_if_low_on_disk_space logic into the `pull_hotlinked_images` job
- Move raw-parsing/replacing logic into `InlineUpload` so it can be easily be shared between `UpdateHotlinkedRaw` and `PullUserProfileHotlinkedImages`
해당 커밋에는 다음이 포함되어 있습니다:
end
end
# onebox may have added some links, so extract them now
def extract_links(post)
TopicLink.extract_from(post)
QuotedPost.extract_from(post)
end
def enqueue_pull_hotlinked_images(post)
Jobs.cancel_scheduled_job(:pull_hotlinked_images, post_id: post.id)
Jobs.enqueue(:pull_hotlinked_images, post_id: post.id)
end
end
end
이 컨텍스트에서 앞에 ::가 필요한 것일까요?
david
(David Taylor)
5월 26, 2022, 11:35오전
2
음, 앞에 ::를 붙이면 확실히 해결되긴 하겠지만… 그렇게 해야 하는 건 아니어야 하는데
호출이 ::Jobs::ProcessPost 내부에서 발생하고 있으므로, Ruby는 트리 구조를 따라 위로 올라가며 탐색해야 합니다. 먼저 ::Jobs::ProcessPost::Jobs를 찾고, 다음으로 ::Jobs::Jobs를 찾은 후, 결국 ::Jobs 모듈을 찾아야 합니다.
보시는 에러는 ::Jobs::Jobs가 어딘가에 정의되어 있다는 것을 시사하는데… 이건 좀 이상하네요! 제 개발 인스턴스에서 확인해 보니:
[1] pry(main)> Jobs::Jobs
=> Jobs::Jobs
[2] pry(main)> Jobs::Jobs.constants
=> [:RemapOldBotImages, :GrantBadges]
discourse-narrative-bot의 이 라인들이 문제를 일으키는 것 같습니다. 주석 처리하면 문제가 해결됩니다.
if Rails.env == "development"
# workaround, teach reloader to reload jobs
# if we do not do this then
#
# 1. on reload rails goes and undefines Jobs::Base
# 2. as a side effect this undefines Jobs::BotInput
# 3. we have a post_edited hook that queues a job for bot input
# 4. if you are not running sidekiq in dev every time you save a post it will trigger it
# 5. but the constant can not be autoloaded
Rails.configuration.autoload_paths << File.expand_path('../autoload', __FILE__)
end
좋은 소식은 개발 환경에서만 발생하는 문제라는 점입니다. 잡(job)의 파일 경로가 모듈 이름과 일치하지 않아서 발생하는 문제입니다. 정리하기 위한 PR을 올렸습니다:
main ← narritive-bot-autoload
merged 12:19PM - 26 May 22 UTC
These incorrect paths were causing the regular jobs to be loaded in a `Jobs::Job… s` module in development mode, which would cause various weird issues.
https://meta.discourse.org/t/228155
리포트해 주셔서 감사합니다 @merefield
아, 그렇군요. 이상하네요. 프로덕션이 터지지 않은 이유가 설명이 되네요!
빠른 답변 감사합니다!!