TestPosixMirrorIntegration fails on macOS: its burst of connections overflows the listen queue
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 77/100
Research direction
Start with integration/mirror/posix/mirror_test.go around the LogIntegrationTest call, then read integration/log/log_integration.go to see how the HTTP client and batch size are used. Reproduce with go test -count=1 -run '^TestPosixMirrorIntegration$' -v ./integration/mirror/posix/ on macOS. Done when the test limits concurrent connections, fills batches promptly, and passes reliably on macOS.
Written by the indexing model from the issue text.
Description
Reviewed and filed by me, a human. The investigation, repro and fix were developed with the assistance of an AI coding agent.
Summary: On macOS, TestPosixMirrorIntegration fails nearly every run with connection reset by peer on POST /add. The test adds 1,024 entries concurrently through http.DefaultClient, which has no limit on connections to one host, so it opens hundreds of connections to its httptest server at once. A macOS listener queues at most 128 connections waiting to be accepted, and macOS 27 resets connections beyond that. Linux queues 4,096 by default, and there the test passes, as it does in CI on Ubuntu.
Where (main at 012e9e0): the test calls LogIntegrationTest without an HTTPClient (mirror_test.go:154). So it gets http.DefaultClient (log_integration.go:54–56), and starts one goroutine per entry, each making one POST (lines 80–98).
Repro. On macOS, in a checkout of main:
go test -count=1 -run '^TestPosixMirrorIntegration$' -v ./integration/mirror/posix/
On macOS 27.0.1 (Apple silicon, Go 1.27.3), it failed 16 of 17 runs, including 3 of 3 in a fresh clone. The reset comes either at connect or when reading the response. These two lines are from separate runs:
mirror_test.go:154: addEntry: entryWriter.add(517): Post "http://127.0.0.1:52811/add": dial tcp 127.0.0.1:52811: connect: connection reset by peer
mirror_test.go:154: addEntry: entryWriter.add(793): Post "http://127.0.0.1:55453/add": read tcp 127.0.0.1:55566->127.0.0.1:55453: read: connection reset by peer
A failing run takes about 62 s; in the run I traced, the failure came after 2.8 s. The rest is cleanup. A goroutine dump during it shows shutdownAppender waiting for a checkpoint, for up to its 60 s DefaultShutdownTimeout, with none of the appender's own goroutines left to publish one. The appender runs on t.Context(), which is cancelled before cleanups run.
Why macOS:
- The queue limit. On macOS, Go listens with a backlog of
kern.ipc.somaxconn(net/sock_bsd.go). XNU initialises that toSOMAXCONN, 128 (uipc_socket.c:250), andsolistencaps any backlog at it (line 911). - Measured here: against a listener that never accepts, I made 300 concurrent dials. All 300 connected, and 128 stayed queued. The kernel reset the other 172, which shows up as
broken pipeon their first write. That was the same in each of 3 runs. The program is about 75 lines; I can share it if that's useful. - macOS 27 changed how an overflowing queue fails. In a thread on the Apple Developer Forums, connects to a full queue that timed out on macOS 26 get
ECONNRESETon macOS 27, and more of them succeed first. An Apple DTS engineer there calls both changes bugs: the new errno doesn't match thelisten(2)man page, and the number that succeed differs from earlier systems. I've only tested macOS 27, so I don't know how this test behaves on 26. - Linux:
net.core.somaxconnhas defaulted to 4,096 since Linux 5.4.tcp_abort_on_overflowis off by default, so a connection that overflows the queue recovers instead of being reset (ip-sysctl). Under Linux in Docker (Go 1.26.9,-race), the test passed 5 of 5.
Fix: I'll open a PR that changes only this test:
- it passes an
HTTPClientlimited to 64 connections; - it sets the log's batch size to 64, so that batches fill instead of waiting their 1 s maximum age.
With that, the test passes 18 of 18 on macOS: about 2.4 s a run, or 3.2 s with -race. On Linux it takes the same time as before.
- Dominant language
- Go
- Stars
- 262
- Forks
- 64
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 20
Getting set up
- No 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 transparency-dev/tessera
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
transparency-dev/tessera#1286 ·
Maintainers usually reply within 1 day
-
Fix tlog-mirror log origin length prefixPossibly taken @phbnf claimed this 32 days ago. Openenhancement
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
transparency-dev/tessera#1233 · 1 comment ·
Maintainers usually reply within 1 day
-
AWS: adds fail while object-storage writes are slow (integration's gap lock on Seq)Possibly taken @grempe claimed this 30 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 35/100
transparency-dev/tessera#1256 ·
Maintainers usually reply within 1 day
-
AWS: MySQL pools are never closed, so reopening a log in one process leaks goroutines and connectionsPossibly taken @grempe claimed this 13 days ago. Open
Difficulty 4/5 1-2 days Newbie friendliness 48/100
transparency-dev/tessera#1251 · 1 comment ·
Maintainers usually reply within 1 day
-
PublicationAwaiter reads the checkpoint every poll period even when nothing is waitingPossibly taken @grempe claimed this 31 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
transparency-dev/tessera#1249 ·
Maintainers usually reply within 1 day
All issues in transparency-dev/tessera
Similar issues
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 2 days
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
seaweedfs/seaweed-block#443 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
version-fox/vfox#825 ·
Maintainers usually reply within 1 day
-
HTTP `batch.Send` returns nil and inserts no rows when the block does not encodePossibly taken @Indian-boult claimed this today. Openbug queries
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
ClickHouse/clickhouse-go#2155 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 82/100
Maintainers usually reply within 1 day