Skip to content

[Migration Engine Part 1] Implement the foundation for migration engine - #5894

Draft
warwickschroeder wants to merge 15 commits into
masterfrom
warwick/migration-engine-1
Draft

warwickschroeder wants to merge 15 commits into
masterfrom
warwick/migration-engine-1

Conversation

@warwickschroeder

@warwickschroeder warwickschroeder commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

What this adds

The foundation for moving an error instance's data from RavenDB to SQL Server or PostgreSQL: a read-only RavenDB source, a report command and the copy engine. Nothing is copied yet, there is no SQL target, and the migration is not switched on anywhere.

  • A read-only RavenDB source that refuses any write, and can describe itself and count every collection.
  • --migration-source-report prints the source's version, location, database names and row counts.
  • The source persister loads beside the configured one in the same process.
  • The migration engine copies in batches with checkpoint resume, retries, throttling and a halt threshold, and runs against in-memory fakes only.
  • Docs live in docs/migration/, linked from the README, and CI gains a Migration test category.

Tests

  • ServiceControl.UnitTests/Migration: the engine, category registry, options and fakes.
  • ServiceControl.UnitTests/Hosting: parsing --migration-source-report.
  • ServiceControl.UnitTests/ApprovalFiles: the new setting in the platform sample settings.
  • ServiceControl.Persistence.Tests.RavenDB/DataMigration: the read-only source's lifecycle.
  • ServiceControl.Migration.Tests (new): the report command, and both persisters in one process.

@rbev rbev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Partial review - adding as comments for now.

Comment thread docs/migration/ravendb-to-sql-migration-instructions.md Outdated
Comment thread docs/migration/ravendb-to-sql-migration-overview.md
Comment thread docs/migration/ravendb-to-sql-migration-overview.md Outdated
Comment thread docs/migration/ravendb-to-sql-migration-overview.md Outdated
Comment thread src/ServiceControl.Persistence/DataMigration/IMigrationTarget.cs
Comment thread src/ServiceControl.Persistence/DataMigration/IMigrationTarget.cs Outdated
Comment thread src/ServiceControl.Persistence/DataMigration/MigrationEngine.cs Outdated
Comment thread src/ServiceControl.Persistence/DataMigration/MigrationEngine.cs
@warwickschroeder
warwickschroeder added this pull request to stack #5898 September 16, 2026 04:25
@warwickschroeder warwickschroeder changed the title Implement the foundation for migration engine [Migration Engine Part 2] Implement the foundation for migration engine Sep 16, 2026
@warwickschroeder warwickschroeder changed the title [Migration Engine Part 2] Implement the foundation for migration engine [Migration Engine Part 1] Implement the foundation for migration engine Sep 16, 2026
Comment thread src/ServiceControl.UnitTests/Migration/MigrationEngineCategorySelectionTests.cs Outdated
Comment thread src/ServiceControl.UnitTests/Migration/MigrationEngineCategorySelectionTests.cs Outdated

@johnsimons johnsimons left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

A few question and comments but overall, lets keep going

Comment thread docs/migration/ravendb-to-sql-migration-instructions.md
Comment thread docs/migration/ravendb-to-sql-migration-overview.md Outdated
Comment thread docs/migration/ravendb-to-sql-migration-overview.md Outdated
Comment thread docs/migration/ravendb-to-sql-migration-overview.md Outdated
Comment thread docs/migration/ravendb-to-sql-migration-overview.md Outdated
Comment thread docs/migration/ravendb-to-sql-migration-overview.md Outdated
Comment thread docs/migration/ravendb-to-sql-migration-overview.md Outdated
Comment thread docs/migration/ravendb-to-sql-migration-overview.md Outdated
Comment thread docs/migration/ravendb-to-sql-migration-overview.md Outdated
…n, clarifying strategies, goals, and migration limitations.
…on source reporting

- Implemented MigrationEngineFailurePathTests to validate behavior during write failures and halts.
- Created MigrationEngineHaltTests to ensure categories halt correctly on systemic failures.
- Added MigrationEngineOptionsTests to verify default and environment variable configurations.
- Developed MigrationEngineOrderingTests to check execution order of migration categories.
- Introduced MigrationEngineResumeTests to confirm no duplicates or gaps after restarts.
- Added MigrationEngineRunCategoriesTests to ensure all categories run in specified order.
- Implemented MigrationEngineSkipReasonTests to validate skip reasons and their aggregation.
- Enhanced MigrationEngineThrottleTests to verify pause behavior for optional categories.
- Updated MigrationSourceReportCommand for improved output and clarity.
- Modified Help.txt and HostArguments.cs for better command descriptions.
- Refined Settings.cs and PersistenceFactory.cs for clearer migration source configuration.
- Introduced `BenignSkipped` property in `MigrationWriteResult` to track rows that the target would have deleted anyway.
- Updated `MigrationEngine` logic to ensure benign skips do not count towards the halt threshold.
- Added tests to verify that benign skips are handled correctly and do not cause category halts.
- Updated skip reasons to include `PastRetention` for better clarity on skipped rows.
- Created approval files for category selection tests to ensure correct order and configuration.
- Improved error logging in MigrationEngine to provide clearer context on exceptions.
- Added functionality to InMemoryMigrationSource to simulate shutdown behavior during body reads.
- Enhanced InMemoryMigrationTarget to allow custom exceptions for failure scenarios.
- Introduced TimerRecordingTimeProvider to facilitate testing of timer-related functionality.
- Expanded HaltThresholdTests to cover edge cases involving mixed benign and fault skips.
- Updated MigrationEngineBodyRetryTests to ensure proper handling of shutdowns during body reads.
- Added tests to verify behavior when categories are empty or already completed.
- Implemented checks for checkpoint conflicts and cancellation scenarios in MigrationEngineFailurePathTests.
- Enhanced MigrationEngineHaltTests to evaluate mixed skip scenarios and their impact on halting.
- Improved MigrationEngineOrderingTests to ensure blocked categories behave correctly.
- Added tests to MigrationEngineResumeTests to verify that restart behavior maintains original start time.
- Updated MigrationEngineRunCategoriesTests to handle cases where no categories are selected.
- Enhanced MigrationEngineSkipReasonTests to ensure accurate recording of multiple skip reasons.
- Added tests to MigrationEngineThrottleTests to verify behavior during pauses and shutdowns.
@warwickschroeder
warwickschroeder force-pushed the warwick/migration-engine-1 branch from 8949344 to 0dcf9c8 Compare September 30, 2026 01:24
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.

4 participants