Skip to content

fix: ensure correct concurrent cancellation results#287

Merged
yarolegovich merged 8 commits intomainfrom
yarolegovich/fix-cancel-result-new
Mar 20, 2026
Merged

fix: ensure correct concurrent cancellation results#287
yarolegovich merged 8 commits intomainfrom
yarolegovich/fix-cancel-result-new

Conversation

@yarolegovich
Copy link
Copy Markdown
Member

the fix was not working for concurrent cancellations because errors.Is check was not passing in the added logic

re #245

the fix was not working for concurrent cancellations because `errors.Is`
check was not passing in the added logic

re #245
@gemini-code-assist
Copy link
Copy Markdown
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 bug in concurrent task cancellation where the system failed to correctly identify cancellation errors due to an errors.Is mismatch. The fix involves explicitly wrapping concurrent modification errors, ensuring that cancellation attempts on already completed tasks are properly recognized. Additionally, the changes significantly enhance the test suite for cancellation logic, introducing new test helpers and scenarios to validate the robustness of concurrent operations.

Highlights

  • Concurrent Cancellation Fix: Resolved an issue where concurrent cancellations were not correctly handled because errors.Is failed to match the underlying error type, leading to incorrect cancellation results.
  • Improved Error Handling: Modified the taskupdate.Manager to wrap concurrent modification errors with taskstore.ErrConcurrentModification, ensuring proper identification and handling of cancellation attempts on tasks that have already reached a terminal state.
  • Enhanced Testability: Refactored the TestAgentExecutor to separate Execute and Cancel implementations and introduced ControlChannels for more granular control over test scenarios, significantly improving the ability to test complex concurrent flows.
  • Expanded End-to-End Tests: Added new end-to-end tests to cover various concurrent cancellation scenarios, including verifying correct error responses for failed cancellations, handling cancellation of already cancelled tasks, and ensuring consistent results across multiple concurrent cancellation requests.
  • Simplified Event Subscription: Streamlined the event subscription logic in localSubscription by removing a redundant terminalReported flag and simplifying the mechanism for reporting terminal events.
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
Copy Markdown
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

This pull request addresses an issue with concurrent cancellations by correctly wrapping taskstore.ErrConcurrentModification, enabling proper error checking with errors.Is. This is a crucial fix for robust error handling in concurrent scenarios. The pull request also significantly enhances the test suite by introducing comprehensive end-to-end tests for various cancellation race conditions, supported by new, well-designed test helpers. Additionally, there's a nice simplification of the event subscription logic. Overall, this is a high-quality contribution that not only resolves the immediate issue but also strengthens the project's test infrastructure. I have one suggestion to further improve the robustness of a new test case.

@yarolegovich yarolegovich merged commit d0f8981 into main Mar 20, 2026
4 checks passed
@yarolegovich yarolegovich deleted the yarolegovich/fix-cancel-result-new branch March 20, 2026 10:00
yarolegovich pushed a commit that referenced this pull request Mar 24, 2026
🤖 I have created a release *beep* *boop*
---


## [2.0.1](v2.0.0...v2.0.1)
(2026-03-24)


### Features

* **a2acompat:** add HTTP+JSON REST support to a2av0 compat layer
([#280](#280))
([bac00e7](bac00e7))
* agent executor cleaner
([#276](#276))
([9c95980](9c95980))


### Bug Fixes

* ensure correct concurrent cancellation results
([#287](#287))
([d0f8981](d0f8981)),
closes [#245](#245)


### Documentation

* **a2aclient:** add Example_* test functions for pkg.go.dev
documentation ([#263](#263))
([f8dae97](f8dae97))
* update diagrams, docs and instructions
([#289](#289))
([ed33c7a](ed33c7a))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
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.

3 participants