samsondav/rihanna

Rollback of upgrade breaks

thiamsantos opened this issue · 5 comments

20:24:40.039 [info] execute "ALTER TABLE rihanna_jobs DROP COLUMN due_at;\nALTER TABLE rihanna_jobs DROP COLUMN rihanna_internal_meta;\n"
** (Postgrex.Error) ERROR 42601 (syntax_error): cannot insert multiple commands into a prepared statement
    (ecto) lib/ecto/adapters/sql.ex:200: Ecto.Adapters.SQL.query!/5
    (ecto) lib/ecto/adapters/postgres.ex:96: anonymous fn/4 in Ecto.Adapters.Postgres.execute_ddl/3
    (elixir) lib/enum.ex:1899: Enum."-reduce/3-lists^foldl/2-0-"/3
    (ecto) lib/ecto/adapters/postgres.ex:96: Ecto.Adapters.Postgres.execute_ddl/3
    (ecto) lib/ecto/migration/runner.ex:104: anonymous fn/2 in Ecto.Migration.Runner.flush/0
    (elixir) lib/enum.ex:1899: Enum."-reduce/3-lists^foldl/2-0-"/3
    (ecto) lib/ecto/migration/runner.ex:102: Ecto.Migration.Runner.flush/0
    (stdlib) timer.erl:181: :timer.tc/2
20:24:40.070 [error] GenServer #PID<0.238.0> terminating
** (Postgrex.Error) ERROR 42601 (syntax_error): cannot insert multiple commands into a prepared statement
    (ecto) lib/ecto/adapters/sql.ex:200: Ecto.Adapters.SQL.query!/5
    (ecto) lib/ecto/adapters/postgres.ex:96: anonymous fn/4 in Ecto.Adapters.Postgres.execute_ddl/3
    (elixir) lib/enum.ex:1899: Enum."-reduce/3-lists^foldl/2-0-"/3
    (ecto) lib/ecto/adapters/postgres.ex:96: Ecto.Adapters.Postgres.execute_ddl/3
    (ecto) lib/ecto/migration/runner.ex:104: anonymous fn/2 in Ecto.Migration.Runner.flush/0
    (elixir) lib/enum.ex:1899: Enum."-reduce/3-lists^foldl/2-0-"/3
    (ecto) lib/ecto/migration/runner.ex:102: Ecto.Migration.Runner.flush/0
    (stdlib) timer.erl:181: :timer.tc/2
