bug: ECS CreateService livelocks under concurrent awsvpc + fixed hostPort (docker_utils port-status ReadTimeoutError) #43
manishahluwalia
started this conversation in
Bugs
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Summary
When creating multiple ECS services concurrently (as Terraform/OpenTofu
applydoes), each usingnetworkMode: awsvpcwith a fixed (non-zero)hostPortinportMappings, LocalStack Pro's ECS task-placement subsystem livelocks.CreateServiceAPI bookkeeping can succeed (services appear inlist-services)pendingCountLocalStack logs show a tight loop of container remove + port-status checks timing out on the Docker Unix socket (
localstack.utils.docker_utils/docker_sdk_client), with host CPU ~1% (I/O serialization, not host starvation).Secondary symptoms after client timeout + retry (downstream of the same livelock):
The given port (Port(port=N, protocol='tcp')) is already reserved.The given port (Port(port=N, protocol='tcp')) is already in use.Environment
localstack/localstack-pro:2026.07.0(also observed on olderlatest→4.8.2.dev35, and on2026.4.0-arm64)/var/run/docker.sockmounted; default Docker executorecs,ec2,logs,iam,stsMinimal reproduction (no application code)
awsvpc+ fixedhostPort8081–8093:{ "family": "repro-task-8081", "networkMode": "awsvpc", "requiresCompatibilities": ["FARGATE"], "cpu": "256", "memory": "512", "containerDefinitions": [{ "name": "repro-container-8081", "image": "public.ecr.aws/nginx/nginx:alpine", "essential": true, "portMappings": [{"containerPort": 8081, "hostPort": 8081, "protocol": "tcp"}] }] }Observed result
All 13 concurrent calls hang ~180s then fail uniformly with client read timeout. Services exist in
list-services, but zero corresponding Docker containers start even after 7+ minutes.A single isolated
create-service(no concurrency) completes and starts its container in ~10–40s. The failure mode is concurrency-triggered.Root cause evidence from LocalStack logs
This repeats across concurrent task placements sharing what appears to be an undersized/serialized Docker Unix-socket client pool.
Notes
localstack.utils.docker_utils/docker_sdk_clientawsvpc+ fixedhostPortbecause LocalStack must inspect containers to verify bound host portsaws_ecs_serviceagainst LocalStack (-parallelism=1/2)All reactions