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

Can't connect to aiven db #76

Open
mine-tech-oficial opened this issue Mar 20, 2024 · 6 comments
Open

Can't connect to aiven db #76

mine-tech-oficial opened this issue Mar 20, 2024 · 6 comments

Comments

@mine-tech-oficial
Copy link

Hello! After setting up an aiven db and testing the connection with rebar3 shell, it seems that it can't connect:

Pool creation:

pgo:start_pool(test, #{pool_size => 5, host => "[REDACTED].a.aivencloud.com", database => "defaultdb", port => 22381, user => "avnadmin", password => "[REDACTED]", ssl => true, ssl_options => [{{cacertfile, "./ca.pem"}, {verify, verify_peer}]}).

Test command:

pgo:query("select id from post", #{pool => test}).

and (because I don't know if it needs to be a string)

pgo:query("select id from post", #{pool => "test"}).

Return from both queries

{error,none_available}

Can someone help me?

@tsloughter
Copy link
Collaborator

And ther eare no logs about connections failing?

@tsloughter
Copy link
Collaborator

logger won't print anything by default, you'll want to create a file like config/sys.config:


[{kernel,
  [{logger_level, debug},
    {logger,
    [{handler, default, logger_std_h,
      #{level => debug, formatter => {logger_formatter, #{single_line => true}}}}
    ]}]}].

And run rebar3 as:

rebar3 shell --config config/sys.config

@mine-tech-oficial
Copy link
Author

After running

pgo:start_pool(test, #{pool_size => 5, host => "pg-a4560fe-catgram.a.aivencloud.com", database => "defaultdb", port => 22381, user => "avnadmin", password => "AVNS_bnrCb3NoORvNXijLsp1", ssl => true, ssl_options => [{{cacertfile, "./ca.pem"}, {verify, verify_peer}}]}).

it spams unknown error when connecting to database: {option_not_a_key_value_tuple,{{cacertfile,"./ca.pem"},{verify,verify_peer}}}

@tsloughter
Copy link
Collaborator

Ah yea, that 2 2-tuples in a 1-tuple. Remove the surrounding {} .

@mine-tech-oficial
Copy link
Author

After fixing that error and running again it returned the following

2024-03-23T13:18:34.527418-03:00 info: Supervisor: {<0.241.0>,pgo_pool_sup}. Started: id=connection_sup,pid=<0.242.0>.
2024-03-23T13:18:34.528201-03:00 info: Supervisor: {<0.241.0>,pgo_pool_sup}. Started: id=connection_starter,pid=<0.243.0>.
2024-03-23T13:18:34.529037-03:00 info: Supervisor: {<0.241.0>,pgo_pool_sup}. Started: id=type_server,pid=<0.244.0>.
{ok,<0.240.0>}
2> 2024-03-23T13:18:34.538168-03:00 info: Supervisor: {local,inet_gethost_native_sup}. Started: pid=<0.252.0>,mfa={inet_gethost_native,init,[[]]}.
2024-03-23T13:18:34.538260-03:00 info: Supervisor: {local,kernel_safe_sup}. Started: id=inet_gethost_native_sup,pid=<0.251.0>.
2024-03-23T13:18:35.376984-03:00 info: Supervisor: {<0.260.0>,tls_dyn_connection_sup}. Started: id=sender,pid=<0.266.0>.
2024-03-23T13:18:35.376987-03:00 info: Supervisor: {<0.263.0>,tls_dyn_connection_sup}. Started: id=sender,pid=<0.268.0>.
2024-03-23T13:18:35.377058-03:00 info: Supervisor: {<0.265.0>,tls_dyn_connection_sup}. Started: id=sender,pid=<0.269.0>.
2024-03-23T13:18:35.377009-03:00 info: Supervisor: {<0.261.0>,tls_dyn_connection_sup}. Started: id=sender,pid=<0.267.0>.
2024-03-23T13:18:35.377095-03:00 info: Supervisor: {<0.260.0>,tls_dyn_connection_sup}. Started: id=receiver,pid=<0.272.0>.
2024-03-23T13:18:35.377142-03:00 info: Supervisor: {<0.263.0>,tls_dyn_connection_sup}. Started: id=receiver,pid=<0.273.0>.
2024-03-23T13:18:35.377171-03:00 info: Supervisor: {<0.265.0>,tls_dyn_connection_sup}. Started: id=receiver,pid=<0.274.0>.
2024-03-23T13:18:35.377093-03:00 info: Supervisor: {<0.262.0>,tls_dyn_connection_sup}. Started: id=sender,pid=<0.270.0>.
2024-03-23T13:18:35.377117-03:00 info: Supervisor: {<0.264.0>,tls_dyn_connection_sup}. Started: id=sender,pid=<0.271.0>.
2024-03-23T13:18:35.377282-03:00 info: Supervisor: {<0.261.0>,tls_dyn_connection_sup}. Started: id=receiver,pid=<0.275.0>.
2024-03-23T13:18:35.377346-03:00 info: Supervisor: {<0.262.0>,tls_dyn_connection_sup}. Started: id=receiver,pid=<0.276.0>.
2024-03-23T13:18:35.377456-03:00 info: Supervisor: {<0.264.0>,tls_dyn_connection_sup}. Started: id=receiver,pid=<0.277.0>.

Then I ran the following tests:

2> pgo:query("select id from post", #{pool => "test"}).
** exception exit: {noproc,{pgo_pool,checkout,[default,[]]}}
     in function  pgo_pool:checkout/2 (/home/pedrohcf/pgo/src/pgo_pool.erl, line 58)
     in call from pgo:query/3 (/home/pedrohcf/pgo/src/pgo.erl, line 100)
3> pgo:query("select id from post", #{pool => test}).
** exception exit: {noproc,{pgo_pool,checkout,[default,[]]}}
     in function  pgo_pool:checkout/2 (/home/pedrohcf/pgo/src/pgo_pool.erl, line 58)
     in call from pgo:query/3 (/home/pedrohcf/pgo/src/pgo.erl, line 100)

@tsloughter
Copy link
Collaborator

try: pgo:query("select id from post", [], #{pool => test}).

To pass the options you have to use query/3: query(Query, Params, Options)

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

No branches or pull requests

2 participants