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
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

View File

@ -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

View File

@ -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"