Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker for M1 Mac Hanging with Postgres SQL File Execution #5830

Closed
3 tasks done
justinl-y opened this issue Jul 7, 2021 · 7 comments
Closed
3 tasks done

Docker for M1 Mac Hanging with Postgres SQL File Execution #5830

justinl-y opened this issue Jul 7, 2021 · 7 comments

Comments

@justinl-y
Copy link

justinl-y commented Jul 7, 2021

  • I have tried with the latest version of Docker Desktop
  • I have tried disabling enabled experimental features
  • I have uploaded Diagnostics
  • Diagnostics ID: 312CA59A-2EC7-4215-A7E3-F364AC6F5B71/20210707205114

Expected behavior

I have a three container setup for web api local testing using Docker Compose. These containers are an api container, integration tests container and a DB container. My problem is with the DB container run.

The DB container is a local postgres instance that follows the Initialization Scripts setup in https://hub.docker.com/_/postgres/. A Dockerfile is used as the base for this process and what it is doing is creating an instance of Postgres with a series of sql files run to create tables and other objects in the new database. The Dockerfile:

# postgis uses the official postgres image internally
FROM postgis/postgis:11-2.5

ENV POSTGRES_DB=test_template
ENV POSTGRES_USER=test
ENV POSTGRES_PASSWORD=test

# The official Postgres Docker image (https://hub.docker.com/_/postgres/) will run initialization & sql scripts found in the /docker-entrypoint-initdb.d/ folder
# create and move into docker-entrypoint-initdb.d
WORKDIR /docker-entrypoint-initdb.d

# copy files in /schema to this dir.
# .sh &.sql will also be auto-run!
COPY schema/* ./

WORKDIR /

The expected behaviour here is that the database instance will be created and started and then the schema sql files iterated through and executed running the DDL needed to populate objects within the database.

With the intel version of Docker for Mac this works perfectly.

Actual behavior

What is happening with the M1 version of Docker for Mac is that after the DB is created, the .sh/.sql files start to be iterated through and executed, then stop at a random file where Docker then hangs indefinitely.

The following is an error log from this exception:

db_1    | psql:/docker-entrypoint-initdb.d/9999999990-permissions-grp_ai_ml_tasks.sql:41: WARNING:  terminating connection because of crash of another server process
db_1    | DETAIL:  The postmaster has commanded this server process to roll back the current transaction and exit, because another server process exited abnormally and possibly corrupted shared memory.
db_1    | HINT:  In a moment you should be able to reconnect to the database and repeat your command.
db_1    | 2021-07-07 21:16:01.748 UTC [111] LOG:  all server processes terminated; reinitializing
db_1    | psql:/docker-entrypoint-initdb.d/9999999990-permissions-grp_ai_ml_tasks.sql:41: server closed the connection unexpectedly
db_1    | 	This probably means the server terminated abnormally
db_1    | 	before or while processing the request.
db_1    | psql:/docker-entrypoint-initdb.d/9999999990-permissions-grp_ai_ml_tasks.sql:41: connection to server was lost

Information

  • Is it reproducible? Yes

  • Is the problem new? The problem is new with the M1 MacBooks in my organization

  • Did the problem appear with an update? Unknown

  • macOS Version: 11.0.1

  • Intel chip or Apple chip: M1 Apple chip

  • Docker Desktop Version: v20.10.7

Steps to reproduce the behavior

@hmaesta
Copy link

hmaesta commented Jul 8, 2021

Maybe related to #5407?

@rfay
Copy link

rfay commented Jul 12, 2021

This is more likely a duplicate of #5590, but that one is intermittent, and it sounds like this one happens every time?

@rfay
Copy link

rfay commented Jul 12, 2021

However, you'll note that the postgis/postgis image is amd64 only, so you're running it in emulation. You'll probably want to try your work with the official postgres image, which has arm64 images.

Essentially, although Docker does its best to do cross-platform emulation, it's a bad idea to use it. It adds complexity in any number of ways, and also hurts performance.

@justinl-y
Copy link
Author

@rfay Thanks for the replies.

The problem happens every time with the iteration through SQL files but at a different SQL file in the series.

I've tested this subsequent to my post above with arm64 compatible images such as duvel/postgis:12-2.5 and also by setting the platform: linux/amd64 variable in Docker Compose. Both had no effect with the same problem as before. I'm inclined to think this isn't something to do with the postgres postgis images.

@rfay
Copy link

rfay commented Jul 12, 2021

Anyway, as in #5590 I see hang (arm64 only, M1 only) regularly but intermittently.

Setting platform/amd64 is exactly what you don't want to do. You want the arm64 images, which you'd get automatically from duvel/postgis:12-2.5.

But I certainly agree that the hang shouldn't happen and hope it can get some attention and a fix.

@docker-robott
Copy link
Collaborator

Issues go stale after 90 days of inactivity.
Mark the issue as fresh with /remove-lifecycle stale comment.
Stale issues will be closed after an additional 30 days of inactivity.

Prevent issues from auto-closing with an /lifecycle frozen comment.

If this issue is safe to close now please do so.

Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows.
/lifecycle stale

@docker-robott
Copy link
Collaborator

Closed issues are locked after 30 days of inactivity.
This helps our team focus on active issues.

If you have found a problem that seems similar to this, please open a new issue.

Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows.
/lifecycle locked

@docker docker locked and limited conversation to collaborators Dec 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants