search-engine-for-typesense 30.1.8.14 → 30.1.8.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 68b92138a4716df3c14da84a5f66b26f30bbdcb6afcb8d54f19d953c6652d1ed
4
- data.tar.gz: 7f21c4f3ea8216ad390494f9ca813a3829b80b15b8948f3ea5523f566d101368
3
+ metadata.gz: 6eb40e6492c7fdccdda9615cf69bea30cf50342b3ca84d72bf0558342ee99477
4
+ data.tar.gz: 7b9236e0737758ba468adc31c4f0c6785e408beb9b057602c8cf899243a0384f
5
5
  SHA512:
6
- metadata.gz: 0cec597cc88d5553ac833035e7e974ea3f6683d1efeaf1c2a2f2431f004c78a5ccfdee27e4eb22c513a0e95f8c2275e28b2b2158fb6d8d95b3846328f45633e4
7
- data.tar.gz: 0a3d95f6df6dba0f0ea9bbdb93fe6224a3b5b2d7cefa0907504273a004c095750f1a9a9f7d67b3e60180dcbf019a01ab55bd137fc5cde563c76c28634a401e3b
6
+ metadata.gz: 99c76462daf9001f8fe5ad7118e5c9723a62fa780456b836669d82769d3b8d13c8d9f23a156bddb91aa8d731f14fc458d1e6ae293f91f1699511c40c808bf7d7
7
+ data.tar.gz: b06ebee63629801c9b7988501f77b3c231acf382fa4d87ad89f7784d55c060b0a23cf4dd7e27b3de9660cf10983a1f34828eddb61b778864373120945fa9fb0b
@@ -42,6 +42,7 @@ module SearchEngine
42
42
  slot = drain_slot.to_i
43
43
  effective_limit = limit || SearchEngine.config.postgres_outbox.batch_size
44
44
  repository = repository_for_slot
45
+ slot_requeued = false
45
46
  return stale_slot_summary(target.key, slot) unless repository.start_drain_slot!(
46
47
  target_key: target.key,
47
48
  slot: slot,
@@ -55,13 +56,16 @@ module SearchEngine
55
56
  slot: slot,
56
57
  worker_id: worker_id
57
58
  )
58
- enqueue_target_continuation(limit: limit, target_key: target.key, drain_slot: slot) if requeued
59
+ if requeued
60
+ slot_requeued = true
61
+ enqueue_requeued_slot_continuation(repository, target.key, slot, limit: limit)
62
+ end
59
63
  else
60
64
  repository.release_drain_slot!(target_key: target.key, slot: slot, worker_id: worker_id)
61
65
  end
62
66
  summary
63
67
  rescue StandardError => error
64
- if repository && target && slot
68
+ if repository && target && slot && !slot_requeued
65
69
  repository.release_drain_slot!(target_key: target.key, slot: slot, worker_id: worker_id, error: error)
66
70
  end
67
71
  raise
@@ -88,6 +92,13 @@ module SearchEngine
88
92
  summary
89
93
  end
90
94
 
95
+ def enqueue_requeued_slot_continuation(repository, target_key, slot, limit:)
96
+ enqueue_target_continuation(limit: limit, target_key: target_key, drain_slot: slot)
97
+ rescue StandardError => error
98
+ repository.release_requeued_drain_slot!(target_key: target_key, slot: slot, error: error)
99
+ raise
100
+ end
101
+
91
102
  def continue_draining?(summary, effective_limit)
92
103
  summary[:continue] || summary[:claimed].to_i >= effective_limit.to_i
93
104
  end
@@ -222,6 +222,27 @@ module SearchEngine
222
222
  SQL
223
223
  end
224
224
 
225
+ # Release a queued slot when a follow-up job could not be enqueued.
226
+ #
227
+ # @param target_key [String, Symbol]
228
+ # @param slot [Integer]
229
+ # @param error [Exception, String, nil]
230
+ # @return [void]
231
+ def release_requeued_drain_slot!(target_key:, slot:, error: nil)
232
+ execute(<<~SQL)
233
+ UPDATE #{quoted_drain_slot_table}
234
+ SET status = 'idle',
235
+ locked_at = NULL,
236
+ locked_by = NULL,
237
+ finished_at = CURRENT_TIMESTAMP,
238
+ last_error = #{quote(error.nil? ? nil : truncate_error(error))},
239
+ updated_at = CURRENT_TIMESTAMP
240
+ WHERE target_key = #{quote(target_key)}
241
+ AND slot = #{slot.to_i}
242
+ AND status = 'queued'
243
+ SQL
244
+ end
245
+
225
246
  private
226
247
 
227
248
  attr_reader :target_key
@@ -3,5 +3,5 @@
3
3
  module SearchEngine
4
4
  # Current gem version.
5
5
  # @return [String]
6
- VERSION = '30.1.8.14'
6
+ VERSION = '30.1.8.15'
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: search-engine-for-typesense
3
3
  version: !ruby/object:Gem::Version
4
- version: 30.1.8.14
4
+ version: 30.1.8.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nikita Shkoda