logstash-integration-jdbc 5.1.2 → 5.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/logstash/filters/jdbc/lookup.rb +5 -2
- data/lib/logstash/plugin_mixins/jdbc/jdbc.rb +1 -2
- data/lib/logstash/plugin_mixins/jdbc_streaming/statement_handler.rb +5 -2
- data/logstash-integration-jdbc.gemspec +1 -1
- data/spec/filters/jdbc/lookup_spec.rb +35 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 629c09f028a534cb970327b8d98eb85d8ae0371f4e9c7ccc8c5c9194d2942293
|
4
|
+
data.tar.gz: 9fddcb34b38b9be0bdc80cfc9c9385dacbcb821530be8c78c21024414b70f0ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06f23b86b0f5f15bb5c0b93cca5068199df24e9867e891d72d930dd87c7f9faf891a2d0937f55d92e74a3769b432f87c5559e07cc028bbc64652631d927f4ebb
|
7
|
+
data.tar.gz: 969df6533a1c1afcd01ff89283195cde0865ee72bae75ed77e9ef7abfb129af9eb62b485d5a0d293189d5348df71b546dd911146d9e46ea0b481369b938959ca
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
## 5.1.3
|
2
|
+
- Improve robustness when handling errors from `sequel` library in jdbc static and streaming
|
3
|
+
filters[#78](https://github.com/logstash-plugins/logstash-integration-jdbc/pull/78)
|
4
|
+
|
1
5
|
## 5.1.2
|
2
6
|
- Fix `prepared_statement_bind_values` in streaming filter to resolve nested event's fields[#76](https://github.com/logstash-plugins/logstash-integration-jdbc/pull/76)
|
3
7
|
|
@@ -162,8 +162,11 @@ module LogStash module Filters module Jdbc
|
|
162
162
|
begin
|
163
163
|
logger.debug? && logger.debug("Executing Jdbc query", :lookup_id => @id, :statement => query, :parameters => params)
|
164
164
|
proc.call(local, query, params, result)
|
165
|
-
rescue
|
166
|
-
#
|
165
|
+
rescue => e
|
166
|
+
# In theory all exceptions in Sequel should be wrapped in Sequel::Error
|
167
|
+
# However, there are cases where other errors can occur - a `SQLTransactionRollbackException`
|
168
|
+
# may be thrown during `prepareStatement`. Let's handle these cases here, where we can tag and warn
|
169
|
+
# appropriately rather than bubble up and potentially crash the plugin.
|
167
170
|
result.failed!
|
168
171
|
logger.warn? && logger.warn("Exception when executing Jdbc query", :lookup_id => @id, :exception => e.message, :backtrace => e.backtrace.take(8))
|
169
172
|
end
|
@@ -119,8 +119,7 @@ module LogStash module PluginMixins module Jdbc
|
|
119
119
|
else
|
120
120
|
@logger.error("Failed to connect to database. #{@jdbc_pool_timeout} second timeout exceeded. Trying again.")
|
121
121
|
end
|
122
|
-
|
123
|
-
rescue ::Sequel::Error => e
|
122
|
+
rescue Java::JavaSql::SQLException, ::Sequel::Error => e
|
124
123
|
if retry_attempts <= 0
|
125
124
|
log_java_exception(e.cause)
|
126
125
|
@logger.error("Unable to connect to database. Tried #{@connection_retry_attempts} times", error_details(e, trace: true))
|
@@ -38,8 +38,11 @@ module LogStash module PluginMixins module JdbcStreaming
|
|
38
38
|
begin
|
39
39
|
logger.debug? && logger.debug("Executing JDBC query", :statement => statement, :parameters => params)
|
40
40
|
execute_extract_records(db, params, result)
|
41
|
-
rescue
|
42
|
-
#
|
41
|
+
rescue => e
|
42
|
+
# In theory all exceptions in Sequel should be wrapped in Sequel::Error
|
43
|
+
# However, there are cases where other errors can occur - a `SQLException`may be thrown
|
44
|
+
# during `prepareStatement`. Let's handle these cases here, where we can tag and warn
|
45
|
+
# appropriately rather than bubble up and potentially crash the plugin.
|
43
46
|
result.failed!
|
44
47
|
logger.warn? && logger.warn("Exception when executing JDBC query", :statement => statement, :parameters => params, :exception => e)
|
45
48
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'logstash-integration-jdbc'
|
3
|
-
s.version = '5.1.
|
3
|
+
s.version = '5.1.3'
|
4
4
|
s.licenses = ['Apache License (2.0)']
|
5
5
|
s.summary = "Integration with JDBC - input and filter plugins"
|
6
6
|
s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"
|
@@ -249,6 +249,41 @@ module LogStash module Filters module Jdbc
|
|
249
249
|
end
|
250
250
|
end
|
251
251
|
|
252
|
+
describe "lookup operations when prepareStatement throws" do
|
253
|
+
let(:local_db) { double("local_db") }
|
254
|
+
let(:lookup_hash) do
|
255
|
+
{
|
256
|
+
"query" => "select * from servers WHERE ip LIKE ? AND os LIKE ?",
|
257
|
+
"prepared_parameters" => ["%%{[ip]}"],
|
258
|
+
"target" => "server",
|
259
|
+
"tag_on_failure" => ["_jdbcstaticfailure_server"]
|
260
|
+
}
|
261
|
+
end
|
262
|
+
let(:event) { LogStash::Event.new()}
|
263
|
+
let(:records) { [{"name" => "ldn-1-23", "rack" => "2:1:6"}] }
|
264
|
+
let(:prepared_statement) { double("prepared_statement")}
|
265
|
+
|
266
|
+
subject(:lookup) { described_class.new(lookup_hash, {}, "lookup-1") }
|
267
|
+
|
268
|
+
before(:each) do
|
269
|
+
allow(local_db).to receive(:prepare).once.and_return(prepared_statement)
|
270
|
+
allow(prepared_statement).to receive(:call).once.and_raise(Java::JavaSql::SQLTransactionRollbackException.new)
|
271
|
+
end
|
272
|
+
|
273
|
+
it "must not be valid" do
|
274
|
+
expect(subject.valid?).to be_falsey
|
275
|
+
end
|
276
|
+
|
277
|
+
it "should tag event as failed" do
|
278
|
+
event.set("ip", "20.20")
|
279
|
+
event.set("os", "MacOS")
|
280
|
+
subject.prepare(local_db)
|
281
|
+
subject.enhance(local_db, event)
|
282
|
+
expect(event.get("tags")).to eq(["_jdbcstaticfailure_server"])
|
283
|
+
expect(event.get("server")).to be_nil
|
284
|
+
end
|
285
|
+
end
|
286
|
+
|
252
287
|
describe "validation of target option" do
|
253
288
|
let(:lookup_hash) do
|
254
289
|
{
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-integration-jdbc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.1.
|
4
|
+
version: 5.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elastic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-07-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|