Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds dependency to Derby (without renaming) and also add derbytools dependency #160

Merged
merged 7 commits into from
Mar 21, 2024

Conversation

andsel
Copy link
Contributor

@andsel andsel commented Mar 7, 2024

Release notes

Fix Derby missed driver classes when built locally for version 10.15.

What does this PR do?

Adds missed Derby jars that contain part of the driver, in particular derbytools jar.

  • copy the missed jars into the local_repository for vendoring
  • remove usage of old jdbc-derby gems that bundled old Derby driver which made the tests works in the past and hidden the bug of not adding all the Derby jars properly.
  • Expose the Derby version in a file which can be reused both from Gradle and Rspec test

Why is it important/What is the impact to the user?

Permit to the user to effectively use the locally built Derby driver.

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • [ ] I have made corresponding changes to the documentation
  • [ ] I have made corresponding change to the default configuration files (and/or docker env variables)
  • [ ] I have added tests that prove my fix is effective or that my feature works

Author's Checklist

  • run with Logstash instance

How to test this PR locally

  1. vendor this gem on this PR
./gradlew clean vendor
  1. configure Logstash to use it, edit Gemfile adding
gem "logstash-integration-jdbc", :path => "/Users/andrea/workspace/logstash_plugins/logstash-integration-jdbc"

and run

bin/logstash-plugin install --no-verify
  1. run a dockerized MySQL server, for example use: https://github.com/andsel/logstash_jdbc_test
  2. run Logstash with pipeline, setting the path to a local mysql jar driver
input {
  generator {
    message => "DEBUG"
    count => 1
    add_field => {"[@metadata][foo]" => "BAR"}
  }
}

filter {
  jdbc_static {
    jdbc_driver_library => "/path/to/mysql-connector-java-8.0.26.jar"
    jdbc_driver_class => "Java::com.mysql.cj.jdbc.Driver"
    jdbc_connection_string => "jdbc:mysql://localhost:3306/test_logstash"

    jdbc_user => "andrea"
    jdbc_password => "password"

    loaders => [
      {
        id => "remote-data_log"
        query => "select log_id, event_type from data_log"
        local_table => "data_log"
      }
    ]

    local_db_objects => [
      {
        name => "data_log"
        index_columns => ["log_id"]
        columns => [
          ["log_id", "int"],
          ["event_type", "varchar(255)"]
        ]
      }
    ]

    local_lookups => [
      {
        id => "local-data_log"
        query => "SELECT log_id FROM data_log WHERE event_type = :event_type"
        parameters => {event_type => "[message]"}
        target => "data_log"
      }
    ]
  }
}


output {
  stdout {
    codec => "rubydebug"
  }
}
  1. Verify that it works while fails without this PR.

Related issues

Logs

