Repository navigation
Conversation
Co-Authored-By: Claude Fable 5 <[email protected]>
…rite window Adds the min(id) refusal to the Down guard, removes install-specific figures from the migration header, lists the int4 advisory-lock follow-ups, adds the operator note on large-table rewrites, and adds a DB-gated test that the Down refuses out-of-range ids in both directions. Co-Authored-By: Claude Fable 5 <[email protected]>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Team Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cfcedf13bc
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| updated_at = NOW() | ||
| WHERE content_id = $2 | ||
| AND id = ANY($3::int[]) | ||
| AND id = ANY($3::bigint[]) |
There was a problem hiding this comment.
Carry bigint IDs through file reattribution
When a media_files.id exceeds the old int4 ceiling, this update succeeds, but the unconditional reattribute.Run call later passes the same IDs into internal/catalog/reattribute/reattribute.go, where every subset query still casts them to ::int[] (for example, lines 352 and 472–473). PostgreSQL therefore raises integer out of range even when no child-state row exists, rolling back admin splits and anchored-identity repairs for precisely the large IDs this migration now permits; use bigint arrays throughout the reattribution predicates.
AGENTS.md reference: AGENTS.md:L12-L17
Useful? React with 👍 / 👎.
Widens the ::int[] parameter casts still bound against media_files.id, media_folders.id, and users.id in reattribute, admin activity, library collections, and setting values, and adds a DB-gated test that reattribution accepts a media_files id above the int4 range. Co-Authored-By: Claude Fable 5 <[email protected]>
|
Verified the Codex P2 and it was right — the original cast sweep was incomplete. Fixed in f04a935, with a full classified sweep this time rather than only the cited lines. Changed to Left alone, with reason: every other Note on the symptom: with pgx the failure is client-side at encode time ( |
|
Closing as superseded by the merged schema-hygiene replacement. |
Problem
Related issue: #135 (schema workstream: #888)
users.id,media_files.id, andmedia_folders.idareinteger, while eight newer foreign-key columns already declarebigintagainst them (invitations.invited_by,playback_v3_attempts.user_id,page_sections.library_id, and others). The parents are the narrow end of their own references, and the 1.0 squashed baseline should not freeze that inconsistency or the 2^31 ceiling on the three most-referenced identities in the schema.Base branch:
schema/hygiene-standardization(PR #893) — fourth and last of the pre-bridge hygiene PRs; only the top two commits are new here. The three ids are alreadyGENERATED BY DEFAULT AS IDENTITYon that base.Approach
One migration,
20260901204344_widen_core_ids_to_bigint.sql, alters the three parent columns tobigint. Verified on PostgreSQL 18: the identity sequence type follows the column automatically (integer→bigint, max9223372036854775807), and reverts on the Down. Per the program plan the scope is the parents only; the migration header lists everyintegerchild column with its rewrite cost so the maintainer can schedule the child sweep separately (Postgres permitsint4→int8references, so nothing breaks in between).The Down narrows back to
integerbehind a guard that readsmin(id),max(id), and the sequence position for each table and raises a named error when any value is outside theint4range. It never truncates.Go-side changes are limited to what is actually wrong against a
bigintid: themedia_folderssweep cursor ininternal/metadata/artwork_reconcile.go(wasint32/ParseInt(..., 32)), and every::int[]/::intparameter cast bound against these columns or their children — ininternal/catalog/filesplit,internal/scanner/file_repo.go,internal/sections/repo.go,internal/usercollections/listing.go, and (found by a second sweep after review) the eightmedia_file_id/last_file_idcasts ininternal/catalog/reattribute/reattribute.go,activity_log.user_idininternal/api/handlers/admin.go, andlibrary_idcasts ininternal/catalog/library_collection_repo.goandinternal/userstore/pgstore/setting_values.go. Ids areinteverywhere else (fine on 64-bit); jellycompat encodes asuint64; the plugin SDK already usesint64. The remaining::int/::integercasts in the tree were classified one by one: row counts, season/episode numbers, ordinals, locked-field enums, andNULL::intplaceholders — none bind an id. Output-side casts on still-integerchild columns (literaryworks,search_indexer,library_collection_repoarray scans) and fourint4advisory-lock sites that narrowusers.idare listed in the migration header for the child sweep.internal/catalog/reattribute/reattribute_bigint_db_test.go(gated onSILO_TEST_DATABASE_URL) runs a real reattribution with amedia_filesid of 3,000,000,000 in the moved-file set and proves the subset queries accept it; it fails against the pre-fix code with pgx'sunable to encode []int{3000000000, ...} into binary format for _int4.migrations/widen_core_ids_to_bigint_test.gopins the threeALTERs, both guard bounds, and that no child is widened.internal/database/widen_core_ids_downguard_test.go(gated onSILO_TEST_DATABASE_URL, same skip convention as the neighbouring tests) proves the Down refuses an id above2^31and one below-2^31, and succeeds once they are removed.Maintenance-window note (for the release notes)
This migration rewrites
users,media_files, andmedia_folders(table plus every index: 3 tables, 28 indexes) and holdsACCESS EXCLUSIVEon every relation that references them — forusersthat is nearly every table in the schema, including the date-partitionedactivity_logandoperational_logs— for the duration. Children are not rewritten, but each referencing table is sequentially scanned once to revalidate its foreign key. Proportional tomedia_filesrow count × its 89 columns; needs free disk for a second copy plus index rebuilds. RaiseSILO_MIGRATE_TIMEOUTabove its 20-minute default on large libraries (the threeALTERs share one transaction, so a timeout aborts cleanly with nothing changed). A verified backup is required perdocs/release-versioning.md. The generic operator guidance now lives indocs/wiki/deployment/docker.md("Backups and updates").Validation
20260901180726and re-up: clean.bigint; explicit ids above2^31inserted into each parent and into abigintchild FK succeed.bigint; after removal the Down succeeds and re-Up restores head. Reproduced independently by the destructive-safety reviewer on its own scratch DB.make migrate-validate,make embed-stub,go build ./...,gofmt(empty),go vet: pass.golangci-lint run --new-from-merge-base="origin/main": 0 issues.make test-go: all ok (includes the contract test). DB-gatedTestMigrateDownToRefusesOutOfRangeCoreIDsrun against a scratch database: pass.pnpm run lint,format:check,build,make test-web: pass.make verify-settings-bindings-all,verify-playback-fixtures,verify-local-paths: pass.Risks
internal/catalogTestEpisodeSearchPostgresAndDocumentSource, reproduces at the base commit and is unrelated.Checklist
AI Disclosure