xtrabackup: Error: write to stdout

Reported by Alexey Kopytov on 2011-02-01
34
This bug affects 8 people
Affects Status Importance Assigned to Milestone
Percona XtraBackup
High
Sergei Glushchenko
1.6
High
Sergei Glushchenko
2.0
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.

Stewart Smith (stewart) on 2011-05-18
Changed in percona-xtrabackup:
status: New → Confirmed
Stewart Smith (stewart) on 2011-05-19
tags: added: low-hanging-fruit
Stewart Smith (stewart) on 2011-05-20
Changed in percona-xtrabackup:
importance: Undecided → High
status: Confirmed → Triaged
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;
                }
        }

Alexey Kopytov (akopytov) wrote :

This is not a duplicate of bug #514068.

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

Other bug subscribers