From 33927e061855f9fce92774781cece60568b269d8 Mon Sep 17 00:00:00 2001 From: Miles Zhang Date: Thu, 5 Dec 2024 20:07:35 +0900 Subject: [PATCH] fix: keep unique analyze job (#2310) Signed-off-by: Miles Zhang --- app/workers/analyze_contract_from_cell_dependency_worker.rb | 3 ++- config/sidekiq.yml | 3 +++ lib/scheduler.rb | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/workers/analyze_contract_from_cell_dependency_worker.rb b/app/workers/analyze_contract_from_cell_dependency_worker.rb index 9c2edd825..fb01a2782 100644 --- a/app/workers/analyze_contract_from_cell_dependency_worker.rb +++ b/app/workers/analyze_contract_from_cell_dependency_worker.rb @@ -1,12 +1,13 @@ class AnalyzeContractFromCellDependencyWorker include Sidekiq::Worker + sidekiq_options queue: "contract", retry: 0 def perform cell_deps_out_points_attrs = Set.new contract_attrs = Set.new cell_deps_attrs = Set.new - CellDependency.where(contract_analyzed: false).where.not(block_number: nil).order("block_number desc").limit(1000).each do |cell_dep| + CellDependency.where(contract_analyzed: false).where.not(block_number: nil).limit(1000).each do |cell_dep| cell_deps_attrs << { contract_analyzed: true, ckb_transaction_id: cell_dep.ckb_transaction_id, contract_cell_id: cell_dep.contract_cell_id, dep_type: cell_dep.dep_type } next if CellDepsOutPoint.where(contract_cell_id: cell_dep.contract_cell_id).exists? diff --git a/config/sidekiq.yml b/config/sidekiq.yml index 7054f09af..f151bd024 100644 --- a/config/sidekiq.yml +++ b/config/sidekiq.yml @@ -7,6 +7,9 @@ - bitcoin - fiber - low + - contract +:limits: + contract: 1 production: :concurrency: 20 diff --git a/lib/scheduler.rb b/lib/scheduler.rb index 9afe16d6f..e5f6efb5f 100644 --- a/lib/scheduler.rb +++ b/lib/scheduler.rb @@ -128,7 +128,7 @@ def call_worker(clz) call_worker GenerateUdtHolderAllocationWorker end -s.every "5s", overlap: false do +s.every "10s", overlap: false do call_worker AnalyzeContractFromCellDependencyWorker end