Skip to content

Conversation

Copy link

Copilot AI commented Jan 23, 2026

DbDataReader from ExecuteReaderAsync() was not disposed, causing connection pool exhaustion and potential database locks under load.

Changes

  • Wrapped DbDataReader in using statement in CsvFileWriter.SaveQueryToCSV
// Before
var reader = await SqlCommand.ExecuteReaderAsync(cancellationToken).ConfigureAwait(false);
output = DataReaderToCsv(reader, csvFile, Options, cancellationToken);

// After  
using (var reader = await SqlCommand.ExecuteReaderAsync(cancellationToken).ConfigureAwait(false))
{
    output = DataReaderToCsv(reader, csvFile, Options, cancellationToken);
}

No functional changes - purely resource management.

Original prompt

Analyze ExecuteQueryToFile task and see if there are some mem leak issues that can be identified


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: jefim <1387820+jefim@users.noreply.github.com>
Copilot AI changed the title [WIP] Analyze ExecuteQueryToFile for memory leak issues Fix resource leak in ExecuteQueryToFile Jan 23, 2026
Copilot AI requested a review from jefim January 23, 2026 08:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants