diff --git a/app.py b/app.py index aeef0ef55..d31c49397 100644 --- a/app.py +++ b/app.py @@ -106,9 +106,6 @@ class InjectingFilter(logging.Filter): root_logger = logging.getLogger() -# Add a null handler to the root logger to silence missing handler errors in tests -root_logger.addHandler(logging.NullHandler()) - # Add the request id filter to all handlers of the root logger for handler in root_logger.handlers: handler.addFilter(InjectingFilter()) diff --git a/util/migrate/allocator.py b/util/migrate/allocator.py index b25ed3cf7..c0502a843 100644 --- a/util/migrate/allocator.py +++ b/util/migrate/allocator.py @@ -132,13 +132,15 @@ def yield_random_entries(batch_query, primary_key_field, batch_size, max_id): try: while True: start_index = allocator.get_block_start_index(batch_size) + end_index = min(start_index + batch_size, max_id + 1) all_candidates = list(batch_query() .where(primary_key_field >= start_index, - primary_key_field <= start_index + batch_size)) + primary_key_field < end_index) + .order_by(primary_key_field)) if len(all_candidates) == 0: - logger.info('No candidates, new highest id: %s', start_index) - allocator.mark_completed(start_index, max_id + 1) + logger.info('No candidates, marking entire block completed %s-%s', start_index, end_index) + allocator.mark_completed(start_index, end_index) continue logger.info('Found %s candidates, processing block', len(all_candidates)) diff --git a/util/migrate/backfill_content_checksums_and_torrent_pieces.py b/util/migrate/backfill_content_checksums_and_torrent_pieces.py index 4a13f2e64..c20b96bad 100644 --- a/util/migrate/backfill_content_checksums_and_torrent_pieces.py +++ b/util/migrate/backfill_content_checksums_and_torrent_pieces.py @@ -88,7 +88,7 @@ def backfill_content_checksums_and_torrent_pieces(piece_length): max_id): locations = _get_image_storage_locations(candidate_storage.id) - checksum = ImageStorage.content_checksum + checksum = candidate_storage.content_checksum torrent_pieces = '' with CloseForLongOperation(app.config): try: