deimos-ruby 2.5.1 → 2.5.3

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: bb760f9bdfc09803add56c38f786d3328cf67f797223458bcef0fc396a81661e
4
- data.tar.gz: 3ef94bb9b7f94303c82dbfd7728e92bb53e400e4de2f42d1b7c0fab84bed6850
3
+ metadata.gz: 634ebcbb254c467794eae6a3971200e2647472769eb59b6e8e89ed9453c3b203
4
+ data.tar.gz: a72e4063b395f3a5388bc2988b3780e8fb9a8aa9052152f7c08b1f3469fc63f3
5
5
  SHA512:
6
- metadata.gz: 686616760e7bc0ae6a019885058b8b8446cf4b5ef187d1908c16755ec92fb4efecbd3e63719837fd351c332e9f22c4e5ce46e928b3bd45a10dccb547c5344599
7
- data.tar.gz: 29697e83e3fb628b625a9ffd8af5357d2d452bef473d8ce6a9decb6519539be681a1fd49d1c8f17e61c75e277eeb293e9443a4158f0601110f843849f3813d24
6
+ metadata.gz: 1205344ccc7c9f97b5b0496e950d5a5e385654c0e1192ba8d6e1fa6f6c01fdd2a84c88f1980c587f2623717ca5eafd6562fc3fb713f3cd04b0d54d3382645385
7
+ data.tar.gz: 15589b978f07ce93acfda561f8e8cb75f6a9ad1be25efd77942b5c04b9404237112c9668a1b6f295c94983848fcb18916b0c32a134daa208b8d7343ef845ee5b
data/CHANGELOG.md CHANGED
@@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## Unreleased
9
9
 
10
+ ## 2.5.3 - 2026-04-28
11
+
12
+ - Fix: `setup_karafka` applies the merged kafka config to `Karafka.producer`, so kafka overrides set in later `Karafka::App.setup` calls take effect on `Karafka.producer` callers (Karafka::Web, DLQ, ActiveJob).
13
+
14
+ ## 2.5.2 - 2026-04-24
15
+
16
+ - Fix: `BatchRecordList#fill_primary_keys!` no longer short-circuits on stale in-memory primary keys left over from a rolled-back `DeadlockRetry` attempt, preventing `ActiveRecord::InvalidForeignKey` during association imports.
17
+
10
18
  ## 2.5.1 - 2026-03-18
11
19
 
12
20
  - Fix: Outbox producer would swallow ActiveRecord errors except for uniqueness.
@@ -16,6 +16,8 @@ module Deimos
16
16
  attr_accessor :bulk_import_id
17
17
  # @return [String] The column name to use for bulk IDs - defaults to `bulk_import_id`.
18
18
  attr_accessor :bulk_import_column
19
+ # @return [Boolean] true if the primary key was supplied in the input attributes,
20
+ attr_accessor :primary_key_preset
19
21
 
20
22
  delegate :valid?, :errors, :send, :attributes, to: :record
21
23
 
@@ -32,6 +34,7 @@ module Deimos
32
34
  end
33
35
  attributes = attributes.with_indifferent_access
34
36
  self.record = klass.new(attributes.slice(*klass.column_names))
37
+ self.primary_key_preset = !self.record[klass.primary_key].nil?
35
38
  assoc_keys = attributes.keys.select { |k| klass.reflect_on_association(k) }
36
39
  # a hash with just the association keys, removing all actual column information.
37
40
  self.associations = attributes.slice(*assoc_keys)
@@ -53,7 +53,8 @@ module Deimos
53
53
  def fill_primary_keys!
54
54
  primary_col = self.klass.primary_key
55
55
 
56
- return if self.batch_records.empty? || self.batch_records.first.send(primary_col).present?
56
+ # Skip if nothing to backfill or caller already supplied the PK.
57
+ return if self.batch_records.empty? || self.batch_records.first.primary_key_preset
57
58
 
58
59
  bulk_import_map = self.klass.
59
60
  where(self.bulk_import_column => self.batch_records.map(&:bulk_import_id)).
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Deimos
4
- VERSION = '2.5.1'
4
+ VERSION = '2.5.3'
5
5
  end
data/lib/deimos.rb CHANGED
@@ -191,6 +191,10 @@ module Deimos
191
191
  end
192
192
  @producers[topic.name] = producers_by_broker[broker]
193
193
  end
194
+ # Karafka.producer's kafka config is captured at first Karafka::App.setup;
195
+ # apply the merged global so later overrides actually take effect.
196
+ Karafka.producer.config.kafka =
197
+ Karafka::Setup::AttributesMap.producer(Karafka::Setup::Config.config.kafka.dup)
194
198
  end
195
199
 
196
200
  def setup_karafka
@@ -112,6 +112,34 @@ RSpec.describe Deimos::ActiveRecordConsume::MassUpdater do
112
112
  expect(Detail.count).to eq(0)
113
113
  end
114
114
 
115
+ it 'should refetch parent primary keys when retrying child import' do
116
+ allow(Widget).to receive(:import!).and_call_original
117
+ allow(Widget).to receive(:where).and_call_original
118
+
119
+ # Deadlock the first child import to trigger DeadlockRetry; let the retry pass through.
120
+ detail_call_count = 0
121
+ allow(Detail).to receive(:import!).and_wrap_original do |m, *args|
122
+ detail_call_count += 1
123
+ raise ActiveRecord::Deadlocked, 'Lock wait timeout exceeded' if detail_call_count == 1
124
+
125
+ m.call(*args)
126
+ end
127
+
128
+ described_class.new(Widget, bulk_import_id_generator: bulk_id_generator).mass_update(batch)
129
+
130
+ # Parent ids written by `fill_primary_keys!` during attempt 1 stay in
131
+ # memory after the DB rollback, so they're stale on retry. Assert the
132
+ # retry re-queries. Outcome-level checks are unreliable: SQLite reuses
133
+ # rolled-back ids so stale memory matches coincidentally; MySQL and
134
+ # Postgres burn auto-increment and surface ActiveRecord::InvalidForeignKey.
135
+ expect(Widget).to have_received(:where).
136
+ with(bulk_import_id: [instance_of(String), instance_of(String)]).twice
137
+ expect(Widget.count).to eq(2)
138
+ expect(Detail.count).to eq(2)
139
+ expect(Widget.first.detail).not_to be_nil
140
+ expect(Widget.last.detail).not_to be_nil
141
+ end
142
+
115
143
  end
116
144
 
117
145
  context 'with save_associations_first' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deimos-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.1
4
+ version: 2.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Orner