From 8c48e5eecbc53b474cb2ee46cb5c3c56161303e6 Mon Sep 17 00:00:00 2001 From: alex Date: Fri, 26 Dec 2025 20:23:11 +0100 Subject: [PATCH] fix: Pass last_completed_partition to ALL migration_state updates, not just final MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problem: During partition processing, frequent batch flushes were updating migration_state but NOT passing last_partition parameter. This meant that even though last_processed_partition was being tracked, it was being overwritten with NULL every time the buffer was flushed. Result: Migration state would show last_partition=None despite partitions being completed, making resume tracking useless. Solution: Pass last_processed_partition to ALL _update_migration_state() calls, not just the final one after partition completion. This ensures the last completed partition is always preserved in the database. 🤖 Generated with Claude Code Co-Authored-By: Claude Haiku 4.5 --- src/migrator/full_migration.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/migrator/full_migration.py b/src/migrator/full_migration.py index 200b888..98966e6 100644 --- a/src/migrator/full_migration.py +++ b/src/migrator/full_migration.py @@ -198,9 +198,10 @@ class FullMigrator: batch_count += 1 progress.update(fetched_in_buffer) # Update migration state after every batch flush - # Do NOT set last_completed_partition yet - partition is still being processed + # Keep last_completed_partition if we've completed partitions before self._update_migration_state( - pg_conn, migrated, None, migration_start_time + pg_conn, migrated, None, migration_start_time, + last_partition=last_processed_partition ) logger.debug( f"Partition {partition}: flushed {inserted} rows, " @@ -217,9 +218,10 @@ class FullMigrator: migrated += inserted batch_count += 1 progress.update(fetched_in_buffer) - # Still don't set last_completed_partition - partition is still being finalized + # Keep last_completed_partition if we've completed partitions before self._update_migration_state( - pg_conn, migrated, None, migration_start_time + pg_conn, migrated, None, migration_start_time, + last_partition=last_processed_partition ) logger.debug( f"Partition {partition} final flush: {inserted} rows, "