Last message: {:EXIT, #PID<0.74.0>, {%Postgrex.Error{connection_id: 8840, message: nil, postgres: %{code: :syntax_error, file: "postgres.c", line: "1280", message: "cannot insert multiple commands into a prepared statement", pg_code: "42601", routine: "exec_parse_message", severity: "ERROR", unknown: "ERROR"}}, [{Ecto.Adapters.SQL, :query!, 5, [file: 'lib/ecto/adapters/sql.ex', line: 200]}, {Ecto.Adapters.Postgres, :"-execute_ddl/3-fun-0-", 4, [file: 'lib/ecto/adapters/postgres.ex', line: 96]}, {Enum, :"-reduce/3-lists^foldl/2-0-", 3, [file: 'lib/enum.ex', line: 1899]}, {Ecto.Adapters.Postgres, :execute_ddl, 3, [file: 'lib/ecto/adapters/postgres.ex', line: 96]}, {Ecto.Migration.Runner, :"-flush/0-fun-1-", 2, [file: 'lib/ecto/migration/runner.ex', line: 104]}, {Enum, :"-reduce/3-lists^foldl/2-0-", 3, [file: 'lib/enum.ex', line: 1899]}, {Ecto.Migration.Runner, :flush, 0, [file: 'lib/ecto/migration/runner.ex', line: 102]}, {:timer, :tc, 2, [file: 'timer.erl', line: 181]}]}}
State: %DynamicSupervisor{args: {{:temporary, 5000}, []}, children: %{}, extra_arguments: [], max_children: :infinity, max_restarts: 3, max_seconds: 5, mod: Task.Supervisor, name: {#PID<0.238.0>, Task.Supervisor}, restarts: [], strategy: :one_for_one}
20:24:40.076 [error] GenServer #PID<0.247.0> terminating
** (Postgrex.Error) ERROR 42601 (syntax_error): cannot insert multiple commands into a prepared statement
    (ecto) lib/ecto/adapters/sql.ex:200: Ecto.Adapters.SQL.query!/5
    (ecto) lib/ecto/adapters/postgres.ex:96: anonymous fn/4 in Ecto.Adapters.Postgres.execute_ddl/3
    (elixir) lib/enum.ex:1899: Enum."-reduce/3-lists^foldl/2-0-"/3
    (ecto) lib/ecto/adapters/postgres.ex:96: Ecto.Adapters.Postgres.execute_ddl/3
    (ecto) lib/ecto/migration/runner.ex:104: anonymous fn/2 in Ecto.Migration.Runner.flush/0
    (elixir) lib/enum.ex:1899: Enum."-reduce/3-lists^foldl/2-0-"/3
    (ecto) lib/ecto/migration/runner.ex:102: Ecto.Migration.Runner.flush/0
    (stdlib) timer.erl:181: :timer.tc/2
Last message: {:EXIT, #PID<0.74.0>, {%Postgrex.Error{connection_id: 8840, message: nil, postgres: %{code: :syntax_error, file: "postgres.c", line: "1280", message: "cannot insert multiple commands into a prepared statement", pg_code: "42601", routine: "exec_parse_message", severity: "ERROR", unknown: "ERROR"}}, [{Ecto.Adapters.SQL, :query!, 5, [file: 'lib/ecto/adapters/sql.ex', line: 200]}, {Ecto.Adapters.Postgres, :"-execute_ddl/3-fun-0-", 4, [file: 'lib/ecto/adapters/postgres.ex', line: 96]}, {Enum, :"-reduce/3-lists^foldl/2-0-", 3, [file: 'lib/enum.ex', line: 1899]}, {Ecto.Adapters.Postgres, :execute_ddl, 3, [file: 'lib/ecto/adapters/postgres.ex', line: 96]}, {Ecto.Migration.Runner, :"-flush/0-fun-1-", 2, [file: 'lib/ecto/migration/runner.ex', line: 104]}, {Enum, :"-reduce/3-lists^foldl/2-0-", 3, [file: 'lib/enum.ex', line: 1899]}, {Ecto.Migration.Runner, :flush, 0, [file: 'lib/ecto/migration/runner.ex', line: 102]}, {:timer, :tc, 2, [file: 'timer.erl', line: 181]}]}}
State: %DynamicSupervisor{args: {{:temporary, 5000}, []}, children: %{}, extra_arguments: [], max_children: :infinity, max_restarts: 3, max_seconds: 5, mod: Task.Supervisor, name: {#PID<0.247.0>, Task.Supervisor}, restarts: [], strategy: :one_for_one}
20:24:40.082 [error] GenServer Broker.Repo terminating
** (Postgrex.Error) ERROR 42601 (syntax_error): cannot insert multiple commands into a prepared statement
    (ecto) lib/ecto/adapters/sql.ex:200: Ecto.Adapters.SQL.query!/5
    (ecto) lib/ecto/adapters/postgres.ex:96: anonymous fn/4 in Ecto.Adapters.Postgres.execute_ddl/3
    (elixir) lib/enum.ex:1899: Enum."-reduce/3-lists^foldl/2-0-"/3
    (ecto) lib/ecto/adapters/postgres.ex:96: Ecto.Adapters.Postgres.execute_ddl/3
    (ecto) lib/ecto/migration/runner.ex:104: anonymous fn/2 in Ecto.Migration.Runner.flush/0
    (elixir) lib/enum.ex:1899: Enum."-reduce/3-lists^foldl/2-0-"/3
    (ecto) lib/ecto/migration/runner.ex:102: Ecto.Migration.Runner.flush/0
    (stdlib) timer.erl:181: :timer.tc/2
Last message: {:EXIT, #PID<0.74.0>, {%Postgrex.Error{connection_id: 8840, message: nil, postgres: %{code: :syntax_error, file: "postgres.c", line: "1280", message: "cannot insert multiple commands into a prepared statement", pg_code: "42601", routine: "exec_parse_message", severity: "ERROR", unknown: "ERROR"}}, [{Ecto.Adapters.SQL, :query!, 5, [file: 'lib/ecto/adapters/sql.ex', line: 200]}, {Ecto.Adapters.Postgres, :"-execute_ddl/3-fun-0-", 4, [file: 'lib/ecto/adapters/postgres.ex', line: 96]}, {Enum, :"-reduce/3-lists^foldl/2-0-", 3, [file: 'lib/enum.ex', line: 1899]}, {Ecto.Adapters.Postgres, :execute_ddl, 3, [file: 'lib/ecto/adapters/postgres.ex', line: 96]}, {Ecto.Migration.Runner, :"-flush/0-fun-1-", 2, [file: 'lib/ecto/migration/runner.ex', line: 104]}, {Enum, :"-reduce/3-lists^foldl/2-0-", 3, [file: 'lib/enum.ex', line: 1899]}, {Ecto.Migration.Runner, :flush, 0, [file: 'lib/ecto/migration/runner.ex', line: 102]}, {:timer, :tc, 2, [file: 'timer.erl', line: 181]}]}}
State: {:state, {:local, Broker.Repo}, :one_for_one, [{:child, #PID<0.628.0>, DBConnection.Poolboy, {:poolboy, :start_link, [[name: {:local, Broker.Repo.Pool}, strategy: :fifo, size: 1, max_overflow: 0, worker_module: DBConnection.Poolboy.Worker], {Postgrex.Protocol, [types: Ecto.Adapters.Postgres.TypeModule, port: 5432, name: Broker.Repo.Pool, otp_app: :broker, repo: Broker.Repo, timeout: 15000, pool_timeout: 5000, adapter: Ecto.Adapters.Postgres, username: "postgres", password: "postgres", database: "broker_dev", hostname: "localhost", pool_size: 1, pool: DBConnection.Poolboy]}]}, :permanent, 5000, :worker, [:poolboy]}], :undefined, 3, 5, [], 0, Ecto.Repo.Supervisor, {Broker.Repo, :broker, Ecto.Adapters.Postgres, [pool_size: 1]}}

I think the error is caused by this line. Here we have two statements on a single execute.

@thiamsantos thanks for raising this issue!

Yes, I think you are right. Would you like to open a pull request with a fix? Otherwise I can.

@samphilipd yes, I would be happy to send a PR.

@samphilipd could publish a new release with this changes?

@samphilipd thanks! I just installed 1.1.2 and it works pretty well.

Great! I'm glad it's working for you 😁