Skip to content

Commit 1bdd9e3

Browse files
authored
Merge pull request #174 from tanmoysrt/improve_post_validation
refactor(physical-restore): Optimize table validations and repair
2 parents bcf0483 + bab7656 commit 1bdd9e3

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

agent/database_physical_restore.py

+7-13
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ def create_restore_job(self):
7575
self.import_tablespaces_in_target_db()
7676
self.hold_write_lock_on_myisam_tables()
7777
self.perform_myisam_file_operations()
78-
self.perform_post_restoration_validation_and_fixes()
7978
self.unlock_all_tables()
79+
self.perform_post_restoration_validation_and_fixes()
8080

8181
@step("Validate Backup Files")
8282
def validate_backup_files(self): # noqa: C901
@@ -294,7 +294,11 @@ def perform_post_restoration_validation_and_fixes(self):
294294
"""
295295

296296
for table in innodb_tables_with_fts:
297-
if self.is_table_corrupted(table) and not self.repair_table(table, "innodb"):
297+
"""
298+
No need to waste time on checking whether index is corrupted or not
299+
Because, physical restoration will not work for FULLTEXT index.
300+
"""
301+
if not self.repair_table(table, "innodb"):
298302
raise Exception(f"Failed to repair table {table}")
299303

300304
"""
@@ -311,16 +315,6 @@ def perform_post_restoration_validation_and_fixes(self):
311315
if self.is_table_corrupted(table) and not self.repair_table(table, "myisam"):
312316
raise Exception(f"Failed to repair table {table}")
313317

314-
for table in self.innodb_tables:
315-
if table in innodb_tables_with_fts:
316-
continue
317-
"""
318-
If other innodb tables are corrupted,
319-
We can't repair the table in running database
320-
"""
321-
if self.is_table_corrupted(table):
322-
raise Exception(f"Failed to repair table {table}")
323-
324318
@step("Unlock All Tables")
325319
def unlock_all_tables(self):
326320
self._get_target_db().execute_sql("UNLOCK TABLES;")
@@ -453,7 +447,7 @@ def is_table_corrupted(self, table_name: str) -> bool:
453447
""" # noqa: E501
454448
isError = False
455449
for row in result:
456-
if row[2] == "error":
450+
if row[2] == "error" or (row[2] == "warning" and table_name in self.myisam_tables):
457451
isError = True
458452
break
459453
return isError

0 commit comments

Comments
 (0)