Concurrent index migration fails on partitioned oban_jobs

Oban.Pro.Migration.up(version: "1.7.0", only: :indexes) fails on partitioned oban_jobs table when upgrading Oban Pro from 1.6 to 1.7

defmodule App.Repo.Migrations.UpgradeObanProTo17Indexes do
  use Ecto.Migration

  @disable_migration_lock true
  @disable_ddl_transaction true

  def up, do: Oban.Pro.Migration.up(version: "1.7.0", only: :indexes)
  def down, do: Oban.Pro.Migration.down(version: "1.7.0", only: :indexes)
end
15:38:26.974 [info] create index if not exists public.oban_jobs_workflow_index
** (Postgrex.Error) ERROR 0A000 (feature_not_supported) cannot create index on partitioned table "oban_jobs" concurrently
    (ecto_sql 3.14.0) lib/ecto/adapters/sql.ex:1121: Ecto.Adapters.SQL.raise_sql_call_error/1
    (elixir 1.19.5) lib/enum.ex:1688: Enum."-map/2-lists^map/1-1-"/2

The non-concurrent migration (without only: :indexes) works fine.

There are many unexpected edge cases with partitioned tables in Postgres. That’s one of the numerous reasons we’ve deprecated DynamicPartitioner as of Pro v1.7:

This module is deprecated. The complexity and edge cases introduced by dynamic partitioning outweigh the benefits for most applications. This plugin will be removed in a future version.

Note that “future version” means v2.0, we won’t remove something functional in a minor release, but you may encounter weirdness with things like concurrent migrations.

2 Likes