sorentwo/oban

Oban with postgres fails when elixir time_zone_database is set to Tzdata.TimeZoneDatabase

Closed this issue · 1 comments

Precheck

I saw a reference to this same error in closed Issue 868 but it didn't seem to give a clear answer to the issue.

Environment

Oban 2.17.2
Elixir 1.15.5 / OTP 26

Current Behavior

Oban works fine when I do not have tzdata as a dependency. Once I add tzdata 1.1 and configure it by adding to config.exs:

config :elixir, :time_zone_database, Tzdata.TimeZoneDatabase

Oban starts throwing errors:

{"time": "2024-01-22T17:58:12.575Z", "level": "error", "msg": "["GenServer ", "{Oban.Registry, {Oban, Oban.Peer}}", " terminating", [[10 | "** (ArgumentError) cannot add 30000 millisecond to ~U[2024-01-22 17:58:12.574980Z] (with time zone database Tzdata.TimeZoneDatabase), reason: :time_zone_not_found"], ["\n " | "(elixir 1.15.5) lib/calendar/datetime.ex:1641: DateTime.add/4"], ["\n " | "(oban 2.17.2) lib/oban/peers/postgres.ex:178: Oban.Peers.Postgres.upsert_peer/1"], ["\n " | "(ecto_sql 3.11.1) lib/ecto/adapters/sql.ex:1358: anonymous fn/3 in Ecto.Adapters.SQL.checkout_or_transaction/4"], ["\n " | "(db_connection 2.6.0) lib/db_connection.ex:1710: DBConnection.run_transaction/4"], ["\n " | "(oban 2.17.2) lib/oban/peers/postgres.ex:99: anonymous fn/2 in Oban.Peers.Postgres.handle_info/2"], ["\n " | "(telemetry 1.2.1) /Users/michaelwatson/code/alab-core/jobs-service/deps/telemetry/src/telemetry.erl:321: :telemetry.span/3"], ["\n " | "(oban 2.17.2)

Expected Behavior

I need to be able to add a timezone database for other parts of my application. Oban should not fail when tzdata is configured.

Oban works with a timezone database set. In fact, it's set in config.exs for all tests: https://github.com/sorentwo/oban/blob/main/config/config.exs#L3

It seems like your application doesn't (or didn't) have the timezone database downloaded and available before Oban started.