B2_Command_Line_Tool icon indicating copy to clipboard operation
B2_Command_Line_Tool copied to clipboard

IndexError: list index out of range when continuing a sync started with Cyberduck

Open briancsimonsen opened this issue 6 years ago • 8 comments

The error occurs while trying to sync a large number of files (~139000) for upload. The process worked correctly on default settings up until nearly the end where the following error occurred. This sync has never successfully completed and is going to a new bucket on a new account.

H:\>b2 sync --skipNewer . b2://FamilyLaCieBackup/Cyberduck
ERROR:b2sdk.sync.action:an exception occurred in a sync action
Traceback (most recent call last):
  File "c:\program files\python37\lib\site-packages\b2sdk\sync\action.py", line 49, in run
    self.do_action(bucket, reporter)
  File "c:\program files\python37\lib\site-packages\b2sdk\sync\action.py", line 129, in do_action
    progress_listener=SyncFileReporter(reporter)
  File "c:\program files\python37\lib\site-packages\logfury\v0_1\trace_call.py", line 84, in wrapper
    return function(*wrapee_args, **wrapee_kwargs)
  File "c:\program files\python37\lib\site-packages\b2sdk\bucket.py", line 591, in upload
    upload_source, file_name, content_type, file_info, progress_listener
  File "c:\program files\python37\lib\site-packages\b2sdk\bucket.py", line 649, in _upload_large_file
    part_ranges,
  File "c:\program files\python37\lib\site-packages\b2sdk\bucket.py", line 696, in _find_unfinished_file_if_possible
    offset, part_length = part_ranges[part.part_number - 1]
IndexError: list index out of range
b2_upload(\\?\H:\mp4FILES\REEL14.mp4, Cyberduck/mp4FILES/REEL14.mp4, 1369161244000): IndexError('list index out of range') list index out of range
ERROR:b2sdk.sync.action:an exception occurred in a sync action
Traceback (most recent call last):
  File "c:\program files\python37\lib\site-packages\b2sdk\sync\action.py", line 49, in run
    self.do_action(bucket, reporter)
  File "c:\program files\python37\lib\site-packages\b2sdk\sync\action.py", line 129, in do_action
    progress_listener=SyncFileReporter(reporter)
  File "c:\program files\python37\lib\site-packages\logfury\v0_1\trace_call.py", line 84, in wrapper
    return function(*wrapee_args, **wrapee_kwargs)
  File "c:\program files\python37\lib\site-packages\b2sdk\bucket.py", line 591, in upload
    upload_source, file_name, content_type, file_info, progress_listener
  File "c:\program files\python37\lib\site-packages\b2sdk\bucket.py", line 649, in _upload_large_file
    part_ranges,
  File "c:\program files\python37\lib\site-packages\b2sdk\bucket.py", line 696, in _find_unfinished_file_if_possible
    offset, part_length = part_ranges[part.part_number - 1]
IndexError: list index out of range
b2_upload(\\?\H:\mp4FILES\REEL5.mp4, Cyberduck/mp4FILES/REEL5.mp4, 1369151190000): IndexError('list index out of range') list index out of range
ERROR:b2.console_tool:ConsoleTool command error
Traceback (most recent call last):
  File "c:\program files\python37\lib\site-packages\b2\console_tool.py", line 1361, in run_command
    return command.run(args)
  File "c:\program files\python37\lib\site-packages\b2\console_tool.py", line 1184, in run
    allow_empty_source=allow_empty_source
  File "c:\program files\python37\lib\site-packages\logfury\v0_1\trace_call.py", line 84, in wrapper
    return function(*wrapee_args, **wrapee_kwargs)
  File "c:\program files\python37\lib\site-packages\b2sdk\sync\sync.py", line 273, in sync_folders
    raise CommandError('sync is incomplete')
b2sdk.exception.CommandError: sync is incomplete
ERROR: sync is incomplete

This is a copy paste from the last try but I have tried a few different things to get around this error.

  • Python 2.7 (32 bit and 64 bit)
  • Change number of threads (1, 10, 100)
  • Python 3.7 (64 bit)
  • reinstall the b2 CLI

briancsimonsen avatar Jun 17 '19 17:06 briancsimonsen

I think this is a bug in B2 CLI. The _find_unfinished_file_if_possible function assumes that the number of parts on B2 is at most equal to the number of parts for the local file. If there are more parts on B2 it will probably fail with this error you are seeing (haven't reproduced it).

Did you change the part size during your sync or did the file size of the corresponding files change? Until this bug is resolved you can delete the unfinished file from B2 and try syncing again.

svonohr avatar Jun 20 '19 06:06 svonohr

The files are all for archival purposes so none of the files should be edited in any way. However, the upload was originally attempted using Cyberduck but the speed was so slow that I switched to the CLI. I don't think that would be the cause considering the command I am running uses the default filename and modification time compare so all partially uploaded files would be skipped.

briancsimonsen avatar Jun 21 '19 23:06 briancsimonsen

If Cyberduck used a different part size than CLI, then it could be a problem.

In order to complete the sync, you could cancel the large file uploads (easy, via b2 cancel-all-unfinished-large-files <bucketName> or b2 list-unfinished-large-files <bucketName> and b2 cancel-large-file <fileId>) or try to match the part size with whatever cyberduck chose (hard).

ppolewicz avatar Jun 23 '19 03:06 ppolewicz

@ppolewicz was correct. There were quite a few unfinished files. After running the b2 cancel-all-unfinished-large-files <bucketName> command everything started working as expected and uploaded successfully.

briancsimonsen avatar Jun 24 '19 18:06 briancsimonsen

We should provide a useful error message instead of the current behavior, but I don't think we should implement a mechanism to detect the part size of the interrupted large file upload. It is possible, but it would never get used and the workaround is trivial, so we just need to tell the user what it is.

ppolewicz avatar Jun 24 '19 19:06 ppolewicz

Why an error message? If there are more parts on B2 than local parts, the unfinished file is not a match and we continue similar to when the file info is different.

svonohr avatar Jun 24 '19 19:06 svonohr

Fair point

ppolewicz avatar Jun 24 '19 20:06 ppolewicz

If unfinished files require system resources, treating unfinished files as unique and ignoring them might not be a good idea.

briancsimonsen avatar Jun 24 '19 20:06 briancsimonsen