Repository navigation
fix: serialize poller close with pending notifications - #768
Open
Scratch-net wants to merge 1 commit into
Open
Scratch-net wants to merge 1 commit into
Scratch-net wants to merge 1 commit into
Conversation
4 tasks done
Owner
|
Thanks, I'll review this when available. |
|
This PR is marked as stale because it has been open for 21 days with no activity. You should take one of the following actions:
This PR will be automatically closed in 7 days if no further activity occurs. |
|
This PR is marked as stale because it has been open for 21 days with no activity. You should take one of the following actions:
This PR will be automatically closed in 7 days if no further activity occurs. |
This branch has not been deployed
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.
1. Are you opening this pull request for bug-fix, optimization or new feature?
Bug fix for poller initialization and concurrent notification/close handling.
2. Please describe how these code changes achieve your intention.
On Linux with
poll_opt, descriptor exhaustion after epoll creation causesOpenPollerto panic while closing a nil eventfd attachment. The included subprocess regression reproduces this on upstreamdev.The patch initializes descriptors to invalid values before fallible setup. BSD wakeup-pipe creation returns an error instead of terminating the process. Repeated
Closecalls return the saved result without closing a reused descriptor.Triggerholds shared admission ownership through queue insertion and notification.Closetakes exclusive ownership afterPollinghas returned. It then closes descriptors and discards queued references without running callbacks outside their event loop. This prevents a producer from notifying a descriptor after it has been closed and reused. A shutdown callback is returned to the task pool beforePollingexits.The existing wakeup CAS and queue priority rules remain. A closed flag or
sync.Oncealone cannot wait for a producer that already passed admission but has not finished notification. The shared lock covers that interval; tests pause a producer inside it and exercise descriptor reuse.There is a cost. With Go 1.20.14, Linux/amd64, GOMAXPROCS=2, and five one-second samples, the included coalesced-submission benchmark had these medians:
This is an uncontended submission microbenchmark, not an end-to-end throughput claim. Feedback on an alternative admission barrier is welcome.
The shared definitions are in
defs_poller.go, following the file-placement feedback in #766. Unlike that proposal, this patch adds noDonechannel or separate retirement operation.Closestill requires the polling owner to have exited. The example now excludespoll_opt, whosePollingmethod has a different signature.Extracted from the local Telego gnet patches. This branch keeps Go 1.20 and upstream dependencies and is independent of the other proposals.
Validation: the complete
pkg/netpolltests pass on Go 1.20.14 with the default race detector and withpoll_opt. The startup test fails on unchanged upstream withpoll_optand passes after this patch. The root test package cross-compiles for Linux/386, Darwin/arm64, FreeBSD/amd64, NetBSD/amd64, OpenBSD/amd64, and Windows/amd64, with both Unix poller variants. Non-Linux runtime testing remains for upstream CI. Upstream-enabled lint checks pass with golangci-lint 2.14.0.3. Please link to the relevant issues (if any).
Related lifecycle discussion: #765 and #766. This PR covers poller initialization and notification/close ownership; enrollment completion is separate.
4. What documentation changes need to be made?
Closecomments specify the polling-owner boundary and idempotence. Tests and the benchmark document the race and its cost.Checklist