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

install postgresql issue #61

Closed
jiangjianxiao opened this issue Apr 8, 2016 · 80 comments
Closed

install postgresql issue #61

jiangjianxiao opened this issue Apr 8, 2016 · 80 comments

Comments

@jiangjianxiao
Copy link

pg_createcluster 9.5 main --start

Creating new cluster 9.5/main ...
  config /etc/postgresql/9.5/main
  data   /var/lib/postgresql/9.5/main
  locale en_US.UTF-8
FATAL:  could not create shared memory segment: Invalid argument
DETAIL:  Failed system call was shmget(key=1, size=56, 03600).
HINT:  This error usually means that PostgreSQL's request for a shared memory segment exceeded your kernel's SHMMAX parameter, or possibly that it is less than your kernel's SHMMIN parameter.
        The PostgreSQL documentation contains more information about shared memory configuration.
child process exited with exit code 1
initdb: removing contents of data directory "/var/lib/postgresql/9.5/main"
Error: initdb failed

sysctl -w kernel.shmmax=1
sysctl: cannot stat /proc/sys/kernel/shmmax: No such file or directory

@filipeaguiar
Copy link

I had the same error yesterday. It appears that writing on some folders or creating symlinks are problematic in WSL right now.

@jwsloan
Copy link

jwsloan commented Apr 14, 2016

Has anyone found a workaround for this?

@yjwong
Copy link

yjwong commented Apr 23, 2016

Seems like there's no proper System V shared memory support at the moment.

@Nilotaviano
Copy link

No workouronds yet?

@mrenigma
Copy link

mrenigma commented Jun 7, 2016

Same issue here with build 14352.rs1_release.160522-1930. Any fixes on this yet? It's the final piece of the puzzle for my workflow!

Output below:

rob@DESKTOP-NQ3AL5E:~$ sudo apt-get install postgresql postgresql-common
[sudo] password for rob:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libossp-uuid16 libxslt1.1 os-prober
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
  postgresql-9.3 postgresql-client-9.3 postgresql-client-common
Suggested packages:
  oidentd ident-server locales-all postgresql-doc-9.3
The following NEW packages will be installed:
  postgresql postgresql-9.3 postgresql-client-9.3 postgresql-client-common
  postgresql-common
0 upgraded, 5 newly installed, 0 to remove and 40 not upgraded.
Need to get 0 B/3,603 kB of archives.
After this operation, 15.2 MB of additional disk space will be used.
Preconfiguring packages .../n] y
E: Can not write log (Is /dev/pts mounted?) - openpty (2: No such file or directory)
Selecting previously unselected package postgresql-client-common.
(Reading database ... 32749 files and directories currently installed.)
Preparing to unpack .../postgresql-client-common_154ubuntu1_all.deb ...
Unpacking postgresql-client-common (154ubuntu1) ...
Selecting previously unselected package postgresql-client-9.3.
Preparing to unpack .../postgresql-client-9.3_9.3.13-0ubuntu0.14.04_amd64.deb ...
Unpacking postgresql-client-9.3 (9.3.13-0ubuntu0.14.04) ...
Selecting previously unselected package postgresql-common.
Preparing to unpack .../postgresql-common_154ubuntu1_all.deb ...
Adding 'diversion of /usr/bin/pg_config to /usr/bin/pg_config.libpq-dev by postgresql-common'
Unpacking postgresql-common (154ubuntu1) ...
Selecting previously unselected package postgresql-9.3.
Preparing to unpack .../postgresql-9.3_9.3.13-0ubuntu0.14.04_amd64.deb ...
Unpacking postgresql-9.3 (9.3.13-0ubuntu0.14.04) ...
Selecting previously unselected package postgresql.
Preparing to unpack .../postgresql_9.3+154ubuntu1_all.deb ...
Unpacking postgresql (9.3+154ubuntu1) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Processing triggers for ureadahead (0.100.0-16) ...
Setting up postgresql-client-common (154ubuntu1) ...
Setting up postgresql-client-9.3 (9.3.13-0ubuntu0.14.04) ...
update-alternatives: using /usr/share/postgresql/9.3/man/man1/psql.1.gz to provide /usr/share/man/man1/psql.1.gz (psql.1.gz) in auto mode
Setting up postgresql-common (154ubuntu1) ...

