This commit is contained in:
Karl Southern 2016-06-29 13:42:09 +01:00
parent ded1106b13
commit b5419813ba
3 changed files with 16 additions and 12 deletions

View File

@ -1,6 +1,10 @@
# Change Log # Change Log
All notable changes to this project will be documented in this file, from 0.2.0. 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 ## [0.2.7] - 2016-05-29
- Backport retry exception logic from v5 branch - Backport retry exception logic from v5 branch
- Backport improved timestamp compatibility from v5 branch - Backport improved timestamp compatibility from v5 branch

View File

@ -151,7 +151,6 @@ class LogStash::Outputs::Jdbc < LogStash::Outputs::Base
if @exceptions_tracker.reject { |i| i.nil? }.count >= @max_flush_exceptions if @exceptions_tracker.reject { |i| i.nil? }.count >= @max_flush_exceptions
@logger.error("JDBC - max_flush_exceptions has been reached") @logger.error("JDBC - max_flush_exceptions has been reached")
log_jdbc_exception(e)
raise LogStash::ShutdownSignal.new raise LogStash::ShutdownSignal.new
end end
end end
@ -223,7 +222,7 @@ class LogStash::Outputs::Jdbc < LogStash::Outputs::Base
begin begin
connection = @pool.getConnection() connection = @pool.getConnection()
rescue => e rescue => e
log_jdbc_exception(e) log_jdbc_exception(e, true)
raise raise
end end
@ -242,7 +241,6 @@ class LogStash::Outputs::Jdbc < LogStash::Outputs::Base
statement.close() statement.close()
@exceptions_tracker << nil @exceptions_tracker << nil
rescue => e rescue => e
log_jdbc_exception(e)
if retry_exception?(e) if retry_exception?(e)
raise raise
end end
@ -258,7 +256,7 @@ class LogStash::Outputs::Jdbc < LogStash::Outputs::Base
begin begin
connection = @pool.getConnection() connection = @pool.getConnection()
rescue => e rescue => e
log_jdbc_exception(e) log_jdbc_exception(e, true)
raise raise
end end
@ -277,7 +275,6 @@ class LogStash::Outputs::Jdbc < LogStash::Outputs::Base
@exceptions_tracker << nil @exceptions_tracker << nil
end end
rescue => e rescue => e
log_jdbc_exception(e)
if retry_exception?(e) if retry_exception?(e)
raise raise
end end
@ -324,20 +321,23 @@ class LogStash::Outputs::Jdbc < LogStash::Outputs::Base
statement statement
end end
def log_jdbc_exception(exception) def log_jdbc_exception(exception, retrying)
current_exception = exception current_exception = exception
loop do 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() current_exception = current_exception.getNextException()
break if current_exception == nil break if current_exception == nil
end end
end end
def retry_exception?(exception) def retry_exception?(exception)
if exception.respond_to? 'getSQLState' retrying = (exception.respond_to? 'getSQLState' and RETRYABLE_SQLSTATE_CLASSES.include?(exception.getSQLState[0,2]))
return RETRYABLE_SQLSTATE_CLASSES.include?(e.getSQLState[0,2]) log_jdbc_exception(exception, retrying)
end
true retrying
end end
end # class LogStash::Outputs::jdbc end # class LogStash::Outputs::jdbc

View File

@ -1,6 +1,6 @@
Gem::Specification.new do |s| Gem::Specification.new do |s|
s.name = 'logstash-output-jdbc' s.name = 'logstash-output-jdbc'
s.version = "0.2.8" s.version = "0.2.9"
s.licenses = [ "Apache License (2.0)" ] s.licenses = [ "Apache License (2.0)" ]
s.summary = "This plugin allows you to output to SQL, via JDBC" 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" 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"