Skip to content

fix(storage): skip redundant v2 message backfill - #743

Merged
Sinity merged 1 commit into
masterfrom
feature/fix/schema-v2-upgrade-skip-existing-backfill
May 3, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/fix/schema-v2-upgrade-skip-existing-backfill

Conversation

@Sinity

@Sinity Sinity commented May 3, 2026

Copy link
Copy Markdown
Owner

Summary

Avoids an unnecessary archive-wide message-type backfill when a schema v2 archive already has the v3 messages.message_type column.

Problem

PR #742 added the right v2-to-v3 upgrade path, but the upgrade plan still appended the message-type backfill whenever messages existed. That is wasteful for the live failure shape: a physically v3-shaped DB whose PRAGMA user_version was rewritten to 2 by an older binary. Running the backfill there would scan the archive even though the column already exists.

Solution

Only append the message-type backfill when messages.message_type is absent. Already-extended v2 archives now repair missing version/index state without rereading all messages/content blocks.

Verification

  • PYTHONPATH=. /realm/project/polylogue-schema-v2-upgrade/.venv/bin/python -m pytest -q tests/unit/storage/test_backend.py tests/unit/storage/test_schema_safety.py -> 61 passed in 8.72s
  • PYTHONPATH=. /realm/project/polylogue-schema-v2-upgrade/.venv/bin/ruff check polylogue/storage/backends/schema_bootstrap.py tests/unit/storage/test_backend.py -> All checks passed!
  • PYTHONPATH=. /realm/project/polylogue-schema-v2-upgrade/.venv/bin/ruff format --check polylogue/storage/backends/schema_bootstrap.py tests/unit/storage/test_backend.py -> 2 files already formatted
  • git diff --check
  • Pre-push hook under the Polylogue devshell -> verify: all checks passed

Ref #618

Problem: the v2-to-v3 upgrade added by PR #742 still planned the message-type backfill when a database already had messages.message_type but only carried the old user_version marker. That is the exact live workstation shape, so applying the fix would still scan the archive unnecessarily.\n\nWhat changed: only append the message-type backfill when the message_type column is absent. Already-extended v2 archives repair only missing version/index state.\n\nVerification: PYTHONPATH=. /realm/project/polylogue-schema-v2-upgrade/.venv/bin/python -m pytest -q tests/unit/storage/test_backend.py tests/unit/storage/test_schema_safety.py; ruff check/format on changed Python files; git diff --check.\n\nRef #618
Copilot AI review requested due to automatic review settings May 3, 2026 01:32
@coderabbitai

coderabbitai Bot commented May 3, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@Sinity has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 54 minutes and 10 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 473b94cf-bdf7-400d-8f98-3b29309dbd10

📥 Commits

Reviewing files that changed from the base of the PR and between 2bd6630 and c963b1a.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • polylogue/storage/backends/schema_bootstrap.py
  • tests/unit/storage/test_backend.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/fix/schema-v2-upgrade-skip-existing-backfill

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 54 minutes and 10 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

@Sinity
Sinity merged commit 5eec6cc into master May 3, 2026
4 checks passed
@Sinity
Sinity deleted the feature/fix/schema-v2-upgrade-skip-existing-backfill branch May 3, 2026 01:33
@Sinity
Sinity removed the request for review from Copilot May 3, 2026 01:55
Sinity added a commit that referenced this pull request May 7, 2026
Summary

Avoids an unnecessary archive-wide message-type backfill when a schema v2 archive already has the v3 `messages.message_type` column.

Problem

PR #742 added the right v2-to-v3 upgrade path, but the upgrade plan still appended the message-type backfill whenever `messages` existed. That is wasteful for the live failure shape: a physically v3-shaped DB whose `PRAGMA user_version` was rewritten to 2 by an older binary. Running the backfill there would scan the archive even though the column already exists.

Solution

Only append the message-type backfill when `messages.message_type` is absent. Already-extended v2 archives now repair missing version/index state without rereading all messages/content blocks.

Verification

- `PYTHONPATH=. /realm/project/polylogue-schema-v2-upgrade/.venv/bin/python -m pytest -q tests/unit/storage/test_backend.py tests/unit/storage/test_schema_safety.py` -> `61 passed in 8.72s`
- `PYTHONPATH=. /realm/project/polylogue-schema-v2-upgrade/.venv/bin/ruff check polylogue/storage/backends/schema_bootstrap.py tests/unit/storage/test_backend.py` -> `All checks passed!`
- `PYTHONPATH=. /realm/project/polylogue-schema-v2-upgrade/.venv/bin/ruff format --check polylogue/storage/backends/schema_bootstrap.py tests/unit/storage/test_backend.py` -> `2 files already formatted`
- `git diff --check`
- Pre-push hook under the Polylogue devshell -> `verify: all checks passed`

Ref #618
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