Creating config file /etc/logrotate.d/postgresql-common with new version
Building PostgreSQL dictionaries from installed myspell/hunspell packages...
Removing obsolete dictionary files:
runlevel:/var/run/utmp: No such file or directory
invoke-rc.d: policy-rc.d denied execution of start.
Processing triggers for ureadahead (0.100.0-16) ...
Setting up postgresql-9.3 (9.3.13-0ubuntu0.14.04) ...
Creating new cluster 9.3/main ...
  config /etc/postgresql/9.3/main
  data   /var/lib/postgresql/9.3/main
  locale C
FATAL:  could not create shared memory segment: Function not implemented
DETAIL:  Failed system call was shmget(key=1, size=48, 03600).
child process exited with exit code 1
initdb: removing contents of data directory "/var/lib/postgresql/9.3/main"
Error: initdb failed
Error: could not create default cluster. Please create it manually with

  pg_createcluster 9.3 main --start

or a similar command (see 'man pg_createcluster').
update-alternatives: using /usr/share/postgresql/9.3/man/man1/postmaster.1.gz to provide /usr/share/man/man1/postmaster.1.gz (postmaster.1.gz) in auto mode
runlevel:/var/run/utmp: No such file or directory
invoke-rc.d: policy-rc.d denied execution of start.
Setting up postgresql (9.3+154ubuntu1) ...
rob@DESKTOP-NQ3AL5E:~$ sudo pg_createcluster 9.3 main --start
Creating new cluster 9.3/main ...
  config /etc/postgresql/9.3/main
  data   /var/lib/postgresql/9.3/main
  locale en_US.UTF-8
FATAL:  could not create shared memory segment: Function not implemented
DETAIL:  Failed system call was shmget(key=1, size=48, 03600).
child process exited with exit code 1
initdb: removing contents of data directory "/var/lib/postgresql/9.3/main"
Error: initdb failed

@threebyeight
Copy link

Still waiting on this.

@the-ult
Copy link

the-ult commented Jun 14, 2016

One of the things holding me from developing on windows with Ruby.

@the-ult
Copy link

the-ult commented Jun 17, 2016

So you don't get an error while installing postgres on WSL?

Which version of postgres are you using?

Or do you mean the combination of postgres on Windows and Ruby on WSL works great?
I thought programs on Windows are not accessible from WSL.
So I figured, the same would go for a rails server using postgres...

@the-ult
Copy link

the-ult commented Jun 17, 2016

Thanks, didn't think of it that way.
Gonna try it out.

Op vr 17 jun. 2016 23:05 schreef SRGOM [email protected]:

The combination. You don't use postgres as a process, you access it over a
port so there should be no issues there


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#61 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AEo0Vj99_9zBZtrF5rFHiLNe6_bqnT9rks5qMwwOgaJpZM4IC15g
.

met vriendelijke groet,
Arjen

M 06-51 800 419
W www.payt.nl

@alexfromvl
Copy link

I got the same error on a new release - build 14367.rs1_release.160613-1700. Can anyone find a solution?

@threebyeight
Copy link

Someone has to implement that call to the kernel.

@glebovsky
Copy link

Hi!

Can someone please describe how to connect to postgres on the host, like @SRGOM mentioned?

Thanks!

@jwsloan
Copy link

jwsloan commented Jun 22, 2016

I am successfully connecting my Rails app running in WSL to Postgres on Windows. I don't recall doing anything special to make that happen.

@glebovsky
Copy link

@SRGOM Thanks! Just tried it and it works perfectly.

@alexfromvl
Copy link

@SRGOM Thank you. When installing Postgres on Windows normally. You can consider this alternative, until they make proper implementation in bash.
Recipe for those who have problems:

  1. Set Postgres for Windows.
  2. Start the server Postgres.
  3. Connect to the database server, as is usually done in the unix;

@pavelbulanov
Copy link

pavelbulanov commented Jul 14, 2016

For records, I'm receiving the same issue on Build 14372.rs1_release.160620-2343, trying to create cluster after installation of postgresql 9.4

$ sudo pg_createcluster 9.4 main
Creating new cluster 9.4/main ...
config /etc/postgresql/9.4/main
data /var/lib/postgresql/9.4/main
locale en_US.UTF-8
FATAL: could not create shared memory segment: Function not implemented
DETAIL: Failed system call was shmget(key=1, size=56, 03600).
child process exited with exit code 1
initdb: removing contents of data directory "/var/lib/postgresql/9.4/main"
Error: initdb failed

@aborruso
Copy link

I have the same error of @pavelbulanov (in italian):

Creating new cluster 9.3/main ...
  config /etc/postgresql/9.3/main
  data   /var/lib/postgresql/9.3/main
  locale it_IT.UTF-8
FATALE:  creazione del segmento di memoria condivisa fallita: Funzione non implementata
DETTAGLI:  La chiamata di sistema fallita era shmget(key=1, size=48, 03600).
processo figlio uscito con codice di uscita 1
initdb: rimozione dei contenuti della directory dati "/var/lib/postgresql/9.3/main"
Error: initdb failed

@darrenmason
Copy link

darrenmason commented Aug 3, 2016

Still unable to install postgres with build 14393.10:

Setting up postgresql-common (154ubuntu1) ...
initctl: Unable to connect to Upstart: Failed to connect to socket /com/ubuntu/upstart: Connection refused
runlevel:/var/run/utmp: No such file or directory
invoke-rc.d: policy-rc.d denied execution of start.
Setting up postgresql-9.3 (9.3.13-0ubuntu0.14.04) ...
update-alternatives: using /usr/share/postgresql/9.3/man/man1/postmaster.1.gz to provide /usr/share/man/man1/postmaster.1.gz (postmaster.1.gz) in auto mode
initctl: Unable to connect to Upstart: Failed to connect to socket /com/ubuntu/upstart: Connection refused

@threebyeight
Copy link

I can think of at least a couple of reasons I don't want Postgres running on Windows and one involves just not wanting the service constantly running in the background when it can be turned on/off by starting/stopping Bash; having to actually open up the services applet to shut it off/turn it on is kind of inconvenient when I'm only using it for the purpose of development. Two, I read that developers were talking about ending support for the Windows port on a mailing list because it's difficult to maintain.

Until this is fixed, I'm sticking with my virtual machine.

@threebyeight
Copy link

I think that, for me, it's just a matter of convenience. Right now, I unpause my VM and go. If I wanted to start using Bash I'd have to start the Postgres service and then start Bash because I would prefer not to have the service running in the background. Call me paranoid.

@bouvyd
Copy link

bouvyd commented Aug 3, 2016

I have Ubuntu 14.04 and Windows 10 on the same machine, and frankly my stack is waaaayyyyy slower in Windows 10 with the server code running in the shell and postgres installed on Windows.

I'm not sure yet what could be the cause of this:

  • windows psql install being generally slower than its unix counterpart
  • extra network layers caused by the fact that I can't connect to psql through a unix socket
  • something else entirely (maybe the shell integration layers themselves)

But I sure as hell would like to compare, because the difference is extremely noticeable.

@pavelbulanov
Copy link

@dbo-odoo, it's unlikely related with postgres, unfortunately - it more looks like overall slowdown in some kind of operations inside bash

if possible, try doing kind of hack for your app to not use db (use static stubs instead) and measure

