Skip to content

fix: signal handling in NotifyContextWithCallback - #5987

Merged
mihir20 merged 1 commit into
masterfrom
mihir/fix-flaky-test
Jun 17, 2025
Merged

mihir20 merged 1 commit into
masterfrom
mihir/fix-flaky-test

Conversation

@mihir20

@mihir20 mihir20 commented Jun 13, 2025 •

Copy link
Copy Markdown
Contributor

Description

test "does not call the callback if context is canceled by us" was flaky as

  1. When cancel() is called in the test, it calls both cancel() and signalCancel()
  2. The goroutine's select statement might choose either <-signalCtx.Done() or <-ctx.Done()
  3. If it happens to select <-signalCtx.Done(), it will incorrectly call the callback function

solution: cancel signalCtx when ctx is done

Linear Ticket

Security

  • The code changed/added as part of this pull request won't create any security issues with how the software is being used.

@ktgowtham
ktgowtham requested a review from atzoum June 13, 2025 09:12
@codecov

codecov Bot commented Jun 13, 2025 •

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 76.61%. Comparing base (7e3715a) to head (a06ca45).
Report is 8 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5987      +/-   ##
==========================================
+ Coverage   76.57%   76.61%   +0.04%     
==========================================
  Files         514      514              
  Lines       69121    69120       -1     
==========================================
+ Hits        52927    52957      +30     
+ Misses      13303    13280      -23     
+ Partials     2891     2883       -8     

☔ View full report in Codecov by Sentry.
📢 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.

@mihir20 mihir20 changed the title chore: improve signal handling in NotifyContextWithCallback fix: signal handling in NotifyContextWithCallback Jun 16, 2025
@ktgowtham
ktgowtham self-requested a review June 16, 2025 11:02

@ktgowtham ktgowtham 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.

How about just removing signalCancel() in the return statement?
We call signalCancel() inside ctx.Done() rt?

@mihir20
mihir20 force-pushed the mihir/fix-flaky-test branch from 84cb09b to a06ca45 Compare June 16, 2025 14:09
@mihir20
mihir20 requested a review from ktgowtham June 16, 2025 14:12
@mihir20
mihir20 merged commit f1934be into master Jun 17, 2025
@mihir20
mihir20 deleted the mihir/fix-flaky-test branch June 17, 2025 11:09
This was referenced Jun 23, 2025
atzoum pushed a commit that referenced this pull request Jun 23, 2025
# Description

test "does not call the callback if context is canceled by us" was flaky
as

1. When cancel() is called in the test, it calls both cancel() and
signalCancel()
2. The goroutine's select statement might choose either
<-signalCtx.Done() or <-ctx.Done()
3. If it happens to select <-signalCtx.Done(), it will incorrectly call
the callback function

---

solution: cancel `signalCtx` when ctx is done

## Linear Ticket

-

## Security

- [x] The code changed/added as part of this pull request won't create
any security issues with how the software is being used.
This was referenced Jun 23, 2025
satishrudderstack pushed a commit that referenced this pull request Jun 23, 2025
🤖 I have created a release *beep* *boop*
---


##
[1.53.0-rc.1](v1.52.0...v1.53.0-rc.1)
(2025-06-23)


### Features

* add support for Snowflake Iceberg tables
([#5922](#5922))
([93b3f5e](93b3f5e))


### Bug Fixes

* add golang.org/x/net/html vulnerability
([#5988](#5988))
([92f8c1c](92f8c1c))
* add source type to internalBatch request stats
([#6030](#6030))
([1c8350e](1c8350e))
* add validation to skip disabled destinations to be associated with
accounts
([#5985](#5985))
([06a584c](06a584c))
* signal handling in NotifyContextWithCallback
([#5987](#5987))
([c3fc223](c3fc223))


### Miscellaneous

* add metrics for duplicate events in staging files
([#5998](#5998))
([2e3ffc5](2e3ffc5))
* bump go kit
([#6034](#6034))
([1fcb140](1fcb140))
* create enterprise images with an additional race enabled build
([#5999](#5999))
([f8d2a94](f8d2a94))
* enable warehouse race test
([#5997](#5997))
([baa83f7](baa83f7))
* gateway warehouse integration test
([#5996](#5996))
([861fada](861fada))
* sync release v1.52.1 to main branch
([#6009](#6009))
([deb8c00](deb8c00))
* sync release v1.52.2 to main branch
([#6019](#6019))
([6cdbb65](6cdbb65))
* sync release v1.52.3 to main branch
([#6024](#6024))
([3fecf81](3fecf81))
* sync release v1.52.4 to main branch
([#6027](#6027))
([fbf54fe](fbf54fe))
* sync release v1.52.5 to main branch
([#6032](#6032))
([8f60155](8f60155))
* update nodeSelector for warehouse benchmark deploy
([#6001](#6001))
([4e6d4ac](4e6d4ac))
* use a reloadable config for deciding whether to shudown on
non-reloadable config change
([#6036](#6036))
([3d0a05a](3d0a05a))
* use kitsync.ErrGroup instead of errgroup.Group
([#6011](#6011))
([bba66d6](bba66d6))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
satishrudderstack pushed a commit that referenced this pull request Jun 25, 2025
🤖 I have created a release *beep* *boop*
---


##
[1.53.0](v1.52.0...v1.53.0)
(2025-06-23)


### Features

* add support for Snowflake Iceberg tables
([#5922](#5922))
([93b3f5e](93b3f5e))


### Bug Fixes

* add golang.org/x/net/html vulnerability
([#5988](#5988))
([92f8c1c](92f8c1c))
* add source type to internalBatch request stats
([#6030](#6030))
([1c8350e](1c8350e))
* add validation to skip disabled destinations to be associated with
accounts
([#5985](#5985))
([06a584c](06a584c))
* signal handling in NotifyContextWithCallback
([#5987](#5987))
([c3fc223](c3fc223))


### Miscellaneous

* add metrics for duplicate events in staging files
([#5998](#5998))
([2e3ffc5](2e3ffc5))
* bump go kit
([#6034](#6034))
([1fcb140](1fcb140))
* create enterprise images with an additional race enabled build
([#5999](#5999))
([f8d2a94](f8d2a94))
* enable warehouse race test
([#5997](#5997))
([baa83f7](baa83f7))
* gateway warehouse integration test
([#5996](#5996))
([861fada](861fada))
* sync release v1.52.1 to main branch
([#6009](#6009))
([deb8c00](deb8c00))
* sync release v1.52.2 to main branch
([#6019](#6019))
([6cdbb65](6cdbb65))
* sync release v1.52.3 to main branch
([#6024](#6024))
([3fecf81](3fecf81))
* sync release v1.52.4 to main branch
([#6027](#6027))
([fbf54fe](fbf54fe))
* sync release v1.52.5 to main branch
([#6032](#6032))
([8f60155](8f60155))
* update nodeSelector for warehouse benchmark deploy
([#6001](#6001))
([4e6d4ac](4e6d4ac))
* use a reloadable config for deciding whether to shudown on
non-reloadable config change
([#6036](#6036))
([3d0a05a](3d0a05a))
* use kitsync.ErrGroup instead of errgroup.Group
([#6011](#6011))
([bba66d6](bba66d6))

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