diff --git a/cmd/influx_tools/parquet/command.go b/cmd/influx_tools/parquet/command.go index e9f8f21e837..ba4ee63d986 100644 --- a/cmd/influx_tools/parquet/command.go +++ b/cmd/influx_tools/parquet/command.go @@ -97,7 +97,7 @@ func (cmd *Command) Run(args []string) (err error) { if err := exp.open(ctx); err != nil { return fmt.Errorf("opening exporter failed: %w", err) } - defer internal_errors.Capture(&err, exp.close) + defer internal_errors.Capture(&err, exp.close)() exp.printPlan(cmd.Stderr) diff --git a/cmd/influx_tools/parquet/exporter.go b/cmd/influx_tools/parquet/exporter.go index 5857dfd1673..cf33b2159bc 100644 --- a/cmd/influx_tools/parquet/exporter.go +++ b/cmd/influx_tools/parquet/exporter.go @@ -419,7 +419,6 @@ func (e *exporter) exportMeasurement(ctx context.Context, shard *tsdb.Shard, mea if err != nil { return fmt.Errorf("creating file %q failed: %w", filename, err) } - defer internal_errors.Capture(&err, file.Close) writer, err := pqarrow.NewFileWriter( schema, @@ -428,9 +427,12 @@ func (e *exporter) exportMeasurement(ctx context.Context, shard *tsdb.Shard, mea pqarrow.NewArrowWriterProperties(pqarrow.WithCoerceTimestamps(arrow.Nanosecond)), ) if err != nil { + if err := file.Close(); err != nil { + e.logger.Errorf("closing file failed: %v", err) + } return fmt.Errorf("creating parquet writer for file %q failed: %w", filename, err) } - defer internal_errors.Capture(&err, writer.Close) + defer internal_errors.Capture(&err, writer.Close)() // Prepare the record builder builder := array.NewRecordBuilder(memory.DefaultAllocator, schema) diff --git a/cmd/influx_tools/parquet/schema.go b/cmd/influx_tools/parquet/schema.go index dfd8cae7bd3..958849d206c 100644 --- a/cmd/influx_tools/parquet/schema.go +++ b/cmd/influx_tools/parquet/schema.go @@ -54,7 +54,7 @@ func (s *schemaCreator) extractSchema(ctx context.Context) (err error) { if err != nil { return fmt.Errorf("getting series cursor failed: %w", err) } - defer errors.Capture(&err, seriesCursor.Close) + defer errors.Capture(&err, seriesCursor.Close)() for { cur, err := seriesCursor.Next()