for me, starting rails server (which doesn't do any postgresql queries) takes like 5-7 secs, comparing to 1-2 secs inside Ubuntu virtual machine (on the same hardware and with lack of resources for VM)

@aseering
Copy link
Contributor

aseering commented Aug 3, 2016

@dbo-odoo -- curious, can you quantify "extremely noticeable"? For you, is that like 20% slower? 100x slower?

@bouvyd
Copy link

bouvyd commented Aug 3, 2016

@pavelbulanov yeah that's not something I'm gonna be able to do easily, but if I do have time i'll test it

@aseering I'd say along the lines of 2-4x slower (as a gross estimation)

If I do some benchmark I'll post them here.

@alexssung
Copy link

I'm also experiencing significantly slower start up times for rails server. The report below shows benchmark results for bash on Windows, and apparently File IO performance can be over 6 times slower than on Ubuntu!

http://www.techrepublic.com/article/windows-10-how-well-does-it-run-ubuntu-bash/

@fpqc
Copy link

fpqc commented Aug 9, 2016

@alexssung yep, I believe @russalex said that the file i/o is the main bottleneck in his //build/ conference presentation

@valorad
Copy link

valorad commented Aug 10, 2016

I experienced the same issue, trying to install PostgreSQL 9.5 for my django. There was no error reported when installing, but something went wrong when creating database superuser and templates.

@pavelbulanov
Copy link

@FqPc, do you know if i/o slowdown is relevant to bash working with both file systems, VolFs and Windows f/s via mnt?

@fpqc
Copy link

fpqc commented Aug 10, 2016

@pavelbulanov the best place to ask would probably be in a new thread and ping russalex in it

@russalex
Copy link
Contributor

Happy to answer this one here.

The file system performance hit happens on both VolFs and DrvFs. VolFs may actually be slightly faster in some situations simply due to the amount of caching we do there, but in most cases the perf will be very similar between the two.

Throwing a quick shout out to @SvenGroot's excellent file system blog post here. It does help explain a lot.

@diwu1989
Copy link

You probably don't want to run Postgres inside BashOnWindows anyways because of IO performance.

It's just plain simpler to run https://github.com/garethflowers/postgresql-portable on Windows side and connect via TCP on linux side

@olinbg
Copy link

olinbg commented Jan 10, 2017

@colinrubbert This worked great for me, thanks.

Very minor edit - I think you meant "postgresql-client" not "postgres-client"

@colinrubbert
Copy link

thanks @olinbg I will fix it. Must've just been speed typing 😄

@steveklabnik
Copy link

Came to this issue, found the workaround, works great 👍

@arjennienhuis
Copy link

arjennienhuis commented Jan 15, 2017

With build 15007 postgres works. The shared memory works.

What doesn't seem to work is the UNIX socket.

It starts and you can connect to it using TCP. To log in you first need to edit pg_hba.conf and enable 'trust' for 127.0.0.1

@wbrianwhite
Copy link

This bug isn't assigned to anyone, but can be closed per the above comment.

https://blogs.msdn.microsoft.com/commandline/2017/01/09/bash-in-windows-insider-build-15002-many-fixes-but-a-couple-of-bugs/

Along with support for the following shared-memory syscalls which are widely used by a number of Linux tools including PostgreSQL.

shmctl
shmget
shmdt
shmat

@arjennienhuis
Copy link

Is there a separate issue for the UNIX socket not working?

@sunilmut
Copy link
Member

@arjennienhuis - Thanks for the validation and the post. Can you provide more specifics with what is not working with UNIX sockets? Targeted repro steps are very useful.

@arjennienhuis
Copy link

arjen@DESKTOP-PVQK426:/mnt/c/Users/Arjen$ sudo apt install postgresql-9.5
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  libpq5 libsensors4 libxslt1.1 postgresql-client-9.5 postgresql-client-common postgresql-common
  postgresql-contrib-9.5 ssl-cert sysstat
Suggested packages:
  lm-sensors locales-all postgresql-doc-9.5 libdbd-pg-perl openssl-blacklist isag
The following NEW packages will be installed:
  libpq5 libsensors4 libxslt1.1 postgresql-9.5 postgresql-client-9.5 postgresql-client-common postgresql-common
  postgresql-contrib-9.5 ssl-cert sysstat
0 upgraded, 10 newly installed, 0 to remove and 0 not upgraded.
Need to get 4,978 kB of archives.
After this operation, 20.0 MB of additional disk space will be used.
Do you want to continue? [Y/n]
Get:1 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libpq5 amd64 9.5.4-0ubuntu0.16.04 [77.8 kB]
Get:2 http://archive.ubuntu.com/ubuntu xenial/main amd64 libsensors4 amd64 1:3.4.0-2 [28.4 kB]
Get:3 http://archive.ubuntu.com/ubuntu xenial/main amd64 libxslt1.1 amd64 1.1.28-2.1 [145 kB]
Get:4 http://archive.ubuntu.com/ubuntu xenial/main amd64 postgresql-client-common all 173 [28.3 kB]
Get:5 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 postgresql-client-9.5 amd64 9.5.4-0ubuntu0.16.04 [860 kB]
Get:6 http://archive.ubuntu.com/ubuntu xenial/main amd64 ssl-cert all 1.0.37 [16.9 kB]
Get:7 http://archive.ubuntu.com/ubuntu xenial/main amd64 postgresql-common all 173 [153 kB]
Get:8 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 postgresql-9.5 amd64 9.5.4-0ubuntu0.16.04 [2,980 kB]
Get:9 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 postgresql-contrib-9.5 amd64 9.5.4-0ubuntu0.16.04 [446 kB]
Get:10 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 sysstat amd64 11.2.0-1ubuntu0.1 [243 kB]
Fetched 4,978 kB in 1s (3,139 kB/s)
Selecting previously unselected package libpq5:amd64.
(Reading database ... 25453 files and directories currently installed.)
Selecting previously unselected package libsensors4:amd64...........................................................]
Selecting previously unselected package libxslt1.1:amd64............................................................]
Selecting previously unselected package postgresql-client-common....................................................]
Selecting previously unselected package postgresql-client-9.5.......................................................]
Selecting previously unselected package ssl-cert....................................................................]
Selecting previously unselected package postgresql-common...........................................................]
Adding 'diversion of /usr/bin/pg_config to /usr/bin/pg_config.libpq-dev by postgresql-common'.......................]
Selecting previously unselected package postgresql-9.5.####.........................................................]
Selecting previously unselected package postgresql-contrib-9.5.##...................................................]
Selecting previously unselected package sysstat.######################..............................................]
Processing triggers for libc-bin (2.23-0ubuntu3) ...########################........................................]
Processing triggers for man-db (2.7.5-1) ...
Processing triggers for systemd (229-4ubuntu8) ...
Processing triggers for ureadahead (0.100.0-19) ...
update-alternatives: using /usr/share/postgresql/9.5/man/man1/psql.1.gz to provide /usr/share/man/man1/psql.1.gz (psql.1Adding user postgres to group ssl-cert###############################################################...............]

Creating config file /etc/postgresql-common/createcluster.conf with new version

Creating config file /etc/logrotate.d/postgresql-common with new version
Building PostgreSQL dictionaries from installed myspell/hunspell packages...
Removing obsolete dictionary files:
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/(?<!\\)\${ <-- HERE ([^}]+)}/ at /usr/sbin/pam_getenv line 78.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/(?<!\\)\${ <-- HERE ([^}]+)}/ at /usr/sbin/pam_getenv line 78.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/(?<!\\)\${ <-- HERE ([^}]+)}/ at /usr/sbin/pam_getenv line 78.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/(?<!\\)\${ <-- HERE ([^}]+)}/ at /usr/sbin/pam_getenv line 78.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/(?<!\\)\${ <-- HERE ([^}]+)}/ at /usr/sbin/pam_getenv line 78.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/(?<!\\)\${ <-- HERE ([^}]+)}/ at /usr/sbin/pam_getenv line 78.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/(?<!\\)\${ <-- HERE ([^}]+)}/ at /usr/sbin/pam_getenv line 78.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/(?<!\\)\${ <-- HERE ([^}]+)}/ at /usr/sbin/pam_getenv line 78.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/(?<!\\)\${ <-- HERE ([^}]+)}/ at /usr/sbin/pam_getenv line 78.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/(?<!\\)\${ <-- HERE ([^}]+)}/ at /usr/sbin/pam_getenv line 78.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/(?<!\\)\${ <-- HERE ([^}]+)}/ at /usr/sbin/pam_getenv line 78.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/(?<!\\)\${ <-- HERE ([^}]+)}/ at /usr/sbin/pam_getenv line 78.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/(?<!\\)\${ <-- HERE ([^}]+)}/ at /usr/sbin/pam_getenv line 78.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/(?<!\\)\${ <-- HERE ([^}]+)}/ at /usr/sbin/pam_getenv line 78.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/(?<!\\)\${ <-- HERE ([^}]+)}/ at /usr/sbin/pam_getenv line 78.
Creating new cluster 9.5/main ...
  config /etc/postgresql/9.5/main
  data   /var/lib/postgresql/9.5/main
  locale C
  socket /var/run/postgresql
  port   5432
