jeroenbourgois

jeroenbourgois

I have two repos, and just recently we switched to myxql from mariaex. Since then, when starting the application, the second repo errors out, and seems to use the IP address/hostname of the machine network I am instead of what is supplied in the config.

Surely, there is a tiny mistake I am overlooking, but it is driving me mad.

As a first hint: how would ecto/myxql be able to get a hold of that ip?

For instance, on my local machine, it goes ahead and fetches my public ip (behind ISP router here). Or for the actual app running docker, it has the public IP of the host machine, instead of the actual DB host ip, as configured in the settings. The settings itself seem to be OK, we inspected the sys.config file inside the docker container.

Maybe our supervision tree for the application is not ok, but it worked just fine with mariaex.

    children = [
      # Start the Ecto repository
      supervisor(App.Repo, []),
      supervisor(App.RepoDuo, []),
      # Start the endpoint when the application starts
      supervisor(App.Endpoint, []),

Showing Posts 1 to 6

wojtekmach

wojtekmach

Hex Core Team

So both repos use myxql but only the 2nd repo has problems? Could you paste your repos config? Whats the exact issue, its trying to connect to a host that it shouldn’t?

wojtekmach

wojtekmach

Hex Core Team

and if you have any additional repo config in its init/2 callback, please paste that too.

jeroenbourgois

jeroenbourgois OP

Hard to give too much config away since it is a client project, but I think it is pretty basic. What truly boggles me is the ip address it is trying to connect to. As I said, when I run the release on my local machine, the external IP of my ISP is mentioned (something like ‘78-xxx-xxx-xxx.access.telenet.be’ and if I run it on the actual machine, it shows the public Digital Ocean box IP, instead of the one for the db, supplied by the config).

Both repos have this as a module:

defmodule App.Repo do
  require Logger

  use Ecto.Repo,
    otp_app: :app_name,
    adapter: Ecto.Adapters.MyXQL

  use Scrivener

  def init(_, opts) do
    Logger.info "Starting Repo"
    Logger.info "#{inspect(opts)}"
    {:ok, opts}
  end
end

Second:

defmodule App.RepoDuo do
  require Logger

  use Ecto.Repo,
    otp_app: :app_name,
    adapter: Ecto.Adapters.MyXQ

  use Scrivener

  def init(_, opts) do
    Logger.info "Starting RepoDuo"
    Logger.info "#{inspect(opts)}"
    {:ok, opts}
  end
end

Then in the config:

config :app_name, App.Repo,
  username: System.fetch_env!("DB_USER"),
  password: System.fetch_env!("DB_PASSWORD"),
  database: System.fetch_env!("DB_NAME"),
  hostname: System.fetch_env!("DB_HOST"),
  timeout: 30_000,
  pool_size: 15

config :app_name, App.RepoDuo,
  username: System.fetch_env!("DB_DUO_USER"),
  password: System.fetch_env!("DB_DUO_PASSWORD"),
  database: System.fetch_env!("DB_DUO_NAME"),
  hostname: System.fetch_env!("DB_DUO_HOST"),
  timeout: 30_000,
  pool_size: 15

Almost as soon as we start the app, we get:
MyXQL.Connection (#PID<0.2640.0>) failed to connect: ** (MyXQL.Error) (1045) (ER_ACCESS_DENIED_ERROR) Access denied for...

wojtekmach

wojtekmach

Hex Core Team

Where is the IP mentioned? In your logs from init callback? From the MySQL server error? Both? Are you setting db config in prod.exs or releases.exs? Are you building release with Elixir releases or distillery? What’s your ecto, ecto_sql, and myxql version?

I know it’s related to deployment but if you could build a project that reproduces this, Ill be happy to help.

jeroenbourgois

jeroenbourgois OP

Yes in the logs. I commented out the other repo from the supervisor and output the opts that get in to the init/2 callback of the repo. There it seems fine, but immediately after seeing the log file, the errors come:

[info] Starting RepoDuo
:supervisor
[info] [telemetry_prefix: [:app_name, :repo_duo], otp_app: :app_name, username: "usr", password: "pwd", database: "duo", hostname: "SOME_IP", timeout: 30000, pool_size: 15]
[debug] [:production@darius][Elixir.Quantum.JobBroadcaster] Loading Initial Jobs from Config
[debug] [:production@darius][Elixir.Quantum.ExecutionBroadcaster] Unknown last execution time, using now
[error] MyXQL.Connection (#PID<0.2606.0>) failed to connect: ** (MyXQL.Error) (1045) (ER_ACCESS_DENIED_ERROR) Access denied for user 'usr'@'ANOTHER_IP.access.telenet.be' (using password: YES)

Just curious: is the supervisor setup ok?

children = [
      # Start the Ecto repository
      supervisor(App.Repo, []),
      supervisor(App.RepoDuo, []),
      # Start the endpoint when the application starts
      supervisor(App.Endpoint, []),
jeroenbourgois

jeroenbourgois OP

Ok, we got it!

I knew it was going to be something silly, sorry to waste your time a bit. Our generated pwd for the db had a $ in it, and it had to be escaped (in the env file where we export it from). So dumb… but it works now! :nerd_face:

— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
asweet-confluent
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews