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

Aperta Adatta ai principianti
#1,253 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@grempe ci sta già lavorando.

Dal 23/10/2026.

  • #1254 di @grempe — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
77/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
go
Ambito
testing

Direzione di ricerca

Inizia da integration/mirror/posix/mirror_test.go, in corrispondenza della chiamata a LogIntegrationTest, poi leggi integration/log/log_integration.go per vedere come vengono usati il client HTTP e la dimensione dei batch. Riproduci il problema con go test -count=1 -run '^TestPosixMirrorIntegration$' -v ./integration/mirror/posix/ su macOS. Il lavoro è terminato quando il test limita le connessioni simultanee, riempie rapidamente i batch e passa in modo affidabile su macOS.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Go
Stelle
262
Fork
64
Merge medio
1g 6h
PR unite (30g)
20

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di transparency-dev/tessera

Tutte le issue di transparency-dev/tessera

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.