Bug #40807 Validity point corrupt on restore on powermac platform
Submitted: 18 Nov 2008 1:33 Modified: 4 Feb 2009 22:08
Reporter: Chuck Bell Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server: Backup Severity:S3 (Non-critical)
Version:6.0.9 OS:MacOS (Powermacg5)
Assigned to: Chuck Bell CPU Architecture:Any

[18 Nov 2008 1:33] Chuck Bell
Description:
The validity point read from the backup stream is not calculated correctly on the powermacg5 platform. 

The backup.backup test checks the validity point during restore by querying the backup logs. Additional statements show the vailidity point is being incorrectly translated to UTC on the powermacg5 platform.

+SELECT * FROM mysql.backup_history where backup_id = @bid;;
+backup_id      271
+process_id     0
+binlog_pos     3046
+binlog_file    master-bin.000001
+backup_state   complete
+operation      restore
+error_num      0
+num_objects    4
+total_bytes    4205
+validity_point_time    1930-04-29 20:37:59
+start_time     2008-11-18 01:29:30
+stop_time      2008-11-18 01:29:30
+host_or_server_name    localhost
+username       root
+backup_file    test.ba
+backup_file_path       /Users/mysqldev/cbell/mysql-6.0.9-alpha-pb111/mysql-test
/var/master-data/
+user_comment
+command        RESTORE FROM 'test.ba'
+drivers        MyISAM, Nodata
+select @vp_time;
+@vp_time
+2008-11-18 01:29:27

How to repeat:
./mysql-test-run.pl backup

Suggested fix:
Correct code in sql/backup/image_info.h:

time_t Image_info::get_vp_time() const
{
  struct tm time;

  bzero(&time,sizeof(time));

  time.tm_year= vp_time.year;
  time.tm_mon= vp_time.mon;
  time.tm_mday= vp_time.mday;
  time.tm_hour= vp_time.hour;
  time.tm_min= vp_time.min;
  time.tm_sec= vp_time.sec;  

  /*
    Note: mktime() assumes that time is expressed as local time and vp_time is
    in UTC. Hence we must correct the result to get it right.
   */ 
  return mktime(&time) - (time_t)timezone;
}

This method is returning the incorrect gmt value.
[18 Nov 2008 2:41] Chuck Bell
Test failure can be seen in mysql-6.0-falcon tree.
[18 Nov 2008 10:10] John Embretsen
Test case failure was already filed as Bug#40759 - "backup.backup test fails with wrong validity_point_time on powermacg5".
[19 Nov 2008 10:33] Sveta Smirnova
Thank you for the report.

Verified as described in both main and falcon trees with failures like in pushbuild.
[5 Dec 2008 10:02] Øystein Grøvlen
I see that in disabled.def, Hakan blames the failure on big-endian architectures.  However, I have not been able to reproduce this on Solaris Sparc.
[23 Dec 2008 12:22] Øystein Grøvlen
I have run the backup test 100 times on powermac both with and without the Ingo's fix to Bug#40808, and I have not been able to make it fail.  I suggest we reenable the test and see what happens.
[23 Dec 2008 12:51] Øystein Grøvlen
Note that I observe, as reported by Chuck, that the vp_time is wrong.  Hence, this is still a valid bug.  I will handling the enabling of the backup test in Bug#40759 instead.

I will revisit this bug after I have fixed Bug#37146 which deals with timestamps and time zones in general.
[22 Jan 2009 22:12] Chuck Bell
Observation:

The error is simply because the 'timezone' variable does not exist on powermac in the same form as other platforms. Apple has a method timegm() that does what 'mktime() - timezone' does on other platforms.

I think part of the problem is the mixing of time structures (e.g. time_t, tm, backup-specific time structures) and/or possibly the incorrect assumptions regarding UTC and timezone conversion.

Still investigating a platform independent solution.
[4 Feb 2009 22:08] Chuck Bell
I have tested this with a (much) newer build on the PowerMacG5 platform (see /cbell/mysql-6.0.9-alpha-pb144) and the problem does not reappear. It seems to be fixed now. Cannot repeat and recommend closing bug report.