supabase / postgres-meta

A RESTful API for managing your Postgres. Fetch tables, add roles, and run queries
https://supabase.com
Apache License 2.0
911 stars 121 forks source link

Stopping the container is slow, resorting to SIGKILL #663

Closed nykula closed 8 months ago

nykula commented 10 months ago

Bug report

Describe the bug

Stopping the postgres-meta container takes more than 10 seconds every time and prints a warning, unlike the postgres and postgrest containers, which stop immediately and print nothing.

To Reproduce

On a clean Fedora 39 system without other containers, install podman and podman-compose, then run the following script as user. The postgrest service without access control is there to show that the issue doesn't affect it, only postgres-meta.

#!/bin/bash
set -e
rm -rf ~/postgres-meta-slow-stop
mkdir ~/postgres-meta-slow-stop
cd ~/postgres-meta-slow-stop

cat >docker-compose.yaml <<'EOF'
version: '3'

services:
  db:
    image: docker.io/postgres
    environment:
      POSTGRES_PASSWORD: $POSTGRES_PASSWORD

  rest:
    image: docker.io/postgrest/postgrest
    ports:
      - 3000:3000
    environment:
      PGRST_DB_URI: postgres://postgres:$POSTGRES_PASSWORD@db:5432/postgres
      PGRST_DB_ANON_ROLE: postgres
    depends_on:
      - db

  meta:
    image: docker.io/supabase/postgres-meta:v0.75.0
    environment:
      PG_META_DB_URL: postgres://postgres:$POSTGRES_PASSWORD@db:5432/postgres
    depends_on:
      - db
EOF

POSTGRES_PASSWORD=password podman-compose up -d

podman exec -i "$(podman ps -aqf name=_db)" psql -U postgres <<EOF
create table person(id uuid primary key, name text);
notify pgrst, 'reload schema';
EOF

podman exec -i "$(podman ps -aqf name=_meta)" env PG_META_GENERATE_TYPES=typescript node dist/server/server.js >database.ts
podman-compose down

Expected behavior

The postgres-meta container should take at most 1 second to stop, like postgrest and postgres, and print no warning.

Screenshots

Relevant part of the output of the commands run by the script above:

podman stop -t 10 postgres-meta-slow-stop_meta_1
WARN[0010] StopSignal SIGTERM failed to stop container postgres-meta-slow-stop_meta_1 in 10 seconds, resorting to SIGKILL 
postgres-meta-slow-stop_meta_1
exit code: 0

System information

Additional context

The Silverblue clarification isn't relevant here I think, on Debian the stop was also slow. But the reason I use the container at all, rather than the npm package, is that installing the dependencies of the npm package throws an error on Silverblue: https://github.com/pyramation/libpg-query-node/issues/25