Integer underflow when repacking tapes where number of files in storage class is less than number of existing tape copies
Summary
In Scheduler::expandRepackRequest()
:
filesToArchive
is defined like this:
//We are in the case where we possibly need to create new copies (if the number of copies the storage class of the current ArchiveFile
//is greater than the number of tape files we have in the current ArchiveFile)
uint64_t nbFilesAlreadyArchived = getNbFilesAlreadyArchived(archiveFile);
uint64_t nbCopiesInStorageClass = sc.nbCopies;
uint64_t filesToArchive = nbCopiesInStorageClass - nbFilesAlreadyArchived;
If nbFilesAlreadyArchived
< nbCopiesInStorageClass
, filesToArchive
is an integer underflow.
This causes the following exception:
if(retrieveSubRequest.copyNbsToRearchive.size() < filesToArchive){
deleteRepackBuffer(std::move(dir),lc);
throw ExpandRepackRequestException("In Scheduler::expandRepackRequest(): Missing archive routes for the creation of the new copies of the files");
}
Steps to reproduce
- Reduce the number of copies in a dual-copy storage class from 2 to 1:
$ cta-admin sc ch -n backup_zvault -c 1
- Repack a tape with files in that storage class.
What is the current bug behaviour?
Repack stops with exception, In Scheduler::expandRepackRequest(): Missing archive routes for the creation of the new copies of the files
.
What is the expected correct behaviour?
Repack should repack one copy of the file.