Skip to content

Fix flaky PipelineBasedStreamingInsertTest.test_failure_in_some_rows_does_not_duplicate - #41004

Merged
tvalentyn merged 1 commit into
apache:masterfrom
tvalentyn:flake
Nov 5, 2026
Merged

tvalentyn merged 1 commit into
apache:masterfrom
tvalentyn:flake

Conversation

@tvalentyn

Copy link
Copy Markdown
Contributor

The mocked insert_rows_json call failed rows by their position in the batch (index 0 and 2), assuming they are always 'value1' and 'value5'. However, _StreamToBigQuery assigns each row a random shard key in [0, 500] and applies ReshufflePerKey, so the order in which rows reach the client is not guaranteed. When 'value1' and 'value5' land on the same shard (~0.2% of runs), the rows arrive as [value1, value5, value3], and 'value3' is failed instead of 'value5', which breaks the RETRY_NEVER variant.

Identify the rows to fail by value instead of by index.

…does_not_duplicate

The mocked insert_rows_json call failed rows by their position in the batch
(index 0 and 2), assuming they are always 'value1' and 'value5'. However,
_StreamToBigQuery assigns each row a random shard key in [0, 500] and applies
ReshufflePerKey, so the order in which rows reach the client is not
guaranteed. When 'value1' and 'value5' land on the same shard (~0.2% of runs),
the rows arrive as [value1, value5, value3], and 'value3' is failed instead of
'value5', which breaks the RETRY_NEVER variant.

Identify the rows to fail by value instead of by index.
@github-actions github-actions Bot added python io gcp size/s S: 10-49 lines changed labels Nov 5, 2026
@tvalentyn

Copy link
Copy Markdown
Contributor Author

Encountered in #40960 (comment)

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

📋 Review Summary

This PR fixes a flaky unit test (PipelineBasedStreamingInsertTest.test_failure_in_some_rows_does_not_duplicate) by matching simulated row failures by row value rather than batch index. Because _StreamToBigQuery assigns random shard keys and applies ReshufflePerKey, batch ordering is non-deterministic when shard keys collide.

🔍 General Feedback

  • The root cause analysis and fix are clean, self-contained, and well-commented.

💡 Tip: Comment /gemini review on this pull request to trigger a new Gemini code review.

@tvalentyn

Copy link
Copy Markdown
Contributor Author

/gemini review

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

📋 Review Summary

This PR resolves a test flake in PipelineBasedStreamingInsertTest.test_failure_in_some_rows_does_not_duplicate caused by non-deterministic row ordering after _StreamToBigQuery's random-key reshuffle. By matching rows to fail by their columnA value rather than their batch index, the mock callback consistently fails 'value1' and 'value5' regardless of arrival order.

🔍 General Feedback

  • The root cause analysis and fix are clean, well-documented, and directly address the ~0.2% shard collision flake without altering the test's intent.

💡 Tip: Comment /gemini review on this pull request to trigger a new Gemini code review.

@codecov

codecov Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.09%. Comparing base (12bbb17) to head (acaace2).
⚠️ Report is 70 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #41004      +/-   ##
==========================================
+ Coverage   79.83%   80.09%   +0.25%     
==========================================
  Files         494      494              
  Lines       83575    83615      +40     
==========================================
+ Hits        66722    66970     +248     
+ Misses      16853    16645     -208     
Flag Coverage Δ
python 80.09% <ø> (+0.25%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Assigning reviewers:

R: @claudevdm for label python.
Backup reviewer: shunping (if the main reviewer is unresponsive, you can escalate to them by tagging their username)

Note: If you would like to opt out of this review, comment assign to next reviewer.

Available commands:

  • stop reviewer notifications - opt out of the automated review tooling
  • remind me after tests pass - tag the comment author after tests pass
  • waiting on author - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)

The PR bot will only process comments in the main thread (not review comments).

@tvalentyn
tvalentyn merged commit 8f5a492 into apache:master Nov 5, 2026
85 of 86 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants