Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better handling of error when dealing with an unknown compression #66

Open
timemaster67 opened this issue Oct 17, 2018 · 2 comments
Open

Comments

@timemaster67
Copy link

what hapenned :
Restoring a backup make with lz4 compression with an older release fail in a non intuitive way. It will simply stall indefinitely, with no error message, and require to kill the program.

how to reproduce :

  1. get a compiled static binary from fsarchiver version 0.8.3 or later from the website.
  2. use savefs to make a backup of the file system
  3. on a new system, use an older version of fsarchiver. Used an older System Rescue CD here.
  4. try to restore the file system. the restore stall and nothing is printed on the console. you cannot do control-C to cancel it. sending kill signal does nothing. you need to kill -9.
  5. try again with -v one time. you see that it can format the file system, and create some folder, but will stall on the first file. There is no error message.
  6. try again with -V 2 times. It will print more information including this line at the top

thread_comp.c#243,decompress_block_generic(): unsupported compression algorithm: 7

comment :
Here, clearly, the user is at fault. fsarchiver 0.8.3 will default to the new algorithm and this conflicted with the older program but it's still a user fault. they (I) just need to use the newer version to do the restore.

I don't ask to patch all older version of the program, that's impossible.
However, if you could modify the current version of the program to handle this case more gracefully, that would be great.
If in the future a new compression is added, this issue would be more clear than what is currently is.

possible improvement could be :
if there is an error when uncompressing a file,

  1. print an error message that will appear without needing to add -vv.
  2. get a more descriptive error message. for example "Restore failed because the file was saved with an unknown compression algorithm".
  3. stop the restore and exit the program.

if that's not possible, it's not that big of a deal. you don't add new compression algorithm quite often hehe.

@marcosfrm
Copy link
Contributor

Small improvement:

diff --git a/src/thread_comp.c b/src/thread_comp.c
index 7e2ce01..fafe8e7 100644
--- a/src/thread_comp.c
+++ b/src/thread_comp.c
@@ -39,6 +39,7 @@
 #include "thread_comp.h"
 #include "error.h"
 #include "queue.h"
+#include "archinfo.h"
 
 int compress_block_generic(struct s_blockinfo *blkinfo)
 {
@@ -99,7 +100,7 @@ int compress_block_generic(struct s_blockinfo *blkinfo)
 #endif // OPTION_ZSTD_SUPPORT
             default:
                 free(bufcomp);
-                msgprintf(2, "invalid compression level: %d\n", (int)compalgo);
+                msgprintf(2, "unsupported compression algorithm: %s\n", compalgostr(compalgo));
                 return -1;
         }
 
@@ -274,7 +275,7 @@ int decompress_block_generic(struct s_blockinfo *blkinfo)
                 break;
 #endif // OPTION_ZSTD_SUPPORT
             default:
-                errprintf("unsupported compression algorithm: %ld\n", (long)blkinfo->blkcompalgo);
+                errprintf("unsupported compression algorithm: %s\n", compalgostr(blkinfo->blkcompalgo));
                 return -1;
         }
         free(blkinfo->blkdata); // free old buffer (with compressed data)

src/oper_restore.c logic is still broken though.

@marcosfrm
Copy link
Contributor

Posted #87 for the error messages.

get_stopfillqueue();

This does not look right. At a first glance, it should stop the queue with queue_set_end_of_queue(), but it is not enough after testing. :-(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants