Skip to content

Commit

Permalink
fix: fixed topological restoration for inserts restorer
Browse files Browse the repository at this point in the history
  • Loading branch information
wwoytenko committed Aug 16, 2024
1 parent 950360a commit 143cc4d
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 5 deletions.
6 changes: 1 addition & 5 deletions internal/db/postgres/cmd/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,8 @@ func (r *Restore) Run(ctx context.Context) error {
}

func (r *Restore) putDumpId(task restorers.RestoreTask) {
tableTask, ok := task.(*restorers.TableRestorer)
if !ok {
return
}
r.mx.Lock()
r.restoredDumpIds[tableTask.Entry.DumpId] = true
r.restoredDumpIds[task.GetEntry().DumpId] = true
r.mx.Unlock()
}

Expand Down
4 changes: 4 additions & 0 deletions internal/db/postgres/restorers/blobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ func (td *BlobsRestorer) execute(ctx context.Context, tx pgx.Tx) error {
return nil
}

func (td *BlobsRestorer) GetEntry() *toc.Entry {
return td.Entry
}

func (td *BlobsRestorer) DebugInfo() string {
return fmt.Sprintf("blobs %s", *td.Entry.Tag)
}
2 changes: 2 additions & 0 deletions internal/db/postgres/restorers/restorer.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ package restorers
import (
"context"

"github.com/greenmaskio/greenmask/internal/db/postgres/toc"
"github.com/jackc/pgx/v5"
)

type RestoreTask interface {
Execute(ctx context.Context, conn *pgx.Conn) error
DebugInfo() string
GetEntry() *toc.Entry
}
4 changes: 4 additions & 0 deletions internal/db/postgres/restorers/sequence.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ func NewSequenceRestorer(entry *toc.Entry) *SequenceRestorer {
}
}

func (td *SequenceRestorer) GetEntry() *toc.Entry {
return td.Entry
}

func (td *SequenceRestorer) Execute(ctx context.Context, conn *pgx.Conn) error {
tx, err := conn.Begin(ctx)
if err != nil {
Expand Down
4 changes: 4 additions & 0 deletions internal/db/postgres/restorers/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ func NewTableRestorer(entry *toc.Entry, st storages.Storager, exitOnError bool)
}
}

func (td *TableRestorer) GetEntry() *toc.Entry {
return td.Entry
}

func (td *TableRestorer) Execute(ctx context.Context, conn *pgx.Conn) error {
// TODO: Add tests

Expand Down
4 changes: 4 additions & 0 deletions internal/db/postgres/restorers/table_insert_format.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ func NewTableRestorerInsertFormat(
}
}

func (td *TableRestorerInsertFormat) GetEntry() *toc.Entry {
return td.Entry
}

func (td *TableRestorerInsertFormat) Execute(ctx context.Context, conn *pgx.Conn) error {

if td.Entry.FileName == nil {
Expand Down

0 comments on commit 143cc4d

Please sign in to comment.