Repository navigation
server-zd: migrate the history of existing runs to segments - #1368
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
…r-zd Runs that started before their partition offloaded history, or while offload was off, have no segment state. Once offload was on, window pruning stopped for them because nothing above the uploaded seq may be deleted, and none of their history reached object storage. The first command that leaves such a run running while its partition offloads now starts the migration. The open segment starts at the run's first seq and event 1, and each command of the run seals at most one segment of it, cut from history metadata at whole seqs. A segment ends at the first seq where it holds two history records and reaches the target bytes, 10,000 superseded values, or 10,000 history rows, or at the command's own seq, which ends the migration. Two records per segment let the migration gain on the run. Each segment holds the rows still stored in its seqs, so seqs that window pruning deleted earlier are holes inside the reported pruned range. Event ranges come from metadata, with records that predate last_assigned_event_id decoded instead. RunRecord field 64, history_migration_started_seq, marks a migrating run; its open segment then tracks no bytes. Closed runs are not migrated. A run that closes while migrating seals one more segment at the close and keeps the rest local until purge. Turning offload off ends a migration, and its unsealed rest joins the gap of commands applied while offload is off. Tests cover the migration in apply, a restored testdata/v1 recording with running, closed, and migrating legacy runs, the uploader, and the simulation, which now requires at most one sealed segment per run and command. testdata/v1 is regenerated with its generator. Refs #1325
longquanzheng
force-pushed
the
history-offload/b7-migration
branch
from
November 7, 2026 06:50
72cfc22 to
329506a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Runs that existed before their partition offloaded history, started before the upgrade or while history offload was off, now migrate their local history to segments. The first command that leaves such a run running while its partition offloads opens its segment state at the run's first seq and event 1. Each later command of the run seals at most one segment, cut from history metadata at whole seqs, until a segment reaches the command itself. The run then seals like a run that started with offload on.
last_assigned_event_idare decoded instead.history_migration_started_seq, marks a migrating run; its open segment then tracks no bytes.Why
Refs #1325 (plan step B7, existing runs). Stacked on #1363 (B6, uploader); it will be retargeted to main once #1363 merges.
Before this change, a run without segment state in an offloading partition was fenced at uploaded seq 0. Window pruning stopped for it and none of its history reached object storage, so its local history grew without bound once offload was on. Migrating in bounded steps uploads that history without a spike.
Changes to B5 code:
segment_seal.rsextractswrite_sealed_segmentandsegment_target_byteswithout changing behavior, andRunCursor::finishcalls the migration-aware wrapper. B5's testruns_started_before_offload_keep_no_segment_state_and_keep_their_historyis removed because B7 replaces that behavior. B5's simulation transition check (H9) now also accepts a migration start and a migration step, and requires progress on every command of a migrating run.Compatibility
testdata/v1is regenerated with its generator and its pin is updated. The workload appendslegacy-running,legacy-closed, andlegacy-migratingruns at its end.Testing
a_recorded_running_run_migrates_one_segment_per_command_once_offload_is_on; applya_running_legacy_run_migrates_one_segment_per_command_until_caught_up.a_recorded_closed_run_is_not_migrated_and_its_purge_deletes_its_local_history; applya_closed_legacy_run_is_not_migrated_and_its_purge_deletes_its_history.time_travel_during_the_migration_of_a_recorded_run_is_correct; applytime_travel_during_a_migration_restores_its_target_and_the_migration_continues.a_run_started_while_offload_was_off_uploads_all_its_history_once_offload_is_on(real uploader, in-memory object store); applya_run_started_while_offload_was_off_migrates_once_it_is_on.turning_offload_off_ends_a_migration_and_its_rest_becomes_a_gapandreenabling_offload_skips_the_gap_and_reads_report_its_pruned_events.last_assigned_event_id, commands larger than the target,a_legacy_seq_past_the_superseded_value_limit_migrates_in_one_step.cargo fmt --check, workspace clippy-D warnings,make rust-rules-check,make copyright-check,cd docs && npm run checkpass.