Distillery release started failing after upgrading to ecto 3

Distillary release started failing after upgrading to ecto 3. and here are the logs

2018-12-10 17:29:58.000 IST
{"init terminating in do_boot",{#{'__exception__'=>true,'__struct__'=>'Elixir.Ecto.MigrationError',message=>...............
Expand all | Collapse all {
 insertId:  "19ig02ag1i7ckw0"  
 labels: {…}  
 logName:  "projects/219605/logs/my-system"  
 receiveTimestamp:  "2018-12-10T15:30:00.060719795Z"  
 resource: {…}  
 severity:  "INFO"  
 textPayload:  "{"init terminating in do_boot",{#{'__exception__'=>true,'__struct__'=>'Elixir.Ecto.MigrationError',message=><<77,.........,10>>},[{'Elixir.Ecto.Adapters.SQL',raise_pool_size_error,0,[{file,"lib/ecto/adapters/sql.ex"},{line,718}]},{'Elixir.Ecto.Adapters.SQL',lock_for_migrations,5,[{file,"lib/ecto/adapters/sql.ex"},{line,703}]},{'Elixir.Ecto.Migrator',lock_for_migrations,3,[{file,"lib/ecto/migrator.ex"},{line,317}]},{'Elixir.DealorDataLayer.ReleaseTasks',seed,0,[{file,"lib/dealor_data_layer/tasks/release_task.ex"},{line,47}]},{init,start_em,1,[]},{init,do_boot,3,[]}]}}


distillary version -> 1.5

guessing - but what is the pool size for your migration? you need POOL_SIZE=2 in ecto3 https://github.com/elixir-ecto/ecto/blob/master/CHANGELOG.md#locked-migrations

In order for this safer migration mechanism to work, at least two database connections are necessary when migrating. One is used to lock the “schema_migrations” table and the other one to effectively run the migrations.

Thanks, I will try this first thing in the morning

1 Like

I tried to run the release but I got different error but again at migrations level

Booting pre hook...
Creating the database if needed...
Running migrations...
[error] an exception was raised logging %DBConnection.LogEntry{call: :prepare_execute, connection_time: 1546000, decode_time: 2268000, params: [], pool_time: 85158000, 
query: %Postgrex.Query{cache: :reference, columns: nil, name: "", param_formats: nil, param_oids: nil, param_types: nil, ref: nil, result_formats: nil, result_oids: nil, result_types: nil,
statement: ["CREATE TABLE ", "IF NOT EXISTS ", [34, "schema_migrations", 34], 32, 40, [[[], [[34, "version", 34], 32, "bigint", [[], []]], ", "], [34, "inserted_at", 34], 32, ["timestamp", "(0)"], [[], []]], [", ", "PRIMARY KEY (", [[], 34, "version", 34], ")"], 41, []], types: nil}, 
result: {:ok, %Postgrex.Query{cache: :reference, columns: nil, name: "", param_formats: [], param_oids: [], param_types: [], ref: #Reference<0.2546646986.3190030338.247>, result_formats: [], result_oids: nil, result_types: nil, 
statement: ["CREATE TABLE ", "IF NOT EXISTS ", [34, "schema_migrations", 34], 32, 40, [[[], [[34, "version", 34], 32, "bigint", [[], []]], ", "], [34, "inserted_at", 34], 32, ["timestamp", "(0)"], [[], []]], [", ", "PRIMARY KEY (", [[], 34, "version", 34], ")"], 41, []], types: {MyApp.PostgresTypes, #Reference<0.2546646986.3190161410.202>}}, %Postgrex.Result{columns: nil, command: :create_table, connection_id: 96039, messages: [%{code: "42P07", file: "parse_utilcmd.c", line: "209", message: "relation \"schema_migrations\" already exists, skipping", routine: "transformCreateStmt", severity: "NOTICE", unknown: "NOTICE"}], num_rows: 0, rows: nil}}}: 
** (ArgumentError) argument error
    (stdlib) :ets.lookup(Telemetry.HandlerTable, [:dealor_data_layer, :repo, :query])
    lib/telemetry/handler_table.ex:59: Telemetry.HandlerTable.list_for_event/1
    lib/telemetry.ex:76: Telemetry.execute/3
    lib/ecto/adapters/sql.ex:770: Ecto.Adapters.SQL.log/4
    (db_connection) lib/db_connection.ex:1311: DBConnection.log/5
    (postgrex) lib/postgrex.ex:182: Postgrex.query_prepare_execute/4
    lib/ecto/adapters/sql.ex:291: Ecto.Adapters.SQL.query!/4
    (elixir) lib/enum.ex:1314: Enum."-map/2-lists^map/1-0-"/2

seems like ecto_sql is not started and thus telemetry is not started… https://github.com/elixir-ecto/ecto/blob/master/CHANGELOG.md#split-ecto-into-ecto-and-ecto_sql

If the application function in your mix.exs file includes an :applications key, you will need to add :ecto_sql to your list of applications. This does not apply if you are using the :extra_applications key.

1 Like

Just went through this myself, these are all the changes I had to make:

Adding :ecto_sql to :extra_applications did not work for me, so I just forced it to start in the migrator script.


I have applied all the steps you mentioned above in github link. Now I am getting this werid error when trying to run test cases

    ==> dealor_data_layer
Compiling 44 files (.ex)
Generated dealor_data_layer app
==> dealor_api_gateway
Compiling 62 files (.ex)
==> _utils
Logger - error: {reLmoogvegde_rfa i-l ienrgr_ohra:n dler,'Elixir.Logger'}
Logger - error: {rLeomgogveerd _-f aeirlrionrg:_ handler,'Elixir.Logger'}
oogger - error: {removed_failing_handler,'Elixir.Logger'}L
eger - error: {removed_failing_handler,'Elixir.LLooggggeerr '-} 
rror: {removed_failing_handler,'Elixir.Logger'}
Logger - error: {removed_failing_handler,'Elixir.Logger'}
Logger - error: {removed_failinLgo_ghgaenrd l-e re,r'rEolri:x ir.Logger'}
{"Kernel pid terminated",application_controller,"{application_terminated,dealor_data_layer,shutdown}"}
Kernel pid terminated (application_controller) ({application_terminated,dealor_data_layer,shutdown})

Crash dump is being written to: erl_crash.dump...done

this error also when I add some agents as childern

       Logger - error: {removed_failing_handler,'Elixir.Logger'}
Logger - error: {Lroemovegdg_efra i-l ienrgr_ohra:n dler,'Elixir.Logger'}
Logger - error: {reLmoogvgeedr_ f-a ielrirnogr_:h andler,'Elixir.Logger'}
Logger - error: {rLeomgogveerd _- fearirlori:n g_handler,'Elixir.Logger'}
Logger - error: {rLeomgogevre d-_ fearirlori:n g_handler,'Elixir.Logger'}
Logger - error: {removed_failing_handler,'Elixir.Logger'}
** (Mix) Could not start application dealor_data_layer: DealorDataLayer.Application.start(:normal, []) returned an error: shutdown: failed to start child: DealorDataLayer.ProtocolAgent
    ** (EXIT) exited in: DBConnection.Holder.checkout(#PID<0.755.0>, [log: #Function<9.90593360/1 in Ecto.Adapters.SQL.with_log/3>, source: "protocols", timeout: 15000, pool_size: 10, pool: DBConnection.ConnectionPool])
        ** (EXIT) killed

I have never seen this error, so I don’t know what it means. Sorry.