connpool: Don't use go internal sema functionality#18719
Merged
arthurschreiber merged 2 commits intomainfrom Oct 8, 2025
Merged
connpool: Don't use go internal sema functionality#18719arthurschreiber merged 2 commits intomainfrom
sema functionality#18719arthurschreiber merged 2 commits intomainfrom
Conversation
Contributor
Review ChecklistHello reviewers! 👋 Please follow this checklist when reviewing this Pull Request. General
Tests
Documentation
New flags
If a workflow is added or modified:
Backward compatibility
|
sema functionality
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #18719 +/- ##
=======================================
Coverage 67.50% 67.50%
=======================================
Files 1606 1605 -1
Lines 263773 263756 -17
=======================================
- Hits 178048 178038 -10
+ Misses 85725 85718 -7 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
harshit-gangal
approved these changes
Oct 7, 2025
Signed-off-by: Arthur Schreiber <arthur@planetscale.com>
b484295 to
be9818e
Compare
dbussink
approved these changes
Oct 7, 2025
…/pool-dont-use-sema Signed-off-by: Arthur Schreiber <arthur@planetscale.com>
tanjinx
pushed a commit
to slackhq/vitess
that referenced
this pull request
Oct 9, 2025
Signed-off-by: Arthur Schreiber <arthur@planetscale.com>
5 tasks
tanjinx
added a commit
to slackhq/vitess
that referenced
this pull request
Oct 16, 2025
…ng for connection (#712) * CONNPOOL: Fix race condition when waiting for connection (vitessio#18712) Signed-off-by: Arthur Schreiber <arthurschreiber@github.com> Signed-off-by: Matt Lord <mattalord@gmail.com> Signed-off-by: Arthur Schreiber <arthur@planetscale.com> Co-authored-by: Matt Lord <mattalord@gmail.com> Signed-off-by: Tanjin Xu <tanjin.xu@slack-corp.com> * connpool: Bump the hang detection timeout to 1 second. (vitessio#18722) Signed-off-by: Arthur Schreiber <arthur@planetscale.com> * connpool: Don't use go internal `sema` functionality (vitessio#18719) Signed-off-by: Arthur Schreiber <arthur@planetscale.com> --------- Signed-off-by: Arthur Schreiber <arthurschreiber@github.com> Signed-off-by: Matt Lord <mattalord@gmail.com> Signed-off-by: Arthur Schreiber <arthur@planetscale.com> Signed-off-by: Tanjin Xu <tanjin.xu@slack-corp.com> Co-authored-by: Arthur Schreiber <arthurschreiber@github.com> Co-authored-by: Matt Lord <mattalord@gmail.com>
tanjinx
pushed a commit
to slackhq/vitess
that referenced
this pull request
Oct 24, 2025
Signed-off-by: Arthur Schreiber <arthur@planetscale.com>
5 tasks
tanjinx
added a commit
to slackhq/vitess
that referenced
this pull request
Nov 3, 2025
…ting for connection (#727) * [release-22.0] CONNPOOL: Fix race condition when waiting for connection (vitessio#18713) (vitessio#18721) Signed-off-by: Arthur Schreiber <arthurschreiber@github.com> Signed-off-by: Matt Lord <mattalord@gmail.com> Signed-off-by: Arthur Schreiber <arthur@planetscale.com> Co-authored-by: vitess-bot[bot] <108069721+vitess-bot[bot]@users.noreply.github.com> Co-authored-by: Matt Lord <mattalord@gmail.com> Co-authored-by: Arthur Schreiber <arthur@planetscale.com> * [release-22.0] connpool: Bump the hang detection timeout to fix flakiness (vitessio#18722) (vitessio#18724) Signed-off-by: Arthur Schreiber <arthur@planetscale.com> Co-authored-by: vitess-bot[bot] <108069721+vitess-bot[bot]@users.noreply.github.com> * Revert "[release-22.0] connpool: Bump the hang detection timeout to fix flakiness (vitessio#18722) (vitessio#18724)" This reverts commit 4dac149. * Revert "[release-22.0] CONNPOOL: Fix race condition when waiting for connection (vitessio#18713) (vitessio#18721)" This reverts commit 9ab76bf. * [release-22.0] CONNPOOL: Fix race condition when waiting for connection (vitessio#18713) (vitessio#18721) Signed-off-by: Arthur Schreiber <arthurschreiber@github.com> Signed-off-by: Matt Lord <mattalord@gmail.com> Signed-off-by: Arthur Schreiber <arthur@planetscale.com> Co-authored-by: vitess-bot[bot] <108069721+vitess-bot[bot]@users.noreply.github.com> Co-authored-by: Matt Lord <mattalord@gmail.com> Co-authored-by: Arthur Schreiber <arthur@planetscale.com> * connpool: Don't use go internal `sema` functionality (vitessio#18719) Signed-off-by: Arthur Schreiber <arthur@planetscale.com> * [release-22.0] connpool: Bump the hang detection timeout to fix flakiness (vitessio#18722) (vitessio#18724) Signed-off-by: Arthur Schreiber <arthur@planetscale.com> Co-authored-by: vitess-bot[bot] <108069721+vitess-bot[bot]@users.noreply.github.com> --------- Signed-off-by: Arthur Schreiber <arthurschreiber@github.com> Signed-off-by: Matt Lord <mattalord@gmail.com> Signed-off-by: Arthur Schreiber <arthur@planetscale.com> Co-authored-by: vitess-bot[bot] <108069721+vitess-bot[bot]@users.noreply.github.com> Co-authored-by: Matt Lord <mattalord@gmail.com> Co-authored-by: Arthur Schreiber <arthur@planetscale.com> Co-authored-by: Arthur Schreiber <arthurschreiber@github.com>
tanjinx
added a commit
to slackhq/vitess
that referenced
this pull request
Nov 10, 2025
…ting for connection (#727) * [release-22.0] CONNPOOL: Fix race condition when waiting for connection (vitessio#18713) (vitessio#18721) Signed-off-by: Arthur Schreiber <arthurschreiber@github.com> Signed-off-by: Matt Lord <mattalord@gmail.com> Signed-off-by: Arthur Schreiber <arthur@planetscale.com> Co-authored-by: vitess-bot[bot] <108069721+vitess-bot[bot]@users.noreply.github.com> Co-authored-by: Matt Lord <mattalord@gmail.com> Co-authored-by: Arthur Schreiber <arthur@planetscale.com> * [release-22.0] connpool: Bump the hang detection timeout to fix flakiness (vitessio#18722) (vitessio#18724) Signed-off-by: Arthur Schreiber <arthur@planetscale.com> Co-authored-by: vitess-bot[bot] <108069721+vitess-bot[bot]@users.noreply.github.com> * Revert "[release-22.0] connpool: Bump the hang detection timeout to fix flakiness (vitessio#18722) (vitessio#18724)" This reverts commit 4dac149. * Revert "[release-22.0] CONNPOOL: Fix race condition when waiting for connection (vitessio#18713) (vitessio#18721)" This reverts commit 9ab76bf. * [release-22.0] CONNPOOL: Fix race condition when waiting for connection (vitessio#18713) (vitessio#18721) Signed-off-by: Arthur Schreiber <arthurschreiber@github.com> Signed-off-by: Matt Lord <mattalord@gmail.com> Signed-off-by: Arthur Schreiber <arthur@planetscale.com> Co-authored-by: vitess-bot[bot] <108069721+vitess-bot[bot]@users.noreply.github.com> Co-authored-by: Matt Lord <mattalord@gmail.com> Co-authored-by: Arthur Schreiber <arthur@planetscale.com> * connpool: Don't use go internal `sema` functionality (vitessio#18719) Signed-off-by: Arthur Schreiber <arthur@planetscale.com> * [release-22.0] connpool: Bump the hang detection timeout to fix flakiness (vitessio#18722) (vitessio#18724) Signed-off-by: Arthur Schreiber <arthur@planetscale.com> Co-authored-by: vitess-bot[bot] <108069721+vitess-bot[bot]@users.noreply.github.com> --------- Signed-off-by: Arthur Schreiber <arthurschreiber@github.com> Signed-off-by: Matt Lord <mattalord@gmail.com> Signed-off-by: Arthur Schreiber <arthur@planetscale.com> Co-authored-by: vitess-bot[bot] <108069721+vitess-bot[bot]@users.noreply.github.com> Co-authored-by: Matt Lord <mattalord@gmail.com> Co-authored-by: Arthur Schreiber <arthur@planetscale.com> Co-authored-by: Arthur Schreiber <arthurschreiber@github.com>
sbaker617
pushed a commit
to slackhq/vitess
that referenced
this pull request
Feb 5, 2026
…ting for connection (#727) * [release-22.0] CONNPOOL: Fix race condition when waiting for connection (vitessio#18713) (vitessio#18721) Signed-off-by: Arthur Schreiber <arthurschreiber@github.com> Signed-off-by: Matt Lord <mattalord@gmail.com> Signed-off-by: Arthur Schreiber <arthur@planetscale.com> Co-authored-by: vitess-bot[bot] <108069721+vitess-bot[bot]@users.noreply.github.com> Co-authored-by: Matt Lord <mattalord@gmail.com> Co-authored-by: Arthur Schreiber <arthur@planetscale.com> * [release-22.0] connpool: Bump the hang detection timeout to fix flakiness (vitessio#18722) (vitessio#18724) Signed-off-by: Arthur Schreiber <arthur@planetscale.com> Co-authored-by: vitess-bot[bot] <108069721+vitess-bot[bot]@users.noreply.github.com> * Revert "[release-22.0] connpool: Bump the hang detection timeout to fix flakiness (vitessio#18722) (vitessio#18724)" This reverts commit 4dac149. * Revert "[release-22.0] CONNPOOL: Fix race condition when waiting for connection (vitessio#18713) (vitessio#18721)" This reverts commit 9ab76bf. * [release-22.0] CONNPOOL: Fix race condition when waiting for connection (vitessio#18713) (vitessio#18721) Signed-off-by: Arthur Schreiber <arthurschreiber@github.com> Signed-off-by: Matt Lord <mattalord@gmail.com> Signed-off-by: Arthur Schreiber <arthur@planetscale.com> Co-authored-by: vitess-bot[bot] <108069721+vitess-bot[bot]@users.noreply.github.com> Co-authored-by: Matt Lord <mattalord@gmail.com> Co-authored-by: Arthur Schreiber <arthur@planetscale.com> * connpool: Don't use go internal `sema` functionality (vitessio#18719) Signed-off-by: Arthur Schreiber <arthur@planetscale.com> * [release-22.0] connpool: Bump the hang detection timeout to fix flakiness (vitessio#18722) (vitessio#18724) Signed-off-by: Arthur Schreiber <arthur@planetscale.com> Co-authored-by: vitess-bot[bot] <108069721+vitess-bot[bot]@users.noreply.github.com> --------- Signed-off-by: Arthur Schreiber <arthurschreiber@github.com> Signed-off-by: Matt Lord <mattalord@gmail.com> Signed-off-by: Arthur Schreiber <arthur@planetscale.com> Co-authored-by: vitess-bot[bot] <108069721+vitess-bot[bot]@users.noreply.github.com> Co-authored-by: Matt Lord <mattalord@gmail.com> Co-authored-by: Arthur Schreiber <arthur@planetscale.com> Co-authored-by: Arthur Schreiber <arthurschreiber@github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This replaces the semaphore implementation that uses go internals with a channel based implementation that effectively performs the same, if not even a tiny bit better.
The "trick" here is the use of
runtime.Gosched()right after writing to the channel, which allows the goroutine that's waiting on the channel to start running immediately. This behaves like the direct handoff functionality of the previous semaphore implementation, but without reaching into go internals.This allows removing one of the
go:linknamedependencies, without any negative side effects. It also means we don't have to ship a custom semaphore implementation for builds that have the race detector enabled.I'm on the fence on whether this should be backported to v21 and v22, as this doesn't directly fix any issues.
Benchmark Results
Related Issue(s)
Checklist
Deployment Notes
AI Disclosure