Bug #43324 Wrong table count per snapshot stored in backup image
Submitted: 3 Mar 2009 8:45 Modified: 26 Apr 2009 0:04
Reporter: Rafal Somla Email Updates:
Status: Closed Impact on me:
Category:MySQL Server: Backup Severity:S3 (Non-critical)
Version:6.0 OS:Any
Assigned to: Chuck Bell
Triage: Triaged: D2 (Serious)

[3 Mar 2009 8:45] Rafal Somla
Backup image stores descriptions of "table data snapshots" contained in it, and for each snapshot the number of tables belonging to it. But this number is not correctly stored and always equals 1.

How to repeat:
Run the following test script:
let $bdir=`select @@backupdir`;
USE db1;

CREATE TABLE t1 (a int);
CREATE TABLE t2 (a int);
CREATE TABLE t3 (a int);

BACKUP DATABASE db1 TO 'db1.bkp';
--exec $MYSQL_BACKUP --snapshots $bdir/db1.bkp


and wath the output of mysqlbackup utility:
Image version:       1
Creation time:       2009-03-03 08:37:01 UTC
Server version:      6.0.11 (6.0.11-alpha)
Server byte order:   little-endian
Server charset:      'utf8'
Snapshot count:      1


  Snapshot 0 type    native from 'MyISAM'  version 1.0
  Snapshot 0 version 1
  Snapshot 0 tables  1           <---- this is wrong, should be 3
  Snapshot 0 table   'db1'.'t1'
  Snapshot 0 table   'db1'.'t2'
  Snapshot 0 table   'db1'.'t3'
[3 Mar 2009 17:01] Chuck Bell
Is this a problem in the backup code or the mysqlbackup utility? Please specify and provide any ideas/suggestions for fixes.
[4 Mar 2009 6:36] Rafal Somla
This is not a problem in mysqlbackup utility, but the number stored in the image is wrong.

I think the developer who gets assigned to this bug will investigate it and then can suggest a solution. I have no ideas right now. I would start looking at methods Logger::report_stats_{pre,post} in logger.c and how they are called from kernel.cc.
[14 Apr 2009 21:09] Chuck Bell
The problem is here:

  Return number of entries in the dynamic array.
  @note Some of the entries can store NULL pointers as no mapping was
  defined for them.
template<class T>
ulong Map<uint,T>::count() const
{ return Base::array.elements; }

elements is always 1.
[14 Apr 2009 22:13] Chuck Bell
Have solution. Checking with reviewer for design approval.
[15 Apr 2009 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:


2797 Chuck Bell	2009-04-15
      BUG#43324 : Wrong table count per snapshot stored in backup image
      The wrong table count is being written to the stream.
      When the backup client reads the stream it produces the
      wrong output. The table count always returned 1.
      This is because the code was counting the tables in the
      add_snapshot() method which is only called once.
      This patch moves the table counting code to allow proper
      counting of the tables in the snapshot.
      As a result, the backup client test results have been
      corrected as well.
[16 Apr 2009 5:14] Rafal Somla
Good to push.
[16 Apr 2009 19:01] Ingo Strüwing
Approved. No comments.
[23 Apr 2009 7:18] 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 2009 0:04] Paul Dubois
Noted in 6.0.11 changelog.

BACKUP DATABASE stored incorrect table counts in the backup image.