From d8515c8d359e92dfc1748df87b98a431e2c1d76f Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Thu, 27 Aug 2020 18:59:09 +0200 Subject: [PATCH] S3 plugin fails to load depending on loaded storage engines storage engines are generally initialized in some random order (by iterating the hash of plugin names). S3 fails if it's initialized before Aria. But it looks that while S3 needs Aria, it does not need Aria to be initialized before S3. S3 copies maria_hton and then overwrites every single member of it, so it can handle Aria being initialized after S3. --- storage/maria/ha_maria.cc | 2 +- storage/maria/ha_s3.cc | 13 +++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index 5f195a9eb8e..26066135b2c 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -72,7 +72,7 @@ const char *zerofill_error_msg= corrupted. */ ulonglong maria_recover_options= HA_RECOVER_NONE; -handlerton __attribute__((visibility("default"))) *maria_hton; +handlerton *maria_hton; /* bits in maria_recover_options */ const char *maria_recover_names[]= diff --git a/storage/maria/ha_s3.cc b/storage/maria/ha_s3.cc index e9396329c50..cf2b9098142 100644 --- a/storage/maria/ha_s3.cc +++ b/storage/maria/ha_s3.cc @@ -51,7 +51,11 @@ but the stored block will be the size of the compressed block. Implementation: - The s3 engine inherits from the ha_maria handler + The s3 engine inherits from the ha_maria handler. + + It uses Aria code and relies on Aria being enabled. We don't have to check + that Aria is enabled though, because Aria is a mandatory plugin, and + the server will refuse to start if Aria failed to initialize. s3 will use it's own page cache to not interfere with normal Aria usage but also to ensure that the S3 page cache is large enough @@ -996,14 +1000,7 @@ static int ha_s3_init(void *p) bool res; static const char *no_exts[]= { 0 }; - /* This can happen if Aria fails to start */ - if (!maria_hton) - return HA_ERR_INITIALIZATION; - s3_hton= (handlerton *)p; - - /* Use Aria engine as a base */ - memcpy(s3_hton, maria_hton, sizeof(*s3_hton)); s3_hton->db_type= DB_TYPE_S3; s3_hton->create= s3_create_handler; s3_hton->panic= s3_hton_panic;