2626#include < vector>
2727#include < algorithm>
2828#include < functional>
29+ #include < optional>
2930#include < variant>
3031
3132/*
@@ -596,7 +597,7 @@ namespace
596597#endif
597598 };
598599
599- std::unique_ptr <Aria_backup> aria_backup;
600+ std::optional <Aria_backup> aria_backup;
600601}
601602
602603/* *
@@ -614,7 +615,8 @@ int aria_backup_start(THD *thd, const backup_target &target,
614615 switch (phase)
615616 {
616617 case BACKUP_PHASE_START :
617- aria_backup= std::make_unique<Aria_backup>(thd, target);
618+ assert (!aria_backup);
619+ aria_backup.emplace (thd, target);
618620 return !aria_backup->is_initialized ();
619621 case BACKUP_PHASE_NO_DML_NON_TRANS :
620622 /* FIXME: Would be better to selectively purge only the tables we need. */
@@ -663,7 +665,16 @@ int aria_backup_step(THD *thd, const backup_target &target,
663665int aria_backup_end (THD *thd, const backup_target &target,
664666 backup_phase phase) noexcept
665667{
666- if (phase == BACKUP_PHASE_FINISH || phase == BACKUP_PHASE_ABORT )
668+ /* Note - aria_backup is currently a singleton object, and it is
669+ reset before BACKUP_PHASE_FINISH to allow for a new backup to run
670+ concurrently. With this design BACKUP_PHASE_FINISH must be a no-op.
671+ If BACKUP_PHASE_FINISH is implemented, the code should be adjusted
672+ to allow for multiple backups to be run in parallel from different
673+ THD, given that only one backup may run in a phase other than
674+ BACKUP_PHASE_FINISH, but any number may run in BACKUP_PHASE_FINISH.
675+ A possible solution would be to have s eparate Ariab_backup object
676+ per THD. */
677+ if (phase == BACKUP_PHASE_NO_COMMIT || phase == BACKUP_PHASE_ABORT )
667678 aria_backup.reset ();
668679 return 0 ;
669680}
0 commit comments