ChristophBaierATB commented on issue #470:
URL: https://github.com/apache/apisix-docker/issues/470#issuecomment-1633956607

   ## Reproduction of the Bug
   
   ### Minimal Setup
   
   Create these two files in the same directory:
   
   1. docker-compose.yml
   
      ```yaml
      version: "3"
      services:
        etcd:
          image: bitnami/etcd:3.4.15
          container_name: etcd
          environment:
            ETCD_ENABLE_V2: "true"
            ALLOW_NONE_AUTHENTICATION: "yes"
            ETCD_ADVERTISE_CLIENT_URLS: "http://etcd:2379";
            ETCD_LISTEN_CLIENT_URLS: "http://0.0.0.0:2379";
      
        apisix:
          image: apache/apisix:3.3.0-debian
          container_name: apisix
          depends_on:
            - etcd
          volumes:
            - ./config.yaml:/usr/local/apisix/conf/config.yaml:ro
      ```
   
   2. config.yaml
   
      ```yaml
      deployment:
        etcd:
          host:
            - "http://etcd:2379";
          prefix: "/apisix"
          timeout: 30
      ```
   
   Start the setup:
   
   ```bash
   docker-compose up -d
   ```
   
   Both services should start successfully.
   
   
   
   ### Trigger the Bug
   
   ```bash
   docker kill apisix # simulate host crash
   docker-compose up -d # start the container again 
   docker logs apisix
   ```
   
   Output:
   
   ```
   ...
   2023/07/13 09:41:38 [emerg] 1#1: bind() to 
unix:/usr/local/apisix/conf/config_listen.sock failed (98: Address already in 
use)
   nginx: [emerg] bind() to unix:/usr/local/apisix/conf/config_listen.sock 
failed (98: Address already in use)
   ...
   ```
   
   
   
   ### Possible Explanation
   
   * When APISIX container starts, it creates a lock file for 
`config_listen.sock`, indicating that it is already in use. This prevents 
multiple APISIX processes from starting and accessing this socket at the same 
time. When the container is gracefully stopped (e.g. via `docker stop apisix`), 
this lock file is deleted. When the APISIX container is restarted (e.g. via 
`docker start apisix`), it can create a new lock file, so no problem.
   * When APISIX container is shut down by force, e.g. by a host crash 
(simulated by `docker kill apisix`), the container will not shut down 
gracefully and the lock file will not be deleted. It persists within the docker 
container. When the host is rebooted and the APISIX container is started again, 
APISIX will try to create a lock file, but since such a file already exists, 
APISIX will think that the socket is already in use, leading to the above error 
message.
   
   
   
   ### Workaround Solution
   
   It is possible to simply delete the container and start a new one that does 
not contain the lock file.
   
   ```bash
   docker rm -f apisix
   docker-compose up -d
   ```
   
   However, this will not solve the problem, as it will recur every time the 
host crashes and restarts.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to