Skip to content
This repository was archived by the owner on Dec 16, 2022. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docker/base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ FROM vitess/bootstrap:mysql57
# Allows some docker builds to disable CGO
ARG CGO_ENABLED=0

# Allows docker builds to set the BUILD_NUMBER
ARG BUILD_NUMBER

# Re-copy sources from working tree
USER root
COPY . /vt/src/vitess.io/vitess
Expand Down
6 changes: 6 additions & 0 deletions docker/base/Dockerfile.mariadb
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
FROM vitess/bootstrap:mariadb

# Allows some docker builds to disable CGO
ARG CGO_ENABLED=0

# Allows docker builds to set the BUILD_NUMBER
ARG BUILD_NUMBER

# Re-copy sources from working tree
USER root
COPY . /vt/src/vitess.io/vitess
Expand Down
6 changes: 6 additions & 0 deletions docker/base/Dockerfile.mariadb103
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
FROM vitess/bootstrap:mariadb103

# Allows some docker builds to disable CGO
ARG CGO_ENABLED=0

# Allows docker builds to set the BUILD_NUMBER
ARG BUILD_NUMBER

# Re-copy sources from working tree
USER root
COPY . /vt/src/vitess.io/vitess
Expand Down
6 changes: 6 additions & 0 deletions docker/base/Dockerfile.mysql56
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
FROM vitess/bootstrap:mysql56

# Allows some docker builds to disable CGO
ARG CGO_ENABLED=0

# Allows docker builds to set the BUILD_NUMBER
ARG BUILD_NUMBER

# Re-copy sources from working tree
USER root
COPY . /vt/src/vitess.io/vitess
Expand Down
6 changes: 6 additions & 0 deletions docker/base/Dockerfile.mysql80
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
FROM vitess/bootstrap:mysql80

# Allows some docker builds to disable CGO
ARG CGO_ENABLED=0

# Allows docker builds to set the BUILD_NUMBER
ARG BUILD_NUMBER

# Re-copy sources from working tree
USER root
COPY . /vt/src/vitess.io/vitess
Expand Down
6 changes: 6 additions & 0 deletions docker/base/Dockerfile.percona
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
FROM vitess/bootstrap:percona

# Allows some docker builds to disable CGO
ARG CGO_ENABLED=0

# Allows docker builds to set the BUILD_NUMBER
ARG BUILD_NUMBER

# Re-copy sources from working tree
USER root
COPY . /vt/src/vitess.io/vitess
Expand Down
6 changes: 6 additions & 0 deletions docker/base/Dockerfile.percona57
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
FROM vitess/bootstrap:percona57

# Allows some docker builds to disable CGO
ARG CGO_ENABLED=0

# Allows docker builds to set the BUILD_NUMBER
ARG BUILD_NUMBER

# Re-copy sources from working tree
USER root
COPY . /vt/src/vitess.io/vitess
Expand Down
6 changes: 6 additions & 0 deletions docker/base/Dockerfile.percona80
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
FROM vitess/bootstrap:percona80

# Allows some docker builds to disable CGO
ARG CGO_ENABLED=0

# Allows docker builds to set the BUILD_NUMBER
ARG BUILD_NUMBER

# Re-copy sources from working tree
USER root
COPY . /vt/src/vitess.io/vitess
Expand Down
3 changes: 3 additions & 0 deletions docker/lite/Dockerfile.alpine
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ FROM vitess/bootstrap:mariadb103 AS builder
# Allows some docker builds to disable CGO
ARG CGO_ENABLED=0

# Allows docker builds to set the BUILD_NUMBER
ARG BUILD_NUMBER

# Re-copy sources from working tree.
COPY --chown=vitess:vitess . /vt/src/vitess.io/vitess

Expand Down
3 changes: 3 additions & 0 deletions docker/lite/Dockerfile.mariadb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ FROM vitess/bootstrap:mariadb AS builder
# Allows some docker builds to disable CGO
ARG CGO_ENABLED=0

# Allows docker builds to set the BUILD_NUMBER
ARG BUILD_NUMBER

# Re-copy sources from working tree.
COPY --chown=vitess:vitess . /vt/src/vitess.io/vitess

Expand Down
3 changes: 3 additions & 0 deletions docker/lite/Dockerfile.mariadb103
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ FROM vitess/bootstrap:mariadb103 AS builder
# Allows some docker builds to disable CGO
ARG CGO_ENABLED=0

# Allows docker builds to set the BUILD_NUMBER
ARG BUILD_NUMBER

# Re-copy sources from working tree.
COPY --chown=vitess:vitess . /vt/src/vitess.io/vitess