[2024-03-14T17:03:09,983][INFO ][logstash.javapipeline    ] Pipeline `main` is configured with `pipeline.ecs_compatibility: v8` setting. All plugins in this pipeline will default to `ecs_compatibility => v8` unless explicitly configured otherwise.
[2024-03-14T17:03:09,988][INFO ][logstash.filters.jdbcstatic][main] derby.system.home is: /Users/andrea/workspace/logstash_andsel/data/plugins/shared/derby_home
[2024-03-14T17:03:10,150][ERROR][logstash.javapipeline    ][main] Pipeline error {:pipeline_id=>"main", :exception=>#<LogStash::Filters::Jdbc::ConnectionJdbcException: org.apache.derby.jdbc.EmbeddedDriver not loaded>, :backtrace=>["/Users/andrea/workspace/logstash_andsel/vendor/bundle/jruby/3.1.0/gems/sequel-5.78.0/lib/sequel/adapters/jdbc.rb:66:in `load_driver'", "/Users/andrea/workspace/logstash_andsel/vendor/bundle/jruby/3.1.0/gems/logstash-integration-jdbc-5.4.8/lib/logstash/filters/jdbc/basic_database.rb:98:in `verify_connection'", "/Users/andrea/workspace/logstash_andsel/vendor/bundle/jruby/3.1.0/gems/logstash-integration-jdbc-5.4.8/lib/logstash/filters/jdbc/read_write_database.rb:58:in `post_create'", "/Users/andrea/workspace/logstash_andsel/vendor/bundle/jruby/3.1.0/gems/logstash-integration-jdbc-5.4.8/lib/logstash/filters/jdbc/basic_database.rb:33:in `create'", "/Users/andrea/workspace/logstash_andsel/vendor/bundle/jruby/3.1.0/gems/logstash-integration-jdbc-5.4.8/lib/logstash/filters/jdbc/lookup_processor.rb:36:in `initialize'", "org/jruby/RubyClass.java:935:in `new'", "/Users/andrea/workspace/logstash_andsel/vendor/bundle/jruby/3.1.0/gems/logstash-integration-jdbc-5.4.8/lib/logstash/filters/jdbc_static.rb:207:in `prepare_runner'", "/Users/andrea/workspace/logstash_andsel/vendor/bundle/jruby/3.1.0/gems/logstash-integration-jdbc-5.4.8/lib/logstash/filters/jdbc_static.rb:158:in `register'", "org/logstash/config/ir/compiler/AbstractFilterDelegatorExt.java:75:in `register'", "/Users/andrea/workspace/logstash_andsel/logstash-core/lib/logstash/java_pipeline.rb:237:in `block in register_plugins'", "org/jruby/RubyArray.java:1983:in `each'", "/Users/andrea/workspace/logstash_andsel/logstash-core/lib/logstash/java_pipeline.rb:236:in `register_plugins'", "/Users/andrea/workspace/logstash_andsel/logstash-core/lib/logstash/java_pipeline.rb:611:in `maybe_setup_out_plugins'", "/Users/andrea/workspace/logstash_andsel/logstash-core/lib/logstash/java_pipeline.rb:249:in `start_workers'", "/Users/andrea/workspace/logstash_andsel/logstash-core/lib/logstash/java_pipeline.rb:194:in `run'", "/Users/andrea/workspace/logstash_andsel/logstash-core/lib/logstash/java_pipeline.rb:146:in `block in start'"], "pipeline.sources"=>["/Users/andrea/workspace/logstash_configs/jdbc/mysql_pipeline_filter.conf"], :thread=>"#<Thread:0x6c547cce /Users/andrea/workspace/logstash_andsel/logstash-core/lib/logstash/java_pipeline.rb:134 run>"}
[2024-03-14T17:03:10,151][INFO ][logstash.javapipeline    ][main] Pipeline terminated {"pipeline.id"=>"main"}
[2024-03-14T17:03:10,166][ERROR][logstash.agent           ] Failed to execute action {:id=>:main, :action_type=>LogStash::ConvergeResult::FailedAction, :message=>"Could not execute action: PipelineAction::Create<main>, action_result: false", :backtrace=>nil}
[2024-03-14T17:03:10,170][INFO ][logstash.runner          ] Logstash shut down.
[2024-03-14T17:03:10,171][FATAL][org.logstash.Logstash    ] Logstash stopped processing because of an error: (SystemExit) exit
org.jruby.exceptions.SystemExit: (SystemExit) exit
	at org.jruby.RubyKernel.exit(org/jruby/RubyKernel.java:912) ~[jruby.jar:?]
	at org.jruby.RubyKernel.exit(org/jruby/RubyKernel.java:871) ~[jruby.jar:?]
	at Users.andrea.workspace.logstash_andsel.lib.bootstrap.environment.<main>(/Users/andrea/workspace/logstash_andsel/lib/bootstrap/environment.rb:90) ~[?:?]

@andsel andsel changed the title Adds dependy to derby (without renaming) and also add derbytools dependency Adds dependency to Derby (without renaming) and also add derbytools dependency Mar 14, 2024
@andsel andsel force-pushed the fix/missed_derbyclasses branch from 9ae2424 to f4c7909 Compare March 14, 2024 09:20
@andsel andsel added the bug Something isn't working label Mar 14, 2024
@andsel andsel marked this pull request as ready for review March 14, 2024 17:58
Copy link
Member

@jsvd jsvd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jsvd jsvd merged commit f860943 into logstash-plugins:main Mar 21, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Apache Derby fails in 8.12.2 for us. 8.12.1 works fine.
3 participants