update-alternatives: using /usr/share/postgresql/9.5/man/man1/postmaster.1.gz to provide /usr/share/man/man1/postmaster.1.gz (postmaster.1.gz) in auto mode
Progress: [ 96%] [###############################################################################################...]
Creating config file /etc/default/sysstat with new version
Processing triggers for libc-bin (2.23-0ubuntu3) ...###############################################################.]
Processing triggers for systemd (229-4ubuntu8) ...
arjen@DESKTOP-PVQK426:/mnt/c/Users/Arjen$
arjen@DESKTOP-PVQK426:/mnt/c/Users/Arjen$
arjen@DESKTOP-PVQK426:/mnt/c/Users/Arjen$
arjen@DESKTOP-PVQK426:/mnt/c/Users/Arjen$ psql
psql: could not connect to server: No such file or directory
        Is the server running locally and accepting
        connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
arjen@DESKTOP-PVQK426:/mnt/c/Users/Arjen$ pg_lsclusters
Ver Cluster Port Status Owner    Data directory               Log file
9.5 main    5432 down   postgres /var/lib/postgresql/9.5/main /var/log/postgresql/postgresql-9.5-main.log
arjen@DESKTOP-PVQK426:/mnt/c/Users/Arjen$ sudo lcluster 9.5 main start
The PostgreSQL server failed to start. Please check the log output:
2017-01-17 21:00:49 STD [2474-1] LOG:  database system was shut down at 2017-01-17 20:59:36 STD
2017-01-17 21:00:49 STD [2474-2] LOG:  MultiXact member wraparound protections are now enabled
2017-01-17 21:00:49 STD [2478-1] LOG:  autovacuum launcher started
2017-01-17 21:00:49 STD [2473-1] LOG:  database system is ready to accept connections
2017-01-17 21:00:50 STD [2480-1] [unknown]@[unknown] LOG:  incomplete startup packet
2017-01-17 21:00:50 STD [2483-1] [unknown]@[unknown] LOG:  incomplete startup packet
2017-01-17 21:00:51 STD [2486-1] [unknown]@[unknown] LOG:  incomplete startup packet
2017-01-17 21:00:51 STD [2489-1] [unknown]@[unknown] LOG:  incomplete startup packet
2017-01-17 21:00:52 STD [2492-1] [unknown]@[unknown] LOG:  incomplete startup packet
2017-01-17 21:00:52 STD [2495-1] [unknown]@[unknown] LOG:  incomplete startup packet
2017-01-17 21:00:53 STD [2498-1] [unknown]@[unknown] LOG:  incomplete startup packet
2017-01-17 21:00:54 STD [2501-1] [unknown]@[unknown] LOG:  incomplete startup packet
2017-01-17 21:00:54 STD [2504-1] [unknown]@[unknown] LOG:  incomplete startup packet
2017-01-17 21:00:55 STD [2507-1] [unknown]@[unknown] LOG:  incomplete startup packet
2017-01-17 21:00:55 STD [2510-1] [unknown]@[unknown] LOG:  incomplete startup packet
2017-01-17 21:00:56 STD [2513-1] [unknown]@[unknown] LOG:  incomplete startup packet
arjen@DESKTOP-PVQK426:/mnt/c/Users/Arjen$ psql
psql: could not get socket error status: Invalid argument
arjen@DESKTOP-PVQK426:/mnt/c/Users/Arjen$ sudo sed -i s/md5$/trust/  /etc/postgresql/9.5/main/pg_hba.conf
arjen@DESKTOP-PVQK426:/mnt/c/Users/Arjen$ sudo pg_ctlcluster 9.5 main reload
arjen@DESKTOP-PVQK426:/mnt/c/Users/Arjen$ psql --host 127.0.0.1 --user postgres
psql (9.5.4)
SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off)
Type "help" for help.

