first binlog header only necessary when startPosition != 0

This commit is contained in:
Shlomi Noach 2017-01-01 15:03:54 +02:00
Родитель 4837c76cae
Коммит 12f090ed2e
1 изменённых файлов: 2 добавлений и 2 удалений

Просмотреть файл

@ -156,7 +156,7 @@ func MySQLBinlogBinaryContents(binlogFiles []string, startPosition int64, stopPo
// We need both from the first log file.
// Typically, the format description ends at pos 120, but let's verify...
cmd := fmt.Sprintf("mysqlbinlog %s --start-position=4 | head | egrep -o 'end_log_pos [^ ]+' | awk '{print $2}' > %s", binlogFiles[0], binlogHeaderTmpFile.Name())
cmd := fmt.Sprintf("mysqlbinlog %s --start-position=4 | head | egrep -o 'end_log_pos [^ ]+' | head -1 | awk '{print $2}' > %s", binlogFiles[0], binlogHeaderTmpFile.Name())
if _, err := commandOutput(sudoCmd(cmd)); err != nil {
return "", err
}
@ -165,7 +165,7 @@ func MySQLBinlogBinaryContents(binlogFiles []string, startPosition int64, stopPo
if err != nil {
return "", log.Errore(err)
}
{
if startPosition != 0 {
cmd := fmt.Sprintf("cat %s | head -c$(cat %s) >> %s", binlogFiles[0], binlogHeaderTmpFile.Name(), tmpFile.Name())
if _, err := commandOutput(sudoCmd(cmd)); err != nil {
return "", err