TestPosixMirrorIntegration fails on macOS: its burst of connections overflows the listen queue

Open Beginner friendly
#1,253 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@grempe is already working on this.

Since Oct 23, 2026.

  • #1254 by @grempe — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
77/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
go
Domain
testing

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 to SOMAXCONN, 128 (uipc_socket.c:250), and solisten caps 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 pipe on 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 ECONNRESET on macOS 27, and more of them succeed first. An Apple DTS engineer there calls both changes bugs: the new errno doesn't match the listen(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.somaxconn has defaulted to 4,096 since Linux 5.4. tcp_abort_on_overflow is 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 HTTPClient limited 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

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from transparency-dev/tessera

All issues in transparency-dev/tessera

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.