Bug #35079 It is not possible to interrupt long BACKUP or RESTORE operation
Submitted: 5 Mar 2008 13:58 Modified: 26 Apr 1:46
Reporter: Rafal Somla
Status: Closed
Category:Server: Backup Severity:S3 (Non-critical)
Version:6.0-backup OS:Any
Assigned to: Rafal Somla Target Version:
Triage: Triaged: D3 (Medium)

[5 Mar 2008 13:58] Rafal Somla
Description:
It is not possible to interrupt a long running BACKUP or RESTORE operation. Also shuting
down the server does not help because server waits for all active threads to terminate
before it quits.

How to repeat:
Backup or restore a big database. Try hitting Ctrl-C while BACKUP or RESTORE command is
running.

Suggested fix:
Fix backup kernel code so that it checks thd->killed flag and interrupts operation if the
thread has been killed.
[25 Apr 2008 15:40] Rafal Somla
BUG#34181 marked as duplicate of this one.
[28 Apr 2008 12:36] Rafal Somla
PROPOSED SOLUTION.

Change in backup behaviour.

The main loop polling backup drivers and writing image data into backup stream is is
executed inside write_table_data() in data_backup.cc. An instance of Scheduler class is
used for that purpose, with its step() method which is called in the loop until end of
backup process is detected.

The Scheduler::step() method will be modified to check for thd->killed flag. If thread
termination is detected, an error will be reported, which will cause the whole backup
process to be interrupted. Scheduler::cancel_backup() method will be called to cancel the
ongoing operation and shut down active backup drivers.

Change in restore behaviour.

The main loop reading backup image data and sending it to restore drivers is executed
inside restore_table_data() function in data_backup.cc. That loop will be modified to
check for thd->killed flag and to interrupt the process if thread shutdown is detected.
Appropriate error will be reported to the upper level and in the logs.

The loop should be refactored to call drv->cancel() methods in case restore process is
interrupted by error or when restore thread is killed. This is required by the protocol
but is not implemented now.

Limitation.

Killing of the backup/restore thread will not be detected during the meta-data
save/restore phase. This should be ok since this phase is relatively short compared to
the main table data reading/writing phase.
[2 Sep 2008 12:25] Rafal Somla
This bug will be fixed by WL#4538.
[5 Dec 2008 8:40] 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/60689

2740 Rafal Somla	2008-12-05
      BUG#35079/WL#4538 - Make BACKUP/RESTORE statements interruptible.
      
      The server detects interruptions in statement execution such as when client 
      connection is closed or if user hits Ctrl+C. However, the code inside the server 
      must actively check if an interruption has happened and abort execution in that 
      case.
      
      This patch adds such checks to the backup code, as described in WL#4538. After 
      this patch it should be possible to interrupt on-going BACKUP/RESTORE command. 
      It also fixes few problems in the code so that the new tests can pass through.
[8 Dec 2008 13:15] 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/60888

2740 Rafal Somla	2008-12-08
      BUG#35079/WL#4538 - Make BACKUP/RESTORE statements interruptible.
      
      The server detects interruptions in statement execution such as when client 
      connection is closed or if user hits Ctrl+C. However, the code inside the server 
      must actively check if an interruption has happened and abort execution in that 
      case.
      
      This patch adds such checks to the backup code, as described in WL#4538. After 
      this patch it should be possible to interrupt on-going BACKUP/RESTORE command. 
      It also fixes few problems in the code so that the new tests can pass through.
[12 Dec 2008 16:06] 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/61517

2740 Rafal Somla	2008-12-12
      BUG#35079/WL#4538 - Make BACKUP/RESTORE statements interruptible.
      
      The server detects interruptions in statement execution such as when client 
      connection is closed or if user hits Ctrl+C. However, the code inside the server 
      must actively check if an interruption has happened and abort execution in that 
      case.
      
      This patch adds such checks to the backup code, as described in WL#4538. After 
      this patch it should be possible to interrupt on-going BACKUP/RESTORE command. 
      It also fixes few problems in the code so that the new tests can pass through.
[19 Dec 2008 15:41] Chuck Bell
Patch approved.
[13 Feb 8:55] Rafal Somla
Have problems with failing tests after updating the patch to the current tree.
Investigating the issue.
[19 Feb 15:39] 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/66920

2773 Rafal Somla	2009-02-19
      BUG#35079/WL#4538 - Make BACKUP/RESTORE statements interruptible.
            
      The server detects interruptions in statement execution such as when client 
      connection is closed or if user hits Ctrl+C. However, the code inside the server 
      must actively check if an interruption has happened and abort execution in that 
      case.
            
      This patch adds such checks to the backup code, as described in WL#4538. After 
      this patch it should be possible to interrupt on-going BACKUP/RESTORE command. 
      It also fixes few problems in the code so that the new tests can pass through.
[20 Feb 6:16] Rafal Somla
Need to extend the patch.
[20 Feb 7:53] 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/66984

2774 Rafal Somla	2009-02-20
      BUG#35079/WL#4538 - Make BACKUP/RESTORE statements interruptible.
            
      The server detects interruptions in statement execution such as when client 
      connection is closed or if user hits Ctrl+C. However, the code inside the server 
      must actively check if an interruption has happened and abort execution in that 
      case.
            
      This patch adds such checks to the backup code, as described in WL#4538. After 
      this patch it should be possible to interrupt on-going BACKUP/RESTORE command. 
      It also fixes few problems in the code so that the new tests can pass through.
[9 Mar 14:22] Oystein Grovlen
Patch approved, pending inclusion of missing result files.
[16 Mar 15:39] 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/69303

2802 Rafal Somla	2009-03-16
      BUG#35079/WL#4538 - Make BACKUP/RESTORE statements interruptible.
            
      The server detects interruptions in statement execution such as when client 
      connection is closed or if user hits Ctrl+C. However, the code inside the server 
      must actively check if an interruption has happened and abort execution in that 
      case.
            
      This patch adds such checks to the backup code, as described in WL#4538. After 
      this patch it should be possible to interrupt on-going BACKUP/RESTORE command. 
      It also fixes few problems in the code so that the new tests can pass through.
[16 Mar 16:46] Rafal Somla
Pushed into mysql-6.0-backup tree.
[23 Apr 9:19] Bugs System
Pushed into 6.0.11-alpha (revid:alik@sun.com-20090423070920-e5lq3vrrqi016z2c) (version
source revid:alik@sun.com-20090423070920-e5lq3vrrqi016z2c) (merge vers: 6.0.11-alpha)
(pib:6)
[26 Apr 1:49] Paul DuBois
Noted in 6.0.11 changelog.

It was not possible to interrupt a long running BACKUP DATABASE or
RESTORE operation.