postgres=#

Which is insecure because it disables all password checking

@arjennienhuis
Copy link

$ strace psql
...
socket(PF_LOCAL, SOCK_STREAM, 0)        = 4
fcntl(4, F_SETFL, O_RDONLY|O_NONBLOCK)  = 0
fcntl(4, F_SETFD, FD_CLOEXEC)           = 0
connect(4, {sa_family=AF_LOCAL, sun_path="/var/run/postgresql/.s.PGSQL.5432"}, 110) = 0
getsockopt(4, SOL_SOCKET, SO_ERROR, 0x7fffca92ae5c, 0x7fffca92ae70) = -1 EINVAL (Invalid argument)
...

and in Linux:

socket(PF_LOCAL, SOCK_STREAM, 0)        = 4
fcntl(4, F_SETFL, O_RDONLY|O_NONBLOCK)  = 0
fcntl(4, F_SETFD, FD_CLOEXEC)           = 0
connect(4, {sa_family=AF_LOCAL, sun_path="/var/run/postgresql/.s.PGSQL.5432"}, 110) = 0
getsockopt(4, SOL_SOCKET, SO_ERROR, [0], [4]) = 0

The source says:

			/*
			 * Write ready, since we've made it here, so the connection
			 * has been made ... or has failed.
			 */

			/*
			 * Now check (using getsockopt) that there is not an error
			 * state waiting for us on the socket.
			 */

			if (getsockopt(conn->sock, SOL_SOCKET, SO_ERROR,
						   (char *) &optval, &optlen) == -1)

