Turning off scale to zero on legacy postgres

Hi,

We’ve got a small MVP product that we’re building. When I first set it up I turned on the scale to zero option, but now I want to turn that off. I’ve turned it off on the app by setting the min_machines_running config value to 1 instead of 0. I’ve tried to turn it off on the postgres app (a legacy non-managed development “cluster” of one machine), by removing the FLY_SCALE_TO_ZERO env variable from the fly.toml file I’ve got for that app.

However, I can’t deploy using the new config. When I try, it fails because of a health check. See the logs below. Now the main app is broken because it can’t connect to the DB.

Feels like the issue could be because of the new image not listening on the right ports? But that’s not something I’m setting/controlling, so I’m not really sure.

Nothing in the DB is particularly valuable, so I guess I could just create a new app, but I’d rather learn what’s going wrong so I don’t have this same issue next month.

fly deploy --app APP --config fly.db.toml --image flyio/postgres-flex:15.2
==> Verifying app config
Validating fly.db.toml
✓ Configuration is valid
--> Verified app config
==> Building image
Searching for image 'flyio/postgres-flex:15.2' remotely...
image found: img_2wokpy18x5lp3g1m

Watch your deployment at https://fly.io/apps/APP/monitoring

-------
Updating existing machines in 'APP' with rolling strategy

WARNING The app is not listening on the expected address and will not be reachable by fly-proxy.
You can fix this by configuring your app to listen on the following addresses:
  - 0.0.0.0:5433
Found these processes inside the machine with open listening sockets:
  PROCESS                                      | ADDRESSES
-----------------------------------------------*---------------------------------------
  /.fly/hallpass                               | [fdaa:e:e3e:a7b:be65:5fe5:7805:2]:22
  /usr/local/bin/start_admin_server            | [::]:5500
  postgres_exporter --log.level=warn           | [::]:9187
  /usr/sbin/haproxy -W -db -f /fly/haproxy.cfg | [::]:5432, [::]:8404, 0.0.0.0:5432


-------
 ✔ Cleared lease for 9185900a9e2de8
-------
Error: failed to update machine 9185900a9e2de8: Unrecoverable error: timeout reached waiting for health checks to pass for machine 9185900a9e2de8: failed to get VM 9185900a9e2de8: Get "https://api.machines.dev/v1/apps/APP/machines/9185900a9e2de8": net/http: request canceled

Hi… As just a quick tip, :red_rock_dwelling:, the most important skill with Legacy Postgres is to look at its full logs…

$ fly logs -a db-app-name

In this case, you’ll probably see the main Postgres process try to start but then crash.

(Often, it’s the --image that trips people up.)

Hope this helps a little!

Thanks!

I can see in the logs that it is trying to connect to port 5433 and it’s failing.

Going on your --images hint I looked in the deployment history and found that the first deploy used version 16.4 not 15.2, so I’m trying the deploy again using the 16.4 version.

Fingers crossed. Thanks for the pointers.

1 Like