Skip to content

fix(schema): widen MusicBrainz Discogs ID columns to BIGINT#376

Merged
SimplicityGuy merged 1 commit into
mainfrom
worktree-bigint-migration
May 31, 2026
Merged

fix(schema): widen MusicBrainz Discogs ID columns to BIGINT#376
SimplicityGuy merged 1 commit into
mainfrom
worktree-bigint-migration

Conversation

@SimplicityGuy

Copy link
Copy Markdown
Owner

Problem

brainztableinator throws continuous PostgreSQL integer out of range errors (dozens/sec, infinite redelivery loop) when processing MusicBrainz releases in production.

Root cause: schema-init/postgres_schema.py declared the Discogs cross-reference columns as INTEGER (int4, max 2,147,483,647), but the extractor parses Discogs IDs as i64 (extractor/src/jsonl_parser.rs). Discogs release IDs now exceed 2.1B → overflow on INSERT into musicbrainz.releases.

The same latent risk affected all four sibling columns:

Table Column
musicbrainz.artists discogs_artist_id
musicbrainz.labels discogs_label_id
musicbrainz.releases discogs_release_id
musicbrainz.release_groups discogs_master_id

Fix

  • Fresh installs: change the four columns to BIGINT in the CREATE TABLE definitions.
  • Existing databases: add idempotent ALTER TABLE … ALTER COLUMN … TYPE BIGINT migrations, because CREATE TABLE IF NOT EXISTS is a no-op on tables that already exist as INTEGER. Re-applying TYPE BIGINT to an already-widened column is a no-op, so the migration is safe on every startup.

Neo4j (brainzgraphinator) is unaffected — Neo4j integers are already 64-bit.

Tests

  • New test_musicbrainz_discogs_id_columns_are_bigint — asserts the four columns are BIGINT.
  • New test_musicbrainz_has_bigint_widening_migrations — asserts the four ALTER COLUMN … TYPE BIGINT migrations exist.
  • Updated test_musicbrainz_tables_use_if_not_exists and test_all_statements_create_if_not_exists to recognize that idempotent ALTER COLUMN … TYPE migrations legitimately carry no IF NOT EXISTS clause.

All schema-init tests pass; mypy, ruff, and bandit clean.

Notes

This PR is scoped to the schema migration. The related requeue=True amplifier in brainztableinator.py (which causes non-retriable data-shape errors to redeliver forever) is a separate concern and is not addressed here.

🤖 Generated with Claude Code

brainztableinator throws continuous PostgreSQL "integer out of range"
errors when processing MusicBrainz releases: discogs_release_id (and its
siblings discogs_artist_id, discogs_label_id, discogs_master_id) were
declared INTEGER (int4, max 2,147,483,647), but the extractor parses
Discogs IDs as i64 and release IDs now exceed 2.1B.

Fix both fresh installs and existing databases:
- Change the four cross-reference columns to BIGINT in the CREATE TABLE
  definitions (fresh installs).
- Add idempotent `ALTER COLUMN ... TYPE BIGINT` migrations, since
  CREATE TABLE IF NOT EXISTS is a no-op on pre-existing tables.

Neo4j (brainzgraphinator) is unaffected — Neo4j integers are 64-bit.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@codecov

codecov Bot commented May 31, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@github-actions

Copy link
Copy Markdown
Contributor

E2E Coverage (chromium)

Totals Coverage
Statements: 46.29% ( 1246 / 2692 )
Lines: 46.29% ( 1246 / 2692 )

StandWithUkraine

@github-actions

Copy link
Copy Markdown
Contributor

E2E Coverage (webkit)

Totals Coverage
Statements: 46.29% ( 1246 / 2692 )
Lines: 46.29% ( 1246 / 2692 )

StandWithUkraine

@github-actions

Copy link
Copy Markdown
Contributor

E2E Coverage (firefox)

Totals Coverage
Statements: 46.29% ( 1246 / 2692 )
Lines: 46.29% ( 1246 / 2692 )

StandWithUkraine

@github-actions

Copy link
Copy Markdown
Contributor

E2E Coverage (webkit - iPhone 15)

Totals Coverage
Statements: 46.29% ( 1246 / 2692 )
Lines: 46.29% ( 1246 / 2692 )

StandWithUkraine

@github-actions

Copy link
Copy Markdown
Contributor

E2E Coverage (webkit - iPad Pro 11)

Totals Coverage
Statements: 46.29% ( 1246 / 2692 )
Lines: 46.29% ( 1246 / 2692 )

StandWithUkraine

@SimplicityGuy SimplicityGuy merged commit dfb0c4a into main May 31, 2026
57 checks passed
@SimplicityGuy SimplicityGuy deleted the worktree-bigint-migration branch May 31, 2026 21:10
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 this pull request may close these issues.

1 participant