ejabberd icon indicating copy to clipboard operation
ejabberd copied to clipboard

PostgreSQL unix socket will not connect and crashes

Open Jieiku opened this issue 3 years ago • 9 comments
trafficstars

Environment

  • ejabberd version: 21.07
  • Erlang version: erl +V: Erlang (SMP,ASYNC_THREADS) (BEAM) emulator version 10.6.4
  • OS: Linux Ubuntu 20.04.3 LTS (GNU/Linux 5.4.143-1-pve x86_64)
  • Installed from: official deb ( https://static.process-one.net/ejabberd/downloads/21.07/ejabberd_21.07-0_amd64.deb )

Configuration:

loglevel: 5

host_config:
  "example.com":
    sql_type: pgsql
    sql_server: "/run/postgresql"
    sql_database: "ejabberd"
    sql_username: "ejabberd"
    sql_password: ""
    auth_method: sql
    auth_password_format: scram

Errors from error.log/crash.log

ejabberd.log:

2021-11-26 19:27:50.986 [warning] <0.622.0>@ejabberd_sql:handle_reconnect:472 pgsql connection failed:
** Reason: {init,{error,nxdomain}}
** Retry after: 30 seconds

crash.log:

2021-11-26 19:27:50 =CRASH REPORT====
  crasher:
    initial call: pgsql_proto:init/1
    pid: <0.769.0>
    registered_name: []
    exception exit: {{init,{error,nxdomain}},[{gen_server,init_it,6,[{file,"gen_server.erl"},{line,358}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,249}]}]}
    ancestors: ['ejabberd_sql_example.com_2','ejabberd_sql_sup_example.com',ejabberd_db_sup,ejabberd_sup,<0.107.0>]
    message_queue_len: 0
    messages: []
    links: []
    dictionary: []
    trap_exit: false
    status: running
    heap_size: 610
    stack_size: 27
    reductions: 765
  neighbours:

error.log:

2021-11-26 19:27:50.987 [error] <0.766.0> CRASH REPORT Process <0.766.0> with 0 neighbours exited with reason: {init,{error,nxdomain}} in gen_server:init_it/6 line 358

Bug description

If you configure ejabberd.yaml (as shown above) to use pgsql via unix socket then it will not connect. Crashes are generated in the crash log as well.

Jieiku avatar Nov 27 '21 04:11 Jieiku

/close as duplicate https://github.com/processone/ejabberd/issues/3165 ?

licaon-kter avatar Nov 27 '21 07:11 licaon-kter

I don't see any resolution in that issue report, only that it was closed, and that was over a year ago, so I am hoping it is worth revisiting this?

Jieiku avatar Nov 27 '21 10:11 Jieiku

Did the issue got fixed in the lib?

licaon-kter avatar Nov 27 '21 10:11 licaon-kter

mmm I found this project: https://github.com/saleyn/euds the opening readme of the page says this:

This project implements a NIF library to support Unix Domain Sockets.

UPDATE: this project will be deprecated beginning with Erlang 19RC2, which will include native support for Unix Domain Sockets.

That to me says that if we are on Erlang 19RC2 or later then yes native support for Unix sockets should be in the Erlang Library.

EDIT: here is relevant info: http://erlang.org/download/otp_src_19.0.readme

OTP-13572 Application(s): erts, kernel Related Id(s): PR-612

           Experimental support for Unix Domain Sockets has been
           implemented. Read the sources if you want to try it
           out. Example: gen_udp:open(0,
           [{ifaddr,{local,"/tmp/socket"}}]). Documentation will
           be written after user feedback on the experimental API.

Jieiku avatar Nov 27 '21 22:11 Jieiku

if we are on Erlang 19RC2 or later then yes native support for Unix sockets should be in the Erlang Library.

ejabberd uses p1_pgsql https://github.com/processone/ejabberd/blob/5506b838c803c33c6fd5b1af00d62482c4a75c60/src/ejabberd_sql.erl#L954

and that library expects a host and a port https://github.com/processone/p1_pgsql/blob/4c42903f91cbb2840b8a5266e6e3b5cdc82b702e/src/pgsql_proto.erl#L99

and that's the only it supports: https://github.com/processone/p1_pgsql/blob/4c42903f91cbb2840b8a5266e6e3b5cdc82b702e/src/pgsql_util.erl#L48

badlop avatar Mar 15 '22 09:03 badlop

hey hey, thanks for the reply! would still love to be able to use unix socket.

Jieiku avatar Mar 15 '22 19:03 Jieiku

This is possible now?

Jieiku avatar Oct 19 '22 17:10 Jieiku

Not possible yet, and apparently no plan; in that case the Milestone field should indicate in what version it is supported, expected or possible.

As months have passed and it seems there's no specific plan to implement it or general interest, during the periodic issue cleaning this has been marked for the "Parking lot", tagged "To reconsider", and temporarily closed.

badlop avatar Oct 24 '22 10:10 badlop