~gl-az/percona-xtrabackup/2.0-ST31441-suspend-debugging

« back to all changes in this revision

Viewing changes to src/xtrabackup.cc

  • Committer: George Lorch
  • Date: 2013-07-17 17:04:46 UTC
  • Revision ID: gl_az@yahoo.com-20130717170446-wr7b6c7ixbrw3e1g
Added extra logging to xtrabackup.cc surrpunding the suspend file and changed suspend file contents to include the current pid. Added suspend file validation in innobackupex to ensure that the pid read from the suspend file matches the known pid of the xtrabackup process to help identify mixed/crossed running backup instances.

Show diffs side-by-side

added added

removed removed

Lines of Context:
5168
5168
xb_create_suspend_file(const char *path)
5169
5169
{
5170
5170
        ibool                   success;
5171
 
        os_file_t               suspend_file = XB_FILE_UNDEFINED;
5172
 
 
5173
 
        /* xb_file_create reads srv_unix_file_flush_method */
5174
 
        suspend_file = xb_file_create(path, OS_FILE_CREATE,
5175
 
                                      OS_FILE_NORMAL, OS_DATA_FILE,
5176
 
                                      &success);
5177
 
 
5178
 
        if (success && suspend_file != XB_FILE_UNDEFINED) {
5179
 
 
5180
 
                os_file_close(suspend_file);
 
5171
        FILE                    *suspend_file;
 
5172
        ibool                   exists;
 
5173
        os_file_type_t          type;
 
5174
        pid_t                   pid;
 
5175
 
 
5176
        pid = getpid();
 
5177
 
 
5178
        success = os_file_status(path, &exists, &type);
 
5179
        /* success == FALSE if file exists, but stat() failed.
 
5180
        os_file_status() prints an error message in this case */
 
5181
        ut_a(success);
 
5182
 
 
5183
        if (exists) {
 
5184
                msg("xtrabackup: Error: Suspend file '%s' already exists!\n", path);
 
5185
 
 
5186
                return(FALSE);
 
5187
        }
 
5188
 
 
5189
        msg("xtrabackup: Creating suspend file '%s' with pid '%u'\n", path, pid);
 
5190
        
 
5191
        suspend_file = fopen(path, "w");
 
5192
        if (suspend_file) {
 
5193
                fprintf(suspend_file, "%u", pid); 
 
5194
 
 
5195
                fclose(suspend_file);
5181
5196
 
5182
5197
                return(TRUE);
5183
5198
        }