Skip to content

Commit 9ce3b11

Browse files
committed
Use isolated connection configurations in the output plugin
Modify to use isolated connection configurations for each plugin instance. The previous implementation had an issue where incorrect connections were used due to ActiveRecord's connection pooling mechanism when the output plugin was used multiple times. Signed-off-by: Haruki Hasegawa <[email protected]>
1 parent 66e411b commit 9ce3b11

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/fluent/plugin/out_sql.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ def start
206206
end
207207

208208
SQLOutput.const_set("BaseModel_#{rand(1 << 31)}", @base_model)
209-
ActiveRecord::Base.establish_connection(config)
209+
@base_model.establish_connection(config)
210210

211211
# ignore tables if TableElement#init failed
212212
@tables.reject! do |te|
@@ -224,7 +224,7 @@ def formatted_to_msgpack_binary
224224
end
225225

226226
def write(chunk)
227-
ActiveRecord::Base.connection_pool.with_connection do
227+
@base_model.connection_pool.with_connection do
228228

229229
@tables.each { |table|
230230
tag = format_tag(chunk.metadata.tag)

0 commit comments

Comments
 (0)