Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

174
Visualizações
Postgres is stuck when creating a database?

I just installed Postgres on Ubuntu 20 on WSL. Both of the following are stuck forever:

CREATE DATABASE foo
WITH
OWNER = postgres      
ENCODING = 'UTF8'     
CONNECTION LIMIT = -1;

And:

sudo -u postgres createdb foo

The log doesn't have anything:

postgres@postgres ERROR:  canceling statement due to user request
postgres@postgres STATEMENT:  CREATE DATABASE foo
            WITH
            OWNER = postgres
            ENCODING = 'UTF8'
            CONNECTION LIMIT = -1;

What are some possible causes for this?

Restarting Postgres or restarting the computer doesn't help and there's no locks. I also tried manually killing every lock.

over 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

While the statement is hanging, connect to the postgres database and look in pg_stat_activity for the wait_event and wait_event_type of the hanging connection.

Very likely it is waiting for a lock. In that case, end the transaction that is holding the lock.

over 4 years ago · Santiago Trujillo Relatório

0

take a look of

select * from pg_stat_activity sa inner join pg_locks l on sa.pid = l.pid

In my case I use wsl and get lock by AccessShareLock
its more a problem with wsl than postgresql

over 4 years ago · Santiago Trujillo Relatório

0

I had the same issue with you. It seems that it has to do with the wsl version. I was running wsl 1 so I had to uninstall ubuntu 20.04 wsl, then set the verion to 2 with the following command

wsl --set-default-version 2

and then install ubuntu 20.04 wsl again. Now everything seems to be in order and I am able to create databases with no issues.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda