Skip to content

fix(backup): prevent restore database name collisions - #5449

Merged
Quick104 merged 1 commit into
mainfrom
fix/restore-db-name-collisions
Nov 27, 2026
Merged

Quick104 merged 1 commit into
mainfrom
fix/restore-db-name-collisions

Conversation

@Quick104

@Quick104 Quick104 commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Restore swaps of different databases on the same PostgreSQL cluster can fail when they start in the same second. The main CI run hit the collision in the plugin provisioning restore test. An earlier run hit it in the command test for restoring an older schema. Main CI run · Earlier CI run

Related issue: N/A
Validation tasks: none

Other clients: N/A (no client-visible change)

Approach

Include the live database's OID in the restore identifier so each swap gets its own database names and journal. The PostgreSQL regression test restores several databases at one fixed time and keeps the previous databases until the cases finish.

Validation

  • Both affected PostgreSQL tests passed twice. The regression test reproduced the failure with the original restore code.
  • All 1,135 database pins passed on PostgreSQL 18.7 with pgvector.
  • The full Go suite, build, lint, vet, and contract checks passed.
  • The web build and checks passed. Two web tests timed out at default parallelism, and all 3,460 passed when the full suite was rerun with 12 workers.

Evidence

Evidence: https://evidence.siloserver.org/r/silo-server/pr-5449/

The PostgreSQL runs verified the patch in commit c6ecba782a.

Risks

Operators use the full identifier printed by the restore command with --recover. A recovery reads the names from its authenticated journal, including journals written before this change.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.
  • Each test this pull request adds meets "Decide what to test" in CONTRIBUTING.md.
  • The Evidence section shows every change a user can see, or how I checked a change nobody sees.

AI Disclosure

  • Harness: OpenAI Codex in T3 Code
  • Tool(s): Codex
  • Model(s): gpt-6.2-sol
  • Involvement: AI-assisted
  • Adversarial review: Traced the restore lock, database names, and recovery of an interrupted swap. With the largest OID, the longest name is 47 bytes and fits PostgreSQL's 63 byte limit. Recovery uses names and OIDs from the authenticated journal. The backup package's crash recovery tests passed.

Note

Fix restore database name collisions by adding live database OID to restore identifier

  • RestoreSwap in swap.go now builds the restore identifier from the UTC timestamp plus the live database OID, so restores of different databases on the same PostgreSQL server no longer collide when they start in the same second.
  • The live database OID lookup and missing-database check moved from swapPreflight into RestoreSwap, which now runs them before opening swap stores. swapPreflight returns only an error.
  • Tests were updated: swapStamp expects the OID suffix, and restore helpers no longer force one-second spacing between restores.
  • Behavioral Change: RestoreSwap now fails before opening swap stores if the live database OID cannot be read or the database is missing; the Journaled callback in SwapOptions receives the restore identifier, not a time value.

Macroscope summarized c6ecba7.

@silo-triage silo-triage Bot added the size/M 50–199 added + deleted lines (all files); change volume, not priority. label Nov 27, 2026
@coderabbitai

coderabbitai Bot commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

  • Ask an admin to enable usage-based reviews

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Next included review available in 14 seconds.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c3ee0b82-08e3-4fed-b26f-fc46b817cae6
Commits

Reviewing files that changed from the base of the PR and between 88db53a and c6ecba7.

Files selected for processing: 5

  • docs/architecture/backups.md
  • internal/backup/carry_same_account_postgres_test.go
  • internal/backup/plugin_provision_postgres_test.go
  • internal/backup/swap.go
  • internal/backup/swap_test.go
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-27T02:39:24.921290Z c6ecba7 PR opened
🔒 Security Review ✅ Completed 2026-11-27T02:40:57.542205Z c6ecba7 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@silo-kody

silo-kody Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌
⚠️ 5 Kody Rule(s) were not evaluated

These rules declare that they need repository context beyond this diff, and the review could not retrieve it, so they were not judged on this pull request:

  • Preserve optional store capabilities through production wrappers
  • Detach mandatory cleanup from request cancellation and bound its lifetime
  • Preserve durable media identity and share identity-evidence precedence
  • Bound decoder throughput trades and share direct-play eligibility
  • Retain distributed firing claims through their own validity windows

@Quick104
Quick104 merged commit 38c3b8c into main Nov 27, 2026
9 checks passed
@Quick104
Quick104 deleted the fix/restore-db-name-collisions branch November 27, 2026 02:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M 50–199 added + deleted lines (all files); change volume, not priority.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant