Bug #34721 Backup driver can't refuse to provide driver
Submitted: 21 Feb 2008 12:45 Modified: 21 Aug 2008 20:22
Reporter: Lars Thalmann
Status: Closed
Category:Server: Backup Severity:S3 (Non-critical)
Version:6.0 source OS:Any
Assigned to: Rafal Somla Target Version:6.0-rc
Triage: D2 (Serious)

[21 Feb 2008 12:45] Lars Thalmann
Description:
Current code checks if there is a method or not.
This makes it impossible for a storage engine that
implements the backup API to say that "no, I don't have a driver" 
and "yes, I do have a driver" dependent on its internal state.

How to repeat:
Review code.

Suggested fix:
Make it so that even though the handler has a get_backup_engine
method, it can still reply "no" and then the blocking driver should
be used.
[26 Feb 2008 14:26] Rafal Somla
REFINED PROBLEM DESCRIPTION
---------------------------

To check if a storage engine provides native backup engine for its tables, backup kernel
looks at handler::get_backup_engine pointer. If it is not NULL, then it points at
function which returns instance of Backup_engine class.

The pointer is checked each time a backup/restore operation is performed. Therefore, in
case of plugin architecture, it is possible to inform backup kernel if a plugin
containing backup engine is loaded or not. When the plugin is loaded,
handler::get_backup_engine can be set up correctly and when it is unloaded, the pointer
can be set to NULL.

There is another possibility. Member handler::get_backup_engine can always point to a
factory function which detects whether backup engine plugin is loaded or not. If it is
not loaded, or backup engine is not available for other reasons, the factory function can
return ERROR value and kernel will be notified about that fact.

Even if backup engine instance is successfully created, it is still possible that it
refuses to create a backup or restore driver. This happens inside
Backup_engine::get_backup() or Backup_engine::get_restore() method. If the driver can not
be created for some reason, that method can return ERROR.

However, there is the following problem. If backup kernel gets ERROR when creating a
backup/restore driver it will abort the operation. But, instead, it should try to use
other available backup engines such as the CS or the default one.

Thus the backup kernel should be modified so that if one of the native backup engines
refuses to create a backup/restore driver, it should try the built-in engines instead of
aborting the operation with an error.
[25 Mar 2008 15:23] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/44396

ChangeSet@1.2606, 2008-03-25 15:22:11+01:00, rafal@quant.(none) +2 -0
  BUG#34721 (Backup driver can't refuse to provide driver):
  
  This patch modifies backup kernel so that it falls back to built in backup 
  engines in case a native backup engine can not be created. 
  
  This is for the special case when storage engine defines a get_backup_engine() 
  factory function (inside the handlerton), but that function fails to create a 
  backup engine instance. Previous code haven't dealt correctly with that case. 
  Now it puts a warning and tries the built-in engines.
[31 Mar 2008 13:29] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/44675

ChangeSet@1.2606, 2008-03-31 13:28:32+02:00, rafal@quant.(none) +6 -0
  BUG#34721 (Backup driver can't refuse to provide driver):
  
  This patch modifies backup kernel so that it falls back to built in backup 
  engines in case a native backup engine can not be created. 
  
  This is for the special case when storage engine defines a get_backup_engine() 
  factory function (inside the handlerton), but that function fails to create a 
  backup engine instance. Previous code haven't dealt correctly with that case. 
  Now it puts a warning and tries the built-in engines.
[1 Apr 2008 3:39] Chuck Bell
Patch approved.
[9 Apr 2008 16:25] Ingo Strüwing
Approved with some change requests. Please see email.
[10 Apr 2008 12:06] Rafal Somla
Updating the patch to implement review comments.
[15 Apr 2008 12:32] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/45419

ChangeSet@1.2606, 2008-04-15 12:29:25+02:00, rafal@quant.(none) +5 -0
  BUG#34721 (Backup driver can't refuse to provide driver):
  
  This patch modifies backup kernel so that it falls back to built in backup 
  engines in case a native backup engine can not be created. 
  
  If storage engine defines a get_backup_engine() factory function (inside the 
  handlerton), but that function fails to create a backup engine then the current 
  code interrupts backup/restore operation and reports error. This is not the 
  expected behaviour. This patch fixes the backup engine selection logic so that 
  in the above case it puts warning and continues using the built-in engines.
[16 Apr 2008 11:37] Ingo Strüwing
Hi Rafal, I approve the patch, but please think about my comments from my yesterday's
email. Regards Ingo
[16 Apr 2008 20:25] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/45514

ChangeSet@1.2606, 2008-04-16 20:23:05+02:00, rafal@quant.(none) +5 -0
  BUG#34721 (Backup driver can't refuse to provide driver):
  
  The problem was that a storage engine could not refuse to create a native backup 
  engine without stopping the whole backup process with an error. The intended 
  behaviour is to use a built-in backup engine for that storage engine is such 
  case.
  
  This patch modifies the backup kernel so that it falls back to the
  built-in backup engines in case a native backup engine can not be created.
  
  In detail each storage engine defines a get_backup_engine() factory
  function (inside the handlerton). If that function fails to create a
  backup engine then the backup engine selection logic does now push a
  warning and continues using a built-in backup engine for this storage
  engine.
[23 Apr 2008 8:54] Rafal Somla
Pushed into mysql-6.0-backup tree.
[20 Aug 2008 15:34] Chuck Bell
Pushed to 6.0.0.
[21 Aug 2008 20:22] Paul DuBois
Pushed to 6.0.5, the same release when BACKUP DATABASE/RESTORE originally appeared. So
this bug is not in any released version; no changelog entry needed.
[14 Sep 2008 1:32] Bugs System
Pushed into 6.0.7-alpha  (revid:sp1r-rafal@quant.(none)-20080416182305-07742) (version
source revid:john.embretsen@sun.com-20080808091208-ht48kyzsk7rim74g) (pib:3)