portlist: TestPortlistBackendChurn is flaky when other processes open sockets
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 70/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- go, linux
- Domain
- networking, testing
Research direction
Start with TestPortlistBackendChurn in portlist_linux_bench_test.go and inspect how it exercises the /proc and inet_diag listing paths. The issue proposes using a dedicated tcp4 listener on a port absent from the listing, then checking that the port appears before closing and disappears afterward. Run the churn test under concurrent socket activity; done means the assertion tracks the fixture port reliably across both paths.
Written by the indexing model from the issue text.
Description
TestPortlistBackendChurn fails when other sockets are opened in the same network namespace while it runs:
portlist_linux_bench_test.go:341: churn did not remove listener: before=11 after=11
This happens in nixpkgs' package tests. There, one go test -p $NIX_BUILD_CORES run tests many packages in parallel inside a single build sandbox, and the sandbox has one network namespace shared by all of them.
The test closes one fixture listener and asserts that len(AppendListeningPorts) shrank. That listing covers every socket in the namespace, so any other process or test that opens a socket between the two listings breaks the assertion. As a reproducer, I ran four processes that bind and close loopback TCP/UDP sockets in a tight loop alongside go test -count=500 -run '^TestPortlistBackendChurn$' ./portlist/. It failed 354 of 500 runs.
The obvious fix is to check that the closed listener's own port disappears, rather than comparing counts. That approach has a second, rarer problem, which the count check also has. The listing is deduplicated by (Proto, Port) regardless of address. The fixture's tcp6 listener on [::1]:0 sometimes gets the same port number as the tcp4 listener on 127.0.0.1:0. When it does, closing the tcp4 listener leaves the (tcp, port) entry in the listing. I saw this once in 2000 runs.
Here's a possible way forward.
- open a dedicated tcp4 listener for the churn step, on a port that is not already in the listing;
- assert that this port is listed before the close and absent after it, for both the
/procandinet_diagpaths.
I prototyped that. Under the same socket noise, that failed 5 of 5773 runs. Each failure was the kernel giving the freed port to one of the noise processes right after the close, which is unlikely at any realistic socket churn rate.
I have a patch ready if that approach sounds right.
- Dominant language
- Go
- Stars
- 38.8k
- Forks
- 3.4k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 194
Getting set up
- Ships a Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from tailscale/tailscale
-
FR: update golang.org/x/sys to v0.50.0Possibly taken @wrenix claimed this today. Openfr needs-triage
Difficulty 2/5 Under an hour Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
fr
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
bug kubernetes
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
Maintainers usually reply within 1 day
-
Document using Docker Compose secrets support for TS_AUTHKEYPossibly taken @Marouane-elfadli claimed this 6 days ago. OpenDocumentation
Difficulty 1/5 1-3 hours Newbie friendliness 84/100
tailscale/tailscale#22214 · 1 reaction ·
Maintainers usually reply within 1 day
-
fr OS-linux
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
All issues in tailscale/tailscale
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
oxc-project/tsgolint#1362 ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
hashicorp/terraform-provider-google#30703 ·
Maintainers usually reply within 1 day
-
UpdateSchema.BuildUpdates should select newly added schemas with schema-id: -1Possibly taken @nisan1101 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
apache/iceberg-go#2586 · 1 comment ·
Maintainers usually reply within 2 days
-
[Docs] Four internal links return 404 (Models concept, Contributing to Docs, Providers reference)Possibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
meshery/meshery#23520 · 1 comment ·
Maintainers usually reply within 1 day
-
automated documentation maintenance
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
github/gh-aw-mcpg#16482 ·
Maintainers usually reply within 1 day