Expand Down
3 changes: 3 additions & 0 deletions docker/lite/Dockerfile.mysql56
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ FROM vitess/bootstrap:mysql56 AS builder
# Allows some docker builds to disable CGO
ARG CGO_ENABLED=0

# Allows docker builds to set the BUILD_NUMBER
ARG BUILD_NUMBER

# Re-copy sources from working tree.
COPY --chown=vitess:vitess . /vt/src/vitess.io/vitess

Expand Down
3 changes: 3 additions & 0 deletions docker/lite/Dockerfile.mysql57
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ FROM vitess/bootstrap:mysql57 AS builder
# Allows some docker builds to disable CGO
ARG CGO_ENABLED=0

# Allows docker builds to set the BUILD_NUMBER
ARG BUILD_NUMBER

# Re-copy sources from working tree.
COPY --chown=vitess:vitess . /vt/src/vitess.io/vitess

Expand Down
3 changes: 3 additions & 0 deletions docker/lite/Dockerfile.mysql80
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ FROM vitess/bootstrap:mysql80 AS builder
# Allows some docker builds to disable CGO
ARG CGO_ENABLED=0

# Allows docker builds to set the BUILD_NUMBER
ARG BUILD_NUMBER

# Re-copy sources from working tree.
COPY --chown=vitess:vitess . /vt/src/vitess.io/vitess

Expand Down
3 changes: 3 additions & 0 deletions docker/lite/Dockerfile.percona
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ FROM vitess/bootstrap:percona AS builder
# Allows some docker builds to disable CGO
ARG CGO_ENABLED=0

# Allows docker builds to set the BUILD_NUMBER
ARG BUILD_NUMBER

# Re-copy sources from working tree.
COPY --chown=vitess:vitess . /vt/src/vitess.io/vitess

Expand Down
3 changes: 3 additions & 0 deletions docker/lite/Dockerfile.percona57
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ FROM vitess/bootstrap:percona57 AS builder
# Allows some docker builds to disable CGO
ARG CGO_ENABLED=0

# Allows docker builds to set the BUILD_NUMBER
ARG BUILD_NUMBER

# Re-copy sources from working tree.
COPY --chown=vitess:vitess . /vt/src/vitess.io/vitess

Expand Down
3 changes: 3 additions & 0 deletions docker/lite/Dockerfile.percona80
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ FROM vitess/bootstrap:percona80 AS builder
# Allows some docker builds to disable CGO
ARG CGO_ENABLED=0

# Allows docker builds to set the BUILD_NUMBER
ARG BUILD_NUMBER

# Re-copy sources from working tree.
COPY --chown=vitess:vitess . /vt/src/vitess.io/vitess

Expand Down
7 changes: 4 additions & 3 deletions go/sqltypes/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,14 @@ func ResultsEqual(r1, r2 []Result) bool {
// Every place this function is called, a comment is needed that explains
// why it's justified.
func MakeRowTrusted(fields []*querypb.Field, row *querypb.Row) []Value {
sqlRow := make([]Value, len(row.Lengths))
sqlRow := make([]Value, len(fields))
var offset int64
for i, length := range row.Lengths {
for i, fld := range fields {
length := row.Lengths[i]
if length < 0 {
continue
}
sqlRow[i] = MakeTrusted(fields[i].Type, row.Values[offset:offset+length])
sqlRow[i] = MakeTrusted(fld.Type, row.Values[offset:offset+length])
offset += length
}
return sqlRow
Expand Down
55 changes: 55 additions & 0 deletions go/sqltypes/result_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,61 @@ import (
querypb "vitess.io/vitess/go/vt/proto/query"
)

func TestMakeRowTrusted(t *testing.T) {
fields := MakeTestFields(
"some_int|some_text|another_int",
"int8|varchar|int8",
)

values := []byte{}
hw := []byte("hello, world")
values = append(values, hw...)
values = append(values, byte(42))

row := &querypb.Row{
Lengths: []int64{-1, int64(len(hw)), 1},
Values: values,
}

want := []Value{
MakeTrusted(querypb.Type_NULL_TYPE, nil),
MakeTrusted(querypb.Type_VARCHAR, []byte("hello, world")),
MakeTrusted(querypb.Type_INT8, []byte{byte(42)}),
}

result := MakeRowTrusted(fields, row)
if !reflect.DeepEqual(result, want) {
t.Errorf("MakeRowTrusted:\ngot: %#v\nwant: %#v", result, want)
}
}

func TestMakeRowTrustedDoesNotPanicOnNewColumns(t *testing.T) {
fields := MakeTestFields(
"some_int|some_text",
"int8|varchar",
)

values := []byte{byte(123)}
hw := []byte("hello, world")
values = append(values, hw...)
values = append(values, byte(42))

row := &querypb.Row{
Lengths: []int64{1, int64(len(hw)), 1},
Values: values,
}

want := []Value{
MakeTrusted(querypb.Type_INT8, []byte{byte(123)}),
MakeTrusted(querypb.Type_VARCHAR, []byte("hello, world")),
}

result := MakeRowTrusted(fields, row)
if !reflect.DeepEqual(result, want) {
t.Errorf("MakeRowTrusted:\ngot: %#v\nwant: %#v", result, want)
}
}

func TestRepair(t *testing.T) {
fields := []*querypb.Field{{
Type: Int64,
Expand Down
19 changes: 17 additions & 2 deletions go/vt/mysqlctl/azblobbackupstorage/azblob.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,21 @@ func (bh *AZBlobBackupHandle) Name() string {
return bh.name
}

// RecordError is part of the concurrency.ErrorRecorder interface.
func (bh *AZBlobBackupHandle) RecordError(err error) {
bh.errors.RecordError(err)
}

// HasErrors is part of the concurrency.ErrorRecorder interface.
func (bh *AZBlobBackupHandle) HasErrors() bool {
return bh.errors.HasErrors()
}

// Error is part of the concurrency.ErrorRecorder interface.
func (bh *AZBlobBackupHandle) Error() error {
return bh.errors.Error()
}

// AddFile implements BackupHandle.
func (bh *AZBlobBackupHandle) AddFile(ctx context.Context, filename string, filesize int64) (io.WriteCloser, error) {
if bh.readOnly {
Expand Down Expand Up @@ -156,7 +171,7 @@ func (bh *AZBlobBackupHandle) AddFile(ctx context.Context, filename string, file
})
if err != nil {
reader.CloseWithError(err)
bh.errors.RecordError(err)
bh.RecordError(err)
}
}()

Expand All @@ -169,7 +184,7 @@ func (bh *AZBlobBackupHandle) EndBackup(ctx context.Context) error {
return fmt.Errorf("EndBackup cannot be called on read-only backup")
}
bh.waitGroup.Wait()
return bh.errors.Error()
return bh.Error()
}

// AbortBackup implements BackupHandle.
Expand Down
5 changes: 5 additions & 0 deletions go/vt/mysqlctl/backupstorage/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"io"

"golang.org/x/net/context"
"vitess.io/vitess/go/vt/concurrency"
)

var (
Expand Down Expand Up @@ -74,6 +75,10 @@ type BackupHandle interface {
// The context is valid for the duration of the reads, until the
// ReadCloser is closed.
ReadFile(ctx context.Context, filename string) (io.ReadCloser, error)

// concurrency.ErrorRecorder is embedded here to coordinate reporting and
// handling of errors among all the components involved in taking a backup.
concurrency.ErrorRecorder
}

// BackupStorage is the interface to the storage system
Expand Down
18 changes: 13 additions & 5 deletions go/vt/mysqlctl/builtinbackupengine.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,6 @@ func (be *BuiltinBackupEngine) backupFiles(ctx context.Context, params BackupPar

// Backup with the provided concurrency.
sema := sync2.NewSemaphore(params.Concurrency, 0)
rec := concurrency.AllErrorRecorder{}
wg := sync.WaitGroup{}
for i := range fes {
wg.Add(1)
Expand All @@ -287,19 +286,28 @@ func (be *BuiltinBackupEngine) backupFiles(ctx context.Context, params BackupPar
// encountered an error.
sema.Acquire()
defer sema.Release()
if rec.HasErrors() {
if bh.HasErrors() {
return
}

// Backup the individual file.
name := fmt.Sprintf("%v", i)
rec.RecordError(be.backupFile(ctx, params, bh, &fes[i], name))
bh.RecordError(be.backupFile(ctx, params, bh, &fes[i], name))
}(i)
}

wg.Wait()
if rec.HasErrors() {
return rec.Error()

// BackupHandle supports the ErrorRecorder interface for tracking errors
// across any goroutines that fan out to take the backup. This means that we
// don't need a local error recorder and can put everything through the bh.
//
// This handles the scenario where bh.AddFile() encounters an error asynchronously,
// which ordinarily would be lost in the context of `be.backupFile`, i.e. if an
// error were encountered
// [here](https://github.com/vitessio/vitess/blob/d26b6c7975b12a87364e471e2e2dfa4e253c2a5b/go/vt/mysqlctl/s3backupstorage/s3.go#L139-L142).
if bh.HasErrors() {
return bh.Error()
}

// open the MANIFEST
Expand Down
Loading