Skip to content

Fix flaky parallel split query test: move ClearLog() before parallel tasks#38640

Merged
AndriySvyryd merged 1 commit into
mainfrom
copilot/fix-flaky-sql-server-test
Jul 16, 2026
Merged

Fix flaky parallel split query test: move ClearLog() before parallel tasks#38640
AndriySvyryd merged 1 commit into
mainfrom
copilot/fix-flaky-sql-server-test

Conversation

Copilot AI commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Can_query_with_nav_collection_in_projection_with_split_query_in_parallel_async intermittently failed with Expected: 400, Actual: 399 because ClearLog() was called inside each concurrent task. Task 2's ClearLog() could race and fire after Task 1 had already logged its first SQL statement, silently dropping it from the shared log.

  • Move ClearLog() from inside each parallel task lambda to the outer test method, called once before tasks are launched
  • Apply the same fix to the sync variant (Can_query_with_nav_collection_in_projection_with_split_query_in_parallel_sync)
// Before: ClearLog() inside each concurrent task — race condition
var task1 = QueryAsync(context1, ...);  // task starts, logs SQL...
var task2 = QueryAsync(context2, ...);  // ClearLog() wipes task1's already-logged entry

// After: cleared once, synchronously, before tasks start
ClearLog();
var task1 = QueryAsync(context1, ...);
var task2 = QueryAsync(context2, ...);

…tasks

Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses intermittent flakiness in the parallel split-query tests by removing a race condition in SQL log clearing: ClearLog() was previously invoked inside concurrently running task bodies, allowing one task to clear the shared TestSqlLoggerFactory log after the other task had already started logging.

Changes:

  • Move ClearLog() to run once before starting parallel async tasks in Can_query_with_nav_collection_in_projection_with_split_query_in_parallel_async.
  • Apply the same change to the sync parallel variant Can_query_with_nav_collection_in_projection_with_split_query_in_parallel_sync.

@AndriySvyryd AndriySvyryd marked this pull request as ready for review July 15, 2026 19:45
@AndriySvyryd AndriySvyryd requested a review from a team as a code owner July 15, 2026 19:45
@AndriySvyryd AndriySvyryd requested a review from cincuranet July 15, 2026 19:45
@AndriySvyryd AndriySvyryd merged commit bd2ea34 into main Jul 16, 2026
17 checks passed
@AndriySvyryd AndriySvyryd deleted the copilot/fix-flaky-sql-server-test branch July 16, 2026 17: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.

4 participants