fix: Pass last_completed_partition to ALL migration_state updates, not just final
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 <noreply@anthropic.com>
This commit is contained in:
@@ -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, "
|
||||
|
||||
Reference in New Issue
Block a user