@sunilmut
Copy link
Member

@arjennienhuis - Thanks for collecting the trace and dissecting it out. Makes the analysis very easy. Good news is that the support for SO_ERROR for unix socket was recently added (thanks @benhillis), but the fix is only available in our dev branch. It is making it's way to the release branch.

@arjennienhuis
Copy link

#1354 mentioned that. Thanks!

@arjennienhuis
Copy link

This doesn't work with 15014. Any idea when the fix will be released?

@sunilmut
Copy link
Member

Support for SO_ERROR for unix sockets came in 15019. Can you try with that build?

@StephanMeijer
Copy link

Same issue here with PostgreSQL 9.3.15.

@arjennienhuis
Copy link

I'm still "Initializing updates"... 😞

@arjennienhuis
Copy link

everything seems to work on 15025

@bhagwandassoni1953
Copy link

postgres@localhost:~$ /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
The files belonging to this database system will be owned by user "postgres". This user must also own the server process. The database cluster will be initialized with locale "C". The default database encoding has accordingly been set to "SQL_ASCII". The default text search configuration will be set to "english". Data page checksums are disabled. fixing permissions on existing directory /usr/local/pgsql/data ... ok creating subdirectories ... ok selecting dynamic shared memory implementation ... posix selecting default max_connections ... 20 selecting default shared_buffers ... 400kB selecting default time zone ... UTC creating configuration files ... ok running bootstrap script ... 2021-08-08 10:34:47.950 UTC [31924] FATAL: could not create shared memory segment: Operation not permitted 2021-08-08 10:34:47.950 UTC [31924] DETAIL: Failed system call was shmget(key=1081392, size=56, 03600). child process exited with exit code 1 initdb: removing contents of data directory "/usr/local/pgsql/data"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests