logstash-input-jdbc: Input crashes on TZInfo::AmbiguousTime Error when setting jdbc_default_timezone
Hi there! First of all - thanks a lot for this plugin - it’s great!
However, when using my MySQL DB’s timestamp in elasticsearch/kibana I noticed it was off by 1h since the MySQL timestamp is interpreted as UTC but in fact is CET.
So i added: jdbc_default_timezone => “Europe/Berlin”
But now my logstash-pipeline crashes fatal resulting in an endless loop of trying to read data from MySQL with this error:
A plugin had an unrecoverable error. Will restart this plugin.
Plugin: <LogStash::Inputs::Jdbc jdbc_connection_string=>"jdbc:mysql://localhost:3306/MYDBNAME?zeroDateTimeBehavior=convertToNull", jdbc_user=>"MYDBUSER", jdbc_password=><password>, jdbc_driver_library=>"/driver/mysql-connector-java-5.1.35-bin.jar", jdbc_driver_class=>"com.mysql.jdbc.Driver", jdbc_default_timezone=>"Europe/Berlin", statement_filepath=>"/config/queries/shop_order_item.sql", type=>"shop_order_item", codec=><LogStash::Codecs::Plain charset=>"UTF-8">, jdbc_paging_enabled=>false, jdbc_page_size=>100000, jdbc_validate_connection=>false, jdbc_validation_timeout=>3600, jdbc_pool_timeout=>5, sql_log_level=>"info", parameters=>{"sql_last_value"=>1970-01-01 00:00:00 UTC}, last_run_metadata_path=>"/var/lib/logstash/.logstash_jdbc_last_run", use_column_value=>false, clean_run=>false, record_last_run=>true, lowercase_column_names=>true>
Error: TZInfo::AmbiguousTime: 2015-10-25T02:49:45+00:00 is an ambiguous local time. {:level=>:error}
I’m aware that this might probably more like an tzinfo related problem (https://github.com/tzinfo/tzinfo/issues/32) but I don’t see any other possibility to make it work correctly.
Exporting a UNIX-timestamp in MySQL and using a date input filter combined with the “unix” timestamp parser is (for whatever reason) painfully slow resulting in jammed elasticsearch input queues.
Best - Max
About this issue
- Original URL
- State: open
- Created 8 years ago
- Reactions: 2
- Comments: 26 (4 by maintainers)
Since v5.4.0 of this plugin (which is now distributed as a part of the JDBC Integration plugin for Logstash), you can specify the behaviour when encountering an ambiguous timestamp:
Versions of this plugin with this feature were first shipped with Logstash v8.6.0.
Logstash 7.6+ and 8.0+ shipped with the JDBC Integration plugin, so it can be updated with the normal method:
Logstash < 7.5 will need to remove the stand-alone JDBC plugins prior to installing the integration plugin, which will look something like:
I don’t really understand why this is not labeled as a bug. If I understand this correctly, the jdbc_default_timezone cannot be used in countries using daylight saving time.
Good point - I don’t know either. If one of the contributors of this plugin could confirm or negate that we could keep this ticket here or move it to the proper elastic project instead.
I guess in the end there should be a global or plugin specific setting, leading to these calls:
tz.local_to_utc(d) { |periods| periods.first }
ortz.local_to_utc(d) { |periods| periods.last }
as mentioned in the linked tzinfo issue.
As far as I understand the issue logstash-input-jdbc would have to let us configure (like tzinfo does it) what fallback (pick first or second point in time) to perform in case of an ambigous time stamp. As long as it doesn’t to this it’s somewhat “correct” to fail fatally.
Here is my understanding of the whole thing - please correct me if I’m wrong:
I know - that’s all evil stuff and everyone should only write UTC timestamps to avoid such awkwardness but in reality there are a lot of databases out there logging stuff in local timezones that support daylight saving time shifts - so support for that would be great 😃