Browse Source

Maintenance: Perform SearchIndexJob and SearchIndexAssociationsJob actions to reduce job numbers.

Thorsten Eckel 3 years ago
parent
commit
f06dc08502

+ 1 - 0
app/jobs/search_index_associations_job.rb

@@ -1,6 +1,7 @@
 class SearchIndexAssociationsJob < SearchIndexJob
 
   def update_search_index(record)
+    super
     record.search_index_update_associations_delta
     record.search_index_update_associations_full
   end

+ 0 - 1
app/models/concerns/has_search_index_backend.rb

@@ -24,7 +24,6 @@ update search index, if configured - will be executed automatically
     # start background job to transfer data to search index
     return true if !SearchIndexBackend.enabled?
 
-    SearchIndexJob.perform_later(self.class.to_s, id)
     SearchIndexAssociationsJob.perform_later(self.class.to_s, id)
     true
   end

+ 2 - 2
spec/models/concerns/has_search_index_backend_examples.rb

@@ -14,13 +14,13 @@ RSpec.shared_examples 'HasSearchIndexBackend' do |indexed_factory:|
       end
 
       it 'indexes on create' do
-        expect(SearchIndexJob).to have_been_enqueued
+        expect(SearchIndexAssociationsJob).to have_been_enqueued
       end
 
       it 'indexes on update' do
         clear_jobs
         subject.update(note: 'Updated')
-        expect(SearchIndexJob).to have_been_enqueued
+        expect(SearchIndexAssociationsJob).to have_been_enqueued
       end
 
       it 'indexes on touch' do

+ 4 - 4
spec/requests/integration/monitoring_spec.rb

@@ -610,7 +610,7 @@ RSpec.describe 'Monitoring', type: :request do
       expect(json_response['message']).to be_truthy
       expect(json_response['issues']).to be_truthy
       expect(json_response['healthy']).to eq(false)
-      expect( json_response['message']).to eq("Failed to run background job #1 'SearchIndexAssociationsJob' 1 time(s) with 1 attempt(s).;Failed to run background job #2 'SearchIndexJob' 1 time(s) with 1 attempt(s).")
+      expect( json_response['message']).to eq("Failed to run background job #1 'SearchIndexAssociationsJob' 1 time(s) with 1 attempt(s).")
 
       # add another job
       manual_added = SearchIndexJob.perform_later('Ticket', 1)
@@ -624,7 +624,7 @@ RSpec.describe 'Monitoring', type: :request do
       expect(json_response['message']).to be_truthy
       expect(json_response['issues']).to be_truthy
       expect(json_response['healthy']).to eq(false)
-      expect( json_response['message']).to eq("Failed to run background job #1 'SearchIndexAssociationsJob' 1 time(s) with 1 attempt(s).;Failed to run background job #2 'SearchIndexJob' 2 time(s) with 11 attempt(s).")
+      expect( json_response['message']).to eq("Failed to run background job #1 'SearchIndexAssociationsJob' 1 time(s) with 1 attempt(s).;Failed to run background job #2 'SearchIndexJob' 1 time(s) with 10 attempt(s).")
 
       # add another job
       dummy_class = Class.new(ApplicationJob) do
@@ -645,7 +645,7 @@ RSpec.describe 'Monitoring', type: :request do
       expect(json_response['message']).to be_truthy
       expect(json_response['issues']).to be_truthy
       expect(json_response['healthy']).to eq(false)
-      expect(json_response['message']).to eq("Failed to run background job #1 'Object' 1 time(s) with 5 attempt(s).;Failed to run background job #2 'SearchIndexAssociationsJob' 1 time(s) with 1 attempt(s).;Failed to run background job #3 'SearchIndexJob' 2 time(s) with 11 attempt(s).")
+      expect(json_response['message']).to eq("Failed to run background job #1 'Object' 1 time(s) with 5 attempt(s).;Failed to run background job #2 'SearchIndexAssociationsJob' 1 time(s) with 1 attempt(s).;Failed to run background job #3 'SearchIndexJob' 1 time(s) with 10 attempt(s).")
 
       # reset settings
       Setting.set('es_url', prev_es_config)
@@ -664,7 +664,7 @@ RSpec.describe 'Monitoring', type: :request do
       expect(json_response['message']).to be_truthy
       expect(json_response['issues']).to be_truthy
       expect(json_response['healthy']).to eq(false)
-      expect(json_response['message']).to eq("14 failing background jobs;Failed to run background job #1 'Object' 7 time(s) with 35 attempt(s).;Failed to run background job #2 'SearchIndexAssociationsJob' 1 time(s) with 1 attempt(s).;Failed to run background job #3 'SearchIndexJob' 2 time(s) with 11 attempt(s).")
+      expect(json_response['message']).to eq("13 failing background jobs;Failed to run background job #1 'Object' 8 time(s) with 40 attempt(s).;Failed to run background job #2 'SearchIndexAssociationsJob' 1 time(s) with 1 attempt(s).;Failed to run background job #3 'SearchIndexJob' 1 time(s) with 10 attempt(s).")
 
       # cleanup
       Delayed::Job.delete_all