xtrabackup: Error: write to stdout

Bug #711207 reported by Alexey Kopytov
34
This bug affects 8 people
Affects Status Importance Assigned to Milestone
Percona XtraBackup moved to https://jira.percona.com/projects/PXB
Fix Released
High
Sergei Glushchenko
1.6
Fix Released
High
Sergei Glushchenko
2.0
Fix Released
High
Sergei Glushchenko

Bug Description

I see the following xtrabackup failure quite frequently:

write: 61952 > 34304
xtrabackup: Error: write to stdout
xtrabackup: Error: xtrabackup_copy_logfile() failed.

The error is produced by the following code on xtrabackup.c

--- cut --
   if (stdout_write_size) {
    ret = write(fileno(stdout), log_sys->buf, stdout_write_size);
    if (ret == stdout_write_size) {
     success = TRUE;
    } else {
     fprintf(stderr, "write: %lu > %lu\n", stdout_write_size, ret);
     success = FALSE;
    }
   }
--- cut ---

I think we should not report an error unless the return code from write() is -1. Instead, we should decrease the number of bytes to be written and advance the pointer accordingly and then retry writing.

Related branches

Stewart Smith (stewart)
Changed in percona-xtrabackup:
status: New → Confirmed
Stewart Smith (stewart)
tags: added: low-hanging-fruit
Stewart Smith (stewart)
Changed in percona-xtrabackup:
importance: Undecided → High
status: Confirmed → Triaged
Revision history for this message
Hui Liu (hickey) wrote :

suggested fixing:

        int ret =0;
        int written = 0;
        while (1) {
                ret = write(fileno(stdout), buf+written, stdout_write_size);
                written += ret;
                if (ret == -1) {
                        fprintf(stderr, "write: %lu > %lu\n", stdout_write_size, written+1);
                        fprintf(stderr, "error: %s", strerror(errno));
                        success = FALSE;
                        break;
                } else if (written == stdout_write_size) {
                        success = TRUE;
                        break;
                }
        }

Revision history for this message
Alexey Kopytov (akopytov) wrote :

This is not a duplicate of bug #514068.

Revision history for this message
Shahriyar Rzayev (rzayev-sehriyar) wrote :

Percona now uses JIRA for bug reports so this bug report is migrated to: https://jira.percona.com/browse/PXB-297

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.