Skip to content

Bug Report: v0.3.0 Fresh Install Fails — Migration 0071 DuplicateColumn on PostgreSQL #66

Description

@plazmabokor

Subject: Bug Report: v0.3.0 Fresh Install Fails — Migration 0071 DuplicateColumn on PostgreSQL

Hi,

I wanted to report a bug I encountered while doing a fresh install of Circuit Breaker v0.3.0 on a Raspberry Pi 3 (aarch64, Raspberry Pi OS Lite 64-bit / Debian 13 Bookworm).

Summary

Fresh native installs consistently fail to start the backend API due to a DuplicateColumn error in migration 0071_network_peer_connection_type. The backend enters a crash loop and never becomes healthy.

Environment

  • Hardware: Raspberry Pi 3 (aarch64)
  • OS: Raspberry Pi OS Lite 64-bit (Debian GNU/Linux 13 Bookworm)
  • Install method: Native installer via --local-bundle flag
  • Circuit Breaker version: v0.3.0

Steps to reproduce

  1. Run a fresh native install using install.sh with the arm64 bundle
  2. Installer completes successfully up to "Starting Application Services"
  3. Backend API fails to start
  4. Run: journalctl -u circuitbreaker-backend --no-pager -n 20

Error message

sqlalchemy.exc.ProgrammingError: (psycopg2.errors.DuplicateColumn) column "connection_type" of relation "network_peers" already exists
[SQL: ALTER TABLE network_peers ADD COLUMN connection_type VARCHAR]

Root cause analysis

Migration 0071_network_peer_connection_type.py attempts to add the connection_type column using batch_alter_table. Although the migration code checks for existing columns via inspector.get_columns(), this check does not work correctly with PostgreSQL in batch mode — the column check passes but the ALTER TABLE still fails with a DuplicateColumn error.

Because the failure happens inside a transaction, the entire migration is rolled back, including the alembic_version table entries. This means every restart triggers a full re-run of all migrations from scratch, hitting the same error every time — creating a permanent crash loop with no way to recover without manual intervention.

Additional notes

The release notes for v0.3.0 mention: "Fixed migration reruns throwing duplicate-table errors" — however this fix does not appear to cover this specific case on fresh PostgreSQL installs.

A simple fix would be to replace the batch_alter_table block in 0071 with direct PostgreSQL DDL using ADD COLUMN IF NOT EXISTS:

def upgrade() -> None:
    conn = op.get_bind()
    conn.execute(sa.text("ALTER TABLE network_peers ADD COLUMN IF NOT EXISTS connection_type VARCHAR"))
    conn.execute(sa.text("ALTER TABLE network_peers ADD COLUMN IF NOT EXISTS bandwidth_mbps INTEGER"))

This is idempotent and PostgreSQL-native, which avoids the batch_alter_table issue entirely.

Happy to provide any additional logs or information if needed. Thanks for the great project!

Best regards

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions