[Bug]: sbx proxy serialises container creates, including ones that will conflict
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 48/100
Research direction
Start with modules/sbx/leases.go, especially portManager.prepareCreate and abortCreate, then inspect the sbx Docker API proxy path that handles container creates. Trace how allocationMu is held around port allocation and cleanup, and compare the proxy's conflict response with Docker's. Done when conflicting concurrent creates fail fast without delaying other creates and TestReaper_ReuseRunning succeeds under sbx.
Written by the indexing model from the issue text.
Description
Testcontainers version
v0.46.0 (main)
Using the latest Testcontainers version?
Yes
Host OS
Linux, GitHub Actions ubuntu-24.04 runners in the Test core using sbx jobs
Host arch
x86_64
Go version
1.26.10 and 1.27.3
Docker version
sbx v0.51.0 (docker-sbx 0.51.0-1~ubuntu.24.04~noble), sandbox Engine 29.9.2
Docker info
Operating System: Docker Hardened Images/Debian GNU/Linux 13 (trixie) (containerized)
What happened?
Under the sbx runtime, concurrent container creates are handled one at a time by the sbx module's Docker API proxy, including creates that Docker will reject on a name conflict. This makes TestReaper_ReuseRunning fail intermittently under sbx, and slows down any processes that create containers concurrently.
Every create first goes through portManager.prepareCreate (modules/sbx/leases.go), which holds allocationMu while it lists the engine's ports and runs sbx ports <sandbox> --publish ... for each port, before the request reaches Docker. When Docker then rejects the create, for example on a name conflict, abortCreate takes allocationMu again to release the ports. Each such create therefore costs a serialised round of sbx CLI calls, about 250 to 500ms in CI, and every other create waits behind it.
TestReaper_ReuseRunning starts 64 spawners at once, standing in for 64 test processes, so 63 lose the race to create the session's reaper. Each loser only gets to reuse the reaper once its own create has been rejected, so they get it at about two to four a second. The winning reaper's start waits on the same lock, taking 6 to 10 seconds, and the spawners give up after their 20 second retry budget. Across the sbx runs in #4095 and #4097, the test passed when that worked out to about 0.3s per spawner, with all 64 getting the reaper, and failed at about 0.5s per spawner, with only 36 getting it in time. Halving the Docker API requests each reuse makes (#3868) did not change the rate, so it isn't the request count.
The proxy could reject such creates before reserving ports, for example by checking that the container name isn't already in use and returning Docker's conflict straight away, or avoid holding allocationMu across the CLI call. Either would make the losing creates fail fast and stop them delaying the others.
Relevant log output
TestReaper_ReuseRunning (Go 1.27.x, sbx), 64 spawners:
22:07:59 64 x Creating container for image testcontainers/ryuk:0.14.0
22:07:59 Container created: <reaper>
22:08:09 Container started: <reaper>
22:08:09 .. 22:08:18 Reaper obtained, about 4 a second, 35 in total
new reaper: run container: container create: Error response from daemon: Conflict. The container name "/reaper_<session>" is already in use by container "<reaper>". You have to remove (or rename) that container to be able to reuse that name.
FAIL TestReaper_ReuseRunning (36.26s)
Additional information
@mdelapenya, as this is in the sbx proxy added in #3987, could you take a look? #4097 lowers TestReaper_ReuseRunning's concurrency to 32 under sbx as a workaround until the proxy is fixed. The other sbx CI failures are tracked in #4096.
- Dominant language
- Go
- Stars
- 5k
- Forks
- 660
- Avg merge
- 3d 11h
- Merged PRs (30d)
- 48
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- Has a 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 testcontainers/testcontainers-go
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
testcontainers/testcontainers-go#4143 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
testcontainers/testcontainers-go#4142 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
testcontainers/testcontainers-go#4120 · 1 comment ·
Maintainers usually reply within 1 day
-
[Bug]: `DockerImageAuth` fails in FIPS 140-only mode: `configKey` uses `crypto/md5`, so image pulls fall back to empty credentialsPossibly taken @spor3006 claimed this 27 days ago. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
testcontainers/testcontainers-go#4080 · 2 comments ·
Maintainers usually reply within 1 day
-
[Bug]: root module still requires vulnerable github.com/moby/go-archive v0.2.0 (GHSA-hfg8-hc9c-6c3h)Open
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
testcontainers/testcontainers-go#3913 · 1 comment · 6 reactions ·
Maintainers usually reply within 1 day
All issues in testcontainers/testcontainers-go
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Maintainers usually reply within 1 day
-
clawsweeper:fix-shape-clear clawsweeper:queueable-fix clawsweeper:source-repro impact:other issue-rating: 🦞 diamond lobster no-stale P2
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
openclaw/crabbox#3249 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
ec2-subnet, security-group and internet-gateway skip all resources when one is deleted during the scanPossibly taken @toabctl claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
gruntwork-io/cloud-nuke#1208 ·
Maintainers usually reply within 5 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
snowflakedb/gosnowflake#1872 ·