From b5419813ba3033f3a767be4d7b96b911279fe9bd Mon Sep 17 00:00:00 2001 From: Karl Southern Date: Wed, 29 Jun 2016 13:42:09 +0100 Subject: [PATCH] 0.2.9 --- CHANGELOG.md | 4 ++++ lib/logstash/outputs/jdbc.rb | 22 +++++++++++----------- logstash-output-jdbc.gemspec | 2 +- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 491d224..6b86b93 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ # Change Log All notable changes to this project will be documented in this file, from 0.2.0. +## [0.2.9] - 2016-06-29 + - Fix NameError exception. + - Moved log_jdbc_exception calls + ## [0.2.7] - 2016-05-29 - Backport retry exception logic from v5 branch - Backport improved timestamp compatibility from v5 branch diff --git a/lib/logstash/outputs/jdbc.rb b/lib/logstash/outputs/jdbc.rb index 47ee9ce..f811c51 100644 --- a/lib/logstash/outputs/jdbc.rb +++ b/lib/logstash/outputs/jdbc.rb @@ -151,7 +151,6 @@ class LogStash::Outputs::Jdbc < LogStash::Outputs::Base if @exceptions_tracker.reject { |i| i.nil? }.count >= @max_flush_exceptions @logger.error("JDBC - max_flush_exceptions has been reached") - log_jdbc_exception(e) raise LogStash::ShutdownSignal.new end end @@ -223,7 +222,7 @@ class LogStash::Outputs::Jdbc < LogStash::Outputs::Base begin connection = @pool.getConnection() rescue => e - log_jdbc_exception(e) + log_jdbc_exception(e, true) raise end @@ -242,7 +241,6 @@ class LogStash::Outputs::Jdbc < LogStash::Outputs::Base statement.close() @exceptions_tracker << nil rescue => e - log_jdbc_exception(e) if retry_exception?(e) raise end @@ -258,7 +256,7 @@ class LogStash::Outputs::Jdbc < LogStash::Outputs::Base begin connection = @pool.getConnection() rescue => e - log_jdbc_exception(e) + log_jdbc_exception(e, true) raise end @@ -277,7 +275,6 @@ class LogStash::Outputs::Jdbc < LogStash::Outputs::Base @exceptions_tracker << nil end rescue => e - log_jdbc_exception(e) if retry_exception?(e) raise end @@ -324,20 +321,23 @@ class LogStash::Outputs::Jdbc < LogStash::Outputs::Base statement end - def log_jdbc_exception(exception) + def log_jdbc_exception(exception, retrying) current_exception = exception loop do - @logger.error("JDBC Exception encountered: Will automatically retry.", :exception => current_exception) + if retrying + @logger.error("JDBC Exception. Retrying.", :exception => current_exception) + else + @logger.error("JDBC Exception. No retry.", :exception => current_exception) + end current_exception = current_exception.getNextException() break if current_exception == nil end end def retry_exception?(exception) - if exception.respond_to? 'getSQLState' - return RETRYABLE_SQLSTATE_CLASSES.include?(e.getSQLState[0,2]) - end + retrying = (exception.respond_to? 'getSQLState' and RETRYABLE_SQLSTATE_CLASSES.include?(exception.getSQLState[0,2])) + log_jdbc_exception(exception, retrying) - true + retrying end end # class LogStash::Outputs::jdbc diff --git a/logstash-output-jdbc.gemspec b/logstash-output-jdbc.gemspec index 61ca587..167c7e2 100644 --- a/logstash-output-jdbc.gemspec +++ b/logstash-output-jdbc.gemspec @@ -1,6 +1,6 @@ Gem::Specification.new do |s| s.name = 'logstash-output-jdbc' - s.version = "0.2.8" + s.version = "0.2.9" s.licenses = [ "Apache License (2.0)" ] s.summary = "This plugin allows you to output to SQL, via JDBC" s.description = "This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program"