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

PostgreSQL unix socket will not connect and crashes #3716

Closed
Jieiku opened this issue Nov 27, 2021 · 10 comments
Closed

PostgreSQL unix socket will not connect and crashes #3716

Jieiku opened this issue Nov 27, 2021 · 10 comments

Comments

@Jieiku
Copy link

Jieiku commented Nov 27, 2021

Environment

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.

@licaon-kter
Copy link
Contributor

/close as duplicate #3165 ?

@Jieiku
Copy link
Author

Jieiku commented Nov 27, 2021

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?

@licaon-kter
Copy link
Contributor

Did the issue got fixed in the lib?

@Jieiku
Copy link
Author

Jieiku commented Nov 27, 2021

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.

@badlop
Copy link
Member

badlop commented Mar 15, 2022

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

case pgsql:connect([{host, Server},

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

@Jieiku
Copy link
Author

Jieiku commented Mar 15, 2022

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

@badlop badlop added this to the Parking Lot milestone Oct 19, 2022
@badlop badlop added the To reconsider Interesting feature, but nobody offered to implement on the short term. label Oct 19, 2022
@badlop badlop closed this as completed Oct 19, 2022
@Jieiku
Copy link
Author

Jieiku commented Oct 19, 2022

This is possible now?

@badlop
Copy link
Member

badlop commented Oct 24, 2022

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 badlop reopened this May 13, 2024
@badlop badlop modified the milestones: Parking Lot, ejabberd 24.xx May 13, 2024
@badlop badlop self-assigned this May 13, 2024
@badlop badlop removed the To reconsider Interesting feature, but nobody offered to implement on the short term. label May 13, 2024
@jeroenhabets
Copy link

FYI: @badlop wrote a patch 🥇 (see processone/p1_pgsql#7 (comment)) that I successfully (smoke)tested. @Jieiku perhaps you want to test https://github.com/badlop/ejabberd/tree/pgsql-unix-socket as well?

@jeroenhabets
Copy link

Thanks again @badlop 🥇! Now that it's committed we only need to be patience for it to be released.

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

4 participants