Skip to content

feat: enhance online migration with auto-creation and cleanup of publications and slots#6

Closed
isdaniel wants to merge 4 commits into
mainfrom
feat/auto-creation-cleanup-pub-slot
Closed

feat: enhance online migration with auto-creation and cleanup of publications and slots#6
isdaniel wants to merge 4 commits into
mainfrom
feat/auto-creation-cleanup-pub-slot

Conversation

@isdaniel
Copy link
Copy Markdown
Owner

@isdaniel isdaniel commented May 8, 2026

  • Added support for auto-creating publications during online migration if they do not exist.
  • Implemented cleanup of auto-created publications and replication slots after successful cutover.
  • Introduced CLI flags to control the auto-creation of publications and retention of replication slots.
  • Updated documentation to reflect changes in migration phases and resource management.
  • Added integration tests to verify the lifecycle of publications and slots during online migrations.

…ications and slots

- Added support for auto-creating publications during online migration if they do not exist.
- Implemented cleanup of auto-created publications and replication slots after successful cutover.
- Introduced CLI flags to control the auto-creation of publications and retention of replication slots.
- Updated documentation to reflect changes in migration phases and resource management.
- Added integration tests to verify the lifecycle of publications and slots during online migrations.
@codecov
Copy link
Copy Markdown

codecov Bot commented May 8, 2026

Codecov Report

❌ Patch coverage is 89.45233% with 52 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.49%. Comparing base (442e188) to head (b4c7fd3).

Files with missing lines Patch % Lines
pg_dbmigrator/src/orchestrator.rs 40.50% 47 Missing ⚠️
pg_dbmigrator/src/dump.rs 81.81% 4 Missing ⚠️
pg_dbmigrator/src/preflight.rs 99.60% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main       #6      +/-   ##
==========================================
- Coverage   90.22%   89.49%   -0.74%     
==========================================
  Files          16       16              
  Lines        5154     5633     +479     
==========================================
+ Hits         4650     5041     +391     
- Misses        504      592      +88     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request implements automatic lifecycle management for PostgreSQL replication resources, enabling the migrator to auto-create publications and clean up publications and slots after cutover. It also introduces table-level progress reporting for dump and restore tasks and updates documentation to include a new SourceCleanup stage. Technical feedback highlights a bug in quoting schema-qualified table names, a state persistence issue for auto-created publications during migration resumes, a potential race condition when dropping replication slots, and a naming inconsistency between the code and documentation regarding the cleanup stage.

Comment thread pg_dbmigrator/src/preflight.rs Outdated
Comment thread pg_dbmigrator/src/orchestrator.rs Outdated
Comment thread pg_dbmigrator/src/orchestrator.rs Outdated
Comment thread pg_dbmigrator/src/orchestrator.rs Outdated
@isdaniel
Copy link
Copy Markdown
Owner Author

isdaniel commented May 8, 2026

/gemini review

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces automated lifecycle management for PostgreSQL replication resources during online migrations. It adds a new SourceCleanup pipeline stage to drop auto-created publications and replication slots after a successful cutover, controlled by new CLI flags --no-auto-create-publication and --keep-slot. The PR also improves progress visibility by parsing pg_dump and pg_restore stderr for table-level updates. Review feedback highlights opportunities to improve the robustness of SQL identifier quoting, refine the logic for mixed table/schema publications, and ensure consistent error propagation in cleanup functions to align with the project's design principles.

Comment thread pg_dbmigrator/src/dump.rs
Comment thread pg_dbmigrator/src/preflight.rs
Comment thread pg_dbmigrator/src/preflight.rs Outdated
Comment thread pg_dbmigrator/src/native_apply.rs Outdated
Comment thread pg_dbmigrator/src/native_apply.rs Outdated
- Fix schema-qualified quoting: validate empty parts, reject trailing/leading dots
- Combine tables+schemas in CREATE PUBLICATION (PG 15+ syntax)
- Propagate errors from drop_source_publication/drop_source_slot instead of swallowing
- Fix emit_table_progress to capture full identifier (not strip outer quotes)
- Persist pub_auto_created in ResumeToken for crash-safe cleanup
- Add SourceCleanup stage to MigrationStage enum
- Extract cleanup_source_after_cutover as public testable function
- Add wait_for_slot_inactive before drop_source_slot post-cutover
- Add integration tests for cleanup_source_after_cutover
- Fix CI port conflict: clean up stale containers before starting stack

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@isdaniel
Copy link
Copy Markdown
Owner Author

isdaniel commented May 8, 2026

/gemini review

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces automated lifecycle management for replication resources during online migrations, including the auto-creation of PostgreSQL publications and the post-cutover cleanup of publications and replication slots. It also enhances progress reporting by parsing table-level updates from pg_dump and pg_restore stderr. Feedback highlights a critical issue where auto-created publications do not respect exclude_tables or exclude_schemas, potentially causing the target apply worker to crash if excluded objects are modified on the source.

Comment thread pg_dbmigrator/src/orchestrator.rs
@isdaniel
Copy link
Copy Markdown
Owner Author

isdaniel commented May 8, 2026

/gemini review

@isdaniel
Copy link
Copy Markdown
Owner Author

isdaniel commented May 8, 2026

/gemini review

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces automated lifecycle management for PostgreSQL replication resources, enabling the migrator to auto-create publications on the source and clean up publications and replication slots after cutover. New CLI flags, --no-auto-create-publication and --keep-slot, provide control over these features. The PR also adds table-level progress reporting during dump and restore operations and updates the project's documentation and integration tests. Reviewers identified a potential bug in identifier quoting for schema names containing dots and a resource leak edge case in the resume logic. Additionally, there is a suggestion to move table-level progress logs to a lower severity level to avoid excessive output in large databases.

Comment thread pg_dbmigrator/src/preflight.rs
Comment thread pg_dbmigrator/src/orchestrator.rs
Comment thread pg_dbmigrator/src/dump.rs
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces automated lifecycle management for PostgreSQL replication resources, specifically publications and replication slots. The migrator now supports auto-creating publications on the source—respecting table and schema exclusions—and includes a new SourceCleanup stage to drop auto-created resources after cutover. New CLI flags, --no-auto-create-publication and --keep-slot, allow users to override these defaults. The PR also enhances progress visibility by emitting table-level updates from pg_dump and pg_restore, refactors the Agent.md developer guide, and adds extensive integration tests for the new functionality. I have no feedback to provide.

@isdaniel isdaniel closed this May 8, 2026
@isdaniel isdaniel deleted the feat/auto-creation-cleanup-pub-slot branch May 8, 2026 02:29
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