Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash on startup #48

Closed
uberbrodt opened this issue Nov 20, 2017 · 8 comments · Fixed by #53
Closed

Crash on startup #48

uberbrodt opened this issue Nov 20, 2017 · 8 comments · Fixed by #53

Comments

@uberbrodt
Copy link

15:57:28.719 [debug] Tzdata downloading new data from https://www.iana.org/time-zones/repository/tzdata-latest.tar.gz                                                                          
15:57:29.399 [debug] Tzdata data downloaded. Release version 2017c.                            
{:error,                                                                                       
 {:tzdata,                                                                                     
  {:bad_return,                                                                                
   {{Tzdata.App, :start, [:normal, []]},                                                       
    {:EXIT,                                                                                    
     {{:badmatch,                                                                              
       {:error,                                                                                
        {:shutdown,                                                                            
         {:failed_to_start_child, Tzdata.EtsHolder,                                            
          {:badarg,                                                                            
           [{:ets, :lookup, [:tzdata_current_release, :release_version], []},                  
            {Tzdata.ReleaseReader, :current_release_from_table, 0,                             
             [file: 'lib/tzdata/release_reader.ex', line: 47]},                                
            {Tzdata.ReleaseReader, :simple_lookup, 1,                                          
             [file: 'lib/tzdata/release_reader.ex', line: 14]},                                
            {Tzdata.ReleaseReader, :release_version, 0,                                        
             [file: 'lib/tzdata/release_reader.ex', line: 9]},                                 
            {Tzdata.DataBuilder, :load_and_save_table, 0,                                      
             [file: 'lib/tzdata/data_builder.ex', line: 11]},                                  
            {Tzdata.EtsHolder, :init, 1,                                                       
             [file: 'lib/tzdata/ets_holder.ex', line: 11]},                                    
            {:gen_server, :init_it, 2, [file: 'gen_server.erl', line: 365]},                   
            {:gen_server, :init_it, 6,                                                         
             [file: 'gen_server.erl', line: 333]}]}}}}},                                       
      [{Tzdata.App, :start, 2, [file: 'lib/tzdata/tzdata_app.ex', line: 15]},                  
       {:application_master, :start_it_old, 4,                                                 
        [file: 'application_master.erl', line: 273]}]}}}}}}                                    
iex(3)> 15:57:29.414 [info] Application tzdata exited: exited in: Tzdata.App.start(:normal, [])
    ** (EXIT) an exception was raised:                                                         
        ** (MatchError) no match of right hand side value: {:error, {:shutdown, {:failed_to_start_child, Tzdata.EtsHolder, {:badarg, [{:ets, :lookup, [:tzdata_current_release, :release_version], []}, {Tzdata.ReleaseReader, :current_release_from_table, 0, [file: 'lib/tzdata/release_reader.ex', line: 47]}, {Tzdata.ReleaseReader, :simple_lookup, 1, [file: 'lib/tzdata/release_reader.ex', line: 14]}, {Tzdata.ReleaseReader, :release_version, 0, [file: 'lib/tzdata/release_reader.ex', line: 9]}, {Tzdata.DataBuilder, :load_and_save_table, 0, [file: 'lib/tzdata/data_builder.ex', line: 11]}, {Tzdata.EtsHolder, :init, 1, [file: 'lib/tzdata/ets_holder.ex', line: 11]}, {:gen_server, :init_it, 2, [file: 'gen_server.erl', line: 365]}, {:gen_server, :init_it, 6, [file: 'gen_server.erl', line: 333]}]}}}}                                                              
            (tzdata) lib/tzdata/tzdata_app.ex:15: Tzdata.App.start/2                           
            (kernel) application_master.erl:273: :application_master.start_it_old/4     

Not sure what the issues is exactly. I confirmed that I'm using the latest 0.5.13 with latest Timex.

@lau
Copy link
Owner

lau commented Nov 21, 2017

This can happen if you don't have an existing .ets file e.g. priv/release_ets/2017c.ets.

Did you configure the tzdata data_dir with config :tzdata, :data_dir, "/etc/elixir_tzdata_data" ? If so there should be a working .ets file there with timezone data. The tzdata Elixir library ships with one (https://github.com/lau/tzdata/tree/05dcdb4e3f5d05ba1281be9df959a70b52fad9ae/priv/release_ets)

If you are in an "iex" console and run Tzdata.Util.data_dir() this is the dir where there should be an .ets file with the timezone data.

@uberbrodt
Copy link
Author

So I did have it configured to use a :data_dir and it was writeable by the process. I tested today and now it seems to work? I guess you can close the issue, I'll re-open if I can reproduce it.

@uberbrodt
Copy link
Author

Actually, I was able to replicated it. So here's the issue. If I don't set the data_dir it works fine, but if I set it to an empty, readable/writeable, directory it fails with the above error. So are you saying that I need to have a .ets file there before the app boots? It won't create the .ets file on it's own?

@lau
Copy link
Owner

lau commented Nov 21, 2017

Thank you for writing about this. If there is no .ets file in the configured directory already it tries to download one at startup. However that functionality might be broken in the current version. I will investigate that.

Yes, if you add a compatible .ets file to that directory (for instance the one that ships with the version of the tzdata hex package), then it should work.

I will add some more information about it to the README.

@FabienHenon
Copy link
Contributor

I have the same issue with the same crash when release_ets is empty (:data_dir has been specified and is readable/writable. Everything was working fine a few weeks ago)

@bmurithi
Copy link

bmurithi commented Dec 18, 2017

Ran into this issue in a live release after a box restart (was using /tmp as the data_dir).

The documentation in the README is pretty clear on how to handle this in releases.

You basically need to copy over _build/prod/lib/tzdata/priv/release_ets during deployment to the configured data_dir in prod.exs or config.exs.

Examples

prod.exs

config :tzdata, :data_dir, "/etc/elixir_tzdata_data"

Docker build example (multi-stage)

COPY --from=builder /app/_build/prod/lib/tzdata/priv/release_ets /etc/elixir_tzdata_data/release_ets/

Ansible Task example

    - name: copy tzdata data release directory
      synchronize:
        src: "_build/prod/lib/tzdata/priv/release_ets"
        dest: "/etc/elixir_tzdata_data"
        use_ssh_args: yes
      tags:
        - code
        - tzdata

@lau
Copy link
Owner

lau commented Dec 27, 2017

I have made a new branch for automatically copying the release from priv to the custom data dir.
See #53
@uberbrodt and @FabienHenon would you mind trying that branch and seeing if it fixes your problems?

@lau lau closed this as completed in #53 Jan 7, 2018
@lau
Copy link
Owner

lau commented Jan 7, 2018

A new version 0.5.15 has just been released. It addresses a configured data_dir without any pre existing release_ets/*.ets files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants