Skip to content

Commit c633411

Browse files
authored
Use isolated connection configurations in the output plugin (#152)
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 <h6a.h4i.0@gmail.com>
1 parent 15a0eff commit c633411

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

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)