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

Salvaging an ARCHIVE table with archive_reader #12

Open
alpha0010 opened this issue Nov 12, 2021 · 0 comments
Open

Salvaging an ARCHIVE table with archive_reader #12

alpha0010 opened this issue Nov 12, 2021 · 0 comments

Comments

@alpha0010
Copy link

While trying to recover a corrupted ARCHIVE table, my searching lead me here. Posting my findings in case it also helps someone in the future. (Note that archive_reader is not specific to this fork - this fork is just where I was lead.)

Patched code with:

diff --git a/storage/archive/CMakeLists.txt b/storage/archive/CMakeLists.txt
index 78fb95c0d2..799ad44a6f 100644
--- a/storage/archive/CMakeLists.txt
+++ b/storage/archive/CMakeLists.txt
@@ -16,3 +16,5 @@
 SET(ARCHIVE_SOURCES  azio.c ha_archive.cc ha_archive.h)
 MYSQL_ADD_PLUGIN(archive ${ARCHIVE_SOURCES} STORAGE_ENGINE LINK_LIBRARIES ${ZLIB_LIBRARY})
 
+MYSQL_ADD_EXECUTABLE(archive_reader archive_reader.c azio.c)
+TARGET_LINK_LIBRARIES(archive_reader mysys)
diff --git a/storage/archive/archive_reader.c b/storage/archive/archive_reader.c
index 2475418fef..7a3fd792c7 100644
--- a/storage/archive/archive_reader.c
+++ b/storage/archive/archive_reader.c
@@ -39,6 +39,8 @@ static char **default_argv;
 int opt_check, opt_force, opt_quiet, opt_backup= 0, opt_extract_frm;
 int opt_autoincrement;
 
+PSI_file_key arch_key_file_metadata, arch_key_file_data, arch_key_file_frm;
+
 int main(int argc, char *argv[])
 {
   unsigned int ret;
  • Compiled with cmake && make archive_reader -j4.
  • Shutdown MySQL/MariaDB server (should work with either; I do not think anyone has worked on the ARCHIVE engine for over a decade).
  • Backup your mysql data dir in case something goes wrong.
  • Rebuild the <table-name>.ARZ with archive_reader --backup path/to/table.ARZ new-file.ARZ.
  • Replace <table-name>.ARZ with the new file.
  • If <table-name>.ARN exists, delete it.
  • Start up the db server.
  • Before doing anything else, mysqldump the table.
    • The server thinks the table is valid, so even if corruption was not repaired, you should still be able to dump data up to the point where it had an issue. Can load this dump later, if need be.
  • If there were no errors, hopefully everything is good to go.

We found ARCHIVE engine to be 6x smaller than compressed InnoDB (and 10x smaller than uncompressed), so still has value. If you too must stay with ARCHIVE, I recommend FLUSHing the table after completing any major write.

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

1 participant