Skip to content

Commit

Permalink
re-use transaction when deleting dataset
Browse files Browse the repository at this point in the history
  • Loading branch information
ohaibbq committed Apr 12, 2024
1 parent bc3e29e commit 5dc4e1d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions internal/metadata/repository.go
Expand Up @@ -778,6 +778,10 @@ func (r *Repository) FindTablesInDatasets(ctx context.Context, projectID, datase
return nil, err
}
defer tx.Commit()
return r.FindTablesInDatasetsWithConnection(ctx, tx, projectID, datasetID)
}

func (r *Repository) FindTablesInDatasetsWithConnection(ctx context.Context, tx *sql.Tx, projectID, datasetID string) ([]*Table, error) {
tablesByDataset, err := r.findTablesInDatasets(ctx, tx, projectID, []string{datasetID})
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion server/handler.go
Expand Up @@ -649,7 +649,7 @@ func (h *datasetsDeleteHandler) Handle(ctx context.Context, r *datasetsDeleteReq
return fmt.Errorf("failed to delete dataset: %w", err)
}
if r.deleteContents {
tables, err := r.dataset.Tables(ctx)
tables, err := r.server.metaRepo.FindTablesInDatasetsWithConnection(ctx, tx.Tx(), r.dataset.ProjectID, r.dataset.ID)
if err != nil {
return fmt.Errorf("failed to find tables in dataset: %w", err)
}
Expand Down

0 comments on commit 5dc4e1d

Please sign in to comment.