diff --git a/flow/connectors/utils/cdc_records/cdc_records_storage.go b/flow/connectors/utils/cdc_records/cdc_records_storage.go index e990235348..1449a489c7 100644 --- a/flow/connectors/utils/cdc_records/cdc_records_storage.go +++ b/flow/connectors/utils/cdc_records/cdc_records_storage.go @@ -163,11 +163,13 @@ func (c *cdcRecordsStore) Len() int { func (c *cdcRecordsStore) Close() error { c.inMemoryRecords = nil - err := c.pebbleDB.Close() - if err != nil { - return fmt.Errorf("failed to close database: %w", err) + if c.pebbleDB != nil { + err := c.pebbleDB.Close() + if err != nil { + return fmt.Errorf("failed to close database: %w", err) + } } - err = os.RemoveAll(c.dbFolderName) + err := os.RemoveAll(c.dbFolderName) if err != nil { return fmt.Errorf("failed to delete database file: %w", err) }