edgedb / edgedb-docker

Official Docker Image packaging for EdgeDB
83 stars 16 forks source link

Minimal docker-compose setup fails to start up on M1 Mac #24

Open mikeyhew opened 3 years ago

mikeyhew commented 3 years ago

This is my docker-compose.yml file:

version: "3.9"  # optional since v1.27.0
services:
  edgedb:
    image: edgedb/edgedb:nightly
    environment:
      - EDGEDB_PASSWORD=edgedb

When I run docker compose up, I get this output:

docker compose up
[+] Running 2/1
 ⠿ Network sharestuff_default     Created                                                                                                                                                              3.7s
 ⠿ Container sharestuff_edgedb_1  Created                                                                                                                                                              0.0s
Attaching to edgedb_1
edgedb_1  | Bootstrapping EdgeDB instance on the local volume...
edgedb_1  | INFO 51 2021-07-12 04:52:36,209 edb.server: EdgeDB server (1.0-beta.3+dev5728.d2021071200.gba528d9cf.cv202107020000) starting.
edgedb_1  | INFO 51 2021-07-12 04:52:38,462 edb.server: Using 19 max backend connections based on total memory.
edgedb_1  | INFO 51 2021-07-12 04:52:38,545 edb.server.pgcluster: Initializing database cluster in /var/lib/edgedb/data
edgedb_1  | INFO 51 2021-07-12 04:52:42,412 edb.server: Creating template database...
edgedb_1  | INFO 51 2021-07-12 04:52:43,190 edb.server: Creating the necessary PostgreSQL extensions...
edgedb_1  | INFO 51 2021-07-12 04:52:43,205 edb.server: Initializing the standard library...
edgedb_1  | ERROR: Server socket did not appear within 120 seconds.
edgedb_1  | /usr/local/bin/docker-entrypoint-funcs.sh: line 599: kill: (53) - No such process
edgedb_1  | ERROR: Could not bootstrap EdgeDB server instance.
edgedb_1 exited with code 1
elprans commented 3 years ago

Hi @mikeyhew! What system are you running this on?

mikeyhew commented 3 years ago

Hi @elprans! I'm running on an M1 mac with Big Sur 11.4, using Docker Desktop for Mac. I don't know any reason why it would behave differently on other systems though - were you able to reproduce it?

docker --version gives me:

Docker version 20.10.6, build 370c289
elprans commented 3 years ago

Can't reproduce on an Intel Mac, so this might be related to x86 emulation on m1, as we don't have native builds for it at the moment.

elprans commented 3 years ago

That said, non-docker installation method (via the edgedb CLI) should work on m1.

mikeyhew commented 3 years ago

Can't reproduce on an Intel Mac, so this might be related to x86 emulation on m1, as we don't have native builds for it at the moment.

@elprans ok thanks for that info. I'll see if I can get some time later to debug this some more. Do you have any ideas of things I could check to try to figure out why the server socket isn't showing up?

elprans commented 3 years ago

My best guess would be that it's either too slow due to Docker virtualization on macOS on M1 or that things are crashing weirdly.

I'd start by adding a bunch of verbose logging:

docker run --rm -it -e EDGEDB_DOCKER_TRACE=1 -e EDGEDB_EXTRA_ARGS="--log-level=debug" -e EDGEDB_DEBUG_SERVER=1 -e EDGEDB_DEBUG_PGSERVER=1 -e EDGEDB_PASSWORD=foo edgedb/edgedb:nightly | tee log.txt

Please compress the resulting log.txt and attach here.

mikeyhew commented 3 years ago

Here is the log from running that command: log.txt.gz

This might actually be the first docker dependency that I've used since getting my M1 Mac that didn't have an arm64 build, so it's possible that there's issues with the x86_64 emulation that I just haven't encountered yet. If that's the case then it might be worth trying to build this locally for arm64 - would that be possible, and if so what is the correct docker incantation to run once I've cloned this repo?

elprans commented 3 years ago

From the log it seems like it's just taking longer than the timeout. I'll respin the image making that timeout configurable via an env var.

mikeyhew commented 3 years ago

To me, based on the log it looks like nothing is happening for the last 110 seconds of the 120 second timeout, so i wouldn't expect increasing the timeout to help. I could be missing something though

elprans commented 3 years ago

nothing is happening for the last 110 seconds

Does top confirm this?

mikeyhew commented 3 years ago

Good question. I can't do it right now, but I'll check this weekend.

mikeyhew commented 3 years ago

@elprans yes, running docker exec -it <container> top shortly after starting the docker run command, I see close to 100% CPU usage, and then it reduces down to about 1% after the last "real" logs are emitted.

By "real" logs, I mean anything other than this

+ for i in $(seq 1 $(($timeout / $retry_period)))
+ sleep 5
+ '[' ']'

Which is repeated 22 times at the end, without any other logs in between. That's where I got the 110 seconds from.

mikeyhew commented 3 years ago

@elprans how hard would it be to create an arm64 version of this image? i think ultimately that would be the best solution, since even if we could get the x86_64 version working, it would still be running under emulation and less performant than a native image.

If that's not feasible, then it might make sense to look into getting the x86_64 version working, but it could be there's some obscure bug that happens when running x86_64 containers in emulation in Docker for Mac on M1 Macs that's just not worth trying to track down, whereas having an arm64 version of the image would be more widely beneficial.

limx0 commented 2 years ago

+1 I'm also seeing this issue - unable to docker install or native on my M1 mac. This is for both beta3 and the nightly build.

Is there a way to turn on debug logging for the native install?

tailhook commented 2 years ago

Is there a way to turn on debug logging for the native install?

You can try RUST_LOG=debug edgedb server install. And also edgedb server _detect

limx0 commented 2 years ago

Thanks @tailhook. I realised this is the docker repo so I've opened https://github.com/edgedb/edgedb/issues/2940 instead.