Skip to content

fix: ordering issue in fast-fail when all tasks succeeds (e.g. retrieve)#2522

Merged
haakonvt merged 3 commits intopysdk-release-v8from
fix-ordering-issue
Mar 20, 2026
Merged

fix: ordering issue in fast-fail when all tasks succeeds (e.g. retrieve)#2522
haakonvt merged 3 commits intopysdk-release-v8from
fix-ordering-issue

Conversation

@haakonvt
Copy link
Contributor

This is the second time we have had this bug, this time because asyncio.wait returns a set (which is unordered). The reason it was not caught immediately by the guarding test from last time was that it was refactored in: #2149 to be much less effective at triggering it.

We should take extra care to rewrite similar tests in the future and ensure the rewritten tests consistently fail on the old version.

@haakonvt haakonvt requested review from a team as code owners March 20, 2026 12:54
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a critical ordering issue that resurfaced in the asynchronous task execution utility. The problem stemmed from relying on the unordered nature of asyncio.wait's return value when all tasks succeeded, leading to incorrect result ordering. The fix ensures that the original task order is preserved, and an accompanying integration test has been significantly improved to prevent future regressions by actively simulating concurrent scenarios and validating the output order.

Highlights

  • Ordering Issue Fix: Resolved an ordering bug in execute_async_tasks_with_fail_fast where results were incorrectly ordered when all asynchronous tasks completed successfully, due to asyncio.wait returning an unordered set.
  • Version Update: Incremented the SDK version from 8.0.2 to 8.0.3 in _version.py and pyproject.toml.
  • Integration Test Enhancement: Refactored the test_retrieve_multiple__ordering_matches_input integration test to reliably reproduce the ordering bug, ensuring it uses sufficient concurrency and correctly verifies the order of retrieved items against the input.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

The code changes increment the cognite-sdk version from 8.0.2 to 8.0.3. Additionally, a test case was modified to address a bug in the SDK version 8.0.0 where the ordering of results was broken when retrieving a large number of events concurrently. The test now creates a large number of events, shuffles their external IDs, and retrieves them using retrieve_multiple, asserting that the order of the retrieved events matches the shuffled order of the external IDs.

@codecov
Copy link

codecov bot commented Mar 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.41%. Comparing base (36037e2) to head (043e50d).
⚠️ Report is 9 commits behind head on pysdk-release-v8.

Additional details and impacted files
@@                 Coverage Diff                  @@
##           pysdk-release-v8    #2522      +/-   ##
====================================================
- Coverage             93.48%   93.41%   -0.08%     
====================================================
  Files                   478      478              
  Lines                 48118    48173      +55     
====================================================
+ Hits                  44983    45000      +17     
- Misses                 3135     3173      +38     
Files with missing lines Coverage Δ
cognite/client/_version.py 100.00% <100.00%> (ø)
cognite/client/utils/_concurrency.py 85.88% <100.00%> (ø)
tests/tests_integration/test_api_client.py 99.52% <100.00%> (+0.02%) ⬆️

... and 5 files with indirect coverage changes

🚀 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.

polomani
polomani previously approved these changes Mar 20, 2026
Copy link
Contributor

@polomani polomani left a comment

Choose a reason for hiding this comment

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

🦄

@haakonvt haakonvt force-pushed the fix-ordering-issue branch from fef50a4 to 043e50d Compare March 20, 2026 15:18
@policy-bot-cognitedata policy-bot-cognitedata bot dismissed polomani’s stale review March 20, 2026 15:18

Invalidated by push of 043e50d

@haakonvt haakonvt enabled auto-merge March 20, 2026 15:19
Copy link
Contributor

@polomani polomani left a comment

Choose a reason for hiding this comment

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

🦄

@haakonvt haakonvt merged commit c9fd42d into pysdk-release-v8 Mar 20, 2026
18 checks passed
@haakonvt haakonvt deleted the fix-ordering-issue branch March 20, 2026 15:25
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