Open ikus060 opened 3 years ago
The following patch fixes the issue:
--- read_write_database.rb.orig 2021-12-08 20:39:59.499527593 +0000
+++ read_write_database.rb 2021-12-08 20:42:32.960977605 +0000
@@ -63,12 +63,12 @@
def fill_local_table(loader)
begin
- @rwlock.writeLock().lock()
start = Time.now.to_f
records = loader.fetch
records_size = records.size
return if records_size.zero?
logger.info("loader #{loader.id}, fetched #{records_size} records in: #{(Time.now.to_f - start).round(3)} seconds")
+ @rwlock.writeLock().lock()
start = Time.now.to_f
import_file = ::File.join(loader.staging_directory, loader.table.to_s)
::File.open(import_file, "w") do |fd|
Logstash information:
docker image bitnami/logstash:7.10.1-debian-10-r35
JVM (e.g.
java -version
):N/A
OS version (
uname -a
if on a Unix-like system):N/A
Description of the problem including expected versus actual behavior:
When using jdbc_static to fetch a reasonable list of records from MySQL database, the pipeline is blocked while recrods get fetched. This causes peak CPU usage as schedule intervale.
I would expect the pipeline to be blocked only during the derby database refresh. Not during the fetching.
Provide logs (if relevant):
When the following line of code get printed, the pipeline stop processing.
While attached to the logstash process using JMX. Here the relevent Thread dumps. worker0 is block by "Ruby-0-Thread-21"
The problem seams to be related to Line 66: https://github.com/logstash-plugins/logstash-integration-jdbc/blob/master/lib/logstash/filters/jdbc/read_write_database.rb#L66
The write lock is aquired to early in the process. It should be aquired after fetching the records on Line 72