0

내 레일 애플리케이션에서 SidekiqAlgoliasearch을 사용할 때 이상한 문제가 발생했습니다.레일 : 작업자가 실패하고 증가하는 메모리 사용량

# A post model 

include AlgoliaSearch 
algoliasearch if: :published?, enqueue: :trigger_sidekiq_worker do 
    attributes :title, :subtitle, :content, :cached_votes_score, :cached_votes_total 

    # the `searchableAttributes` (formerly known as attributesToIndex) setting defines the attributes 
    # you want to search in: here `title`, `subtitle` & `description`. 
    # You need to list them by order of importance. `description` is tagged as 
    # `unordered` to avoid taking the position of a match into account in that attribute. 
    searchableAttributes ['title', 'subtitle', 'unordered(content)'] 

    # the `customRanking` setting defines the ranking criteria use to compare two matching 
    # records in case their text-relevance is equal. It should reflect your record popularity. 
    customRanking ['desc(cached_votes_score)', 'desc(cached_votes_total)'] 
end 

private 

def self.trigger_sidekiq_worker(record, remove) 
    ::Algolia::Blog::PostsWorker.perform_async(record.id, remove) 
end 

로그 : 그 행동은 다음과 같이 구성되어있는 경우

$ bundle exec sidekiq 


     m, 
     `$b 
    .ss, $$:   .,d$ 
    `$$P,d$P' .,md$P"' 
    ,$$$$$bmmd$$$P^' 
    .d$$$$$$$$$$P' 
    $$^' `"^$$$'  ____ _  _  _ _ 
    $:  ,$$:  /___|(_) __| | ___| | _(_) __ _ 
    `b  :$$  \___ \| |/ _` |/ _ \ |//|/ _` | 
      $$:   ___) | | (_| | __/ <| | (_| | 
      $$   |____/|_|\__,_|\___|_|\_\_|\__, | 
     .d$$          |_| 

Signal TTIN not supported 
Signal TSTP not supported 
Signal USR1 not supported 
Signal USR2 not supported 
2017-04-25T18:50:30.134Z 5596 TID-c0loo INFO: Running in ruby 2.3.3p222 (2016-11-21 revision 56859) [i386-mingw32] 
2017-04-25T18:50:30.134Z 5596 TID-c0loo INFO: See LICENSE and the LGPL-3.0 for licensing details. 
2017-04-25T18:50:30.135Z 5596 TID-c0loo INFO: Upgrade to Sidekiq Pro for more features and support: http://sidekiq.org 
2017-04-25T18:50:30.136Z 5596 TID-c0loo INFO: Booting Sidekiq 5.0.0 with redis options {:url=>nil} 
2017-04-25T18:50:30.138Z 5596 TID-c0loo INFO: Starting processing, hit Ctrl-C to stop 
2017-04-25T18:50:30.207Z 5596 TID-1nla70 Algolia::Blog::PostsWorker JID-262b2f8613a197637d05caf3 INFO: start 
2017-04-25T18:50:30.539Z 5596 TID-1nla70 Algolia::Blog::PostsWorker JID-262b2f8613a197637d05caf3 INFO: fail: 0.333 sec 
2017-04-25T18:50:30.540Z 5596 TID-1nla70 WARN: {"context":"Job raised exception","job":{"class":"Algolia::Blog::PostsWorker","args":[1,false],"retry":true,"queue":"default","jid":"262b2f8613a197637d05caf3","created_at":1493146072.768356,"enqueued_at":1493146072.768356,"error_message":"Couldn't find Blog::Post with 'id'=1","error_class":"ActiveRecord::RecordNotFound","failed_at":1493146230.538659,"retry_count":0},"jobstr":"{\"class\":\"Algolia::Blog::PostsWorker\",\"args\":[1,false],\"retry\":true,\"queue\":\"default\",\"jid\":\"262b2f8613a197637d05caf3\",\"created_at\":1493146072.768356,\"enqueued_at\":1493146072.768356}"} 
2017-04-25T18:50:30.541Z 5596 TID-1nla70 WARN: ActiveRecord::RecordNotFound: Couldn't find Blog::Post with 'id'=1 

모르겠다는 algolia 보인다 내가 sidekiq를 시작할 때마다

자동 내가 Algoliasearch로 구성된 모든 작업을 수행 내가 ID를 가진 레코드를 색인하려고 시도한다. 내가 이해하는 한, 레코드가 생성, 삭제 또는 업데이트 된 후에 만 ​​색인을 생성해야한다.

작업자가 실패하면 작업이 다시 시작되어 많은 메모리가 누적됩니다. 어떤 경우에는 모든 클래스와 네임 스페이스의 이름이 올바르게 지정되어 있는데도 LoadError이 표시됩니다.

Algolia 또는 Sidekiq에 문제가 있는지 알 수 없습니다.

답변

3

내 대기업에는 더 이상 존재하지 않는 개체를 인덱싱하는 작업이있을 것입니다.

대기열에서 올바르게 처리해야하며 왜 그렇지 않은지 잘 모르겠습니다.

사이드 키 큐를 지울 수 있습니까? 실행, 모든 대기열을 지우려면 :

Sidekiq::Queue.all.each &:clear 

을 콘솔에 다음 다시 시도하십시오.

+0

[algoliasearch-rails] (https://github.com/algolia/algoliasearch-rails) 보석 (Sidekiq과 함께 사용하고 있음)이 id가 '1'인 레코드를 색인하려고합니다. 사이드킥을 시작할 때마다. 그게 문제의 원인이라고 생각합니다. GitHub [여기] (https://github.com/algolia/algoliasearch-rails/issues/229)에서 문제를 열었습니다. – jonhue