fix(mbi): handle orphaned InnoDB tablespace in temp table creation to prevent ETL crash#3165
fix(mbi): handle orphaned InnoDB tablespace in temp table creation to prevent ETL crash#3165
Conversation
… prevent ETL crash Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are limited based on label configuration. 🏷️ Required labels (at least one) (1)
Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Great job! No new security vulnerabilities introduced in this pull request |
Extract the _recreateTempTable recovery logic from Metrics.pm into a shared TableUtils::recreate_table() function, then use it in all MBI lib files that create InnoDB temp tables via bare DROP + CREATE. This prevents the errno 184 "Tablespace already exists" crash across all ETL code paths, not just the three in Metrics.pm. MON-185830
| # InnoDB tablespace (.ibd file) may exist after a database migration (e.g. | ||
| # rsync of /var/lib/mysql). Without this, CREATE TABLE dies with errno 184 | ||
| # "Tablespace already exists" and the ETL crashes. | ||
| sub recreate_table { |
There was a problem hiding this comment.
This new feature is used in several places; it would be wise to have the associated unit tests, as several different outputs are possible depending on the inputs.
There was a problem hiding this comment.
I wrote some unit tests, but not really convinced about the value they bring. Can we discuss about this when you have some time?
|
🤖 This is an automatic comment generated by an internal tool. Complexity Classification: StandardJustification: Automatic classification failed; defaulting to standard.
A maintainer can override this classification at any time. |

Description
The daily ETL (
centreonBIETL) crashes witherrno: 184 "Tablespace already exists"whenmod_bi_tmp_*tables have orphaned InnoDB tablespace files (.ibd) left behind after a database migration (e.g. rsync of/var/lib/mysql). Since all DB connections usedie => 1, the failedCREATE TABLEimmediately crashes the process.Root cause:
DROP TABLE IF EXISTSis a no-op when the table doesn't exist in the data dictionary, but the orphaned.ibdfile on disk causesCREATE TABLEto fail.Changes to
Metrics.pm:New
_recreateTempTablehelper: Wraps theDROP + CREATEpattern with multi-step error recovery:DROP TABLE IF EXISTS+CREATE TABLEeval): checks if the table structure still exists in DD (e.g., DROP only partially succeeded) and reuses it viaTRUNCATEDROP + CREATEon a fresh connection (the error handler auto-disconnects)Updated all three
createTempTable*methods to use_recreateTempTableinstead of bareDROP + CREATEcallsFixed
dropTempTableCtimeMinMaxValues: ChangedDROP TABLEtoDROP TABLE IF EXISTSto prevent crashes when the table doesn't existFixes MON-185830
Type of change
Target serie
How this pull request can be tested ?
/var/lib/mysqlwhile MariaDB is running, or manually create.ibdfiles formod_bi_tmp_*tables/usr/share/centreon-bi/etl/centreonBIETLerrno: 184 "Tablespace already exists"