Hot Upgrade breaks when there are 2 past releases

Steps to reproduce

Distillery version 2.0
Elixir 1.7.1
OTP 21.0
First, do a normal release and deploy with mix release . It created a build in prod/rel/app_name/releases/1.0.1-08f6b0c

Application working

now change something and again create a release with mix release --upgrade

It created a new version in prod/rel/app_name/releases/1.0.1-a4011918

and do the upgrade as

/opt/app-name/bin/app-name upgrade 1.0.1-a4011918

Application got upgraded.

Now again make a new change create an upgrade release. version 1.0.1-a6cf7267.

now try to upgrade and it will give an error.

Verbose ansible Logs

“Could not locate code path for release-evercam_media”,“1.0.1-08f6b0c!”

ansible + doing manual

"Could not locate code path for release-evercam_media\",\"1.0.1-08f6b0c!"

Description of issue

Expected: It should upgrade the new release version. but failed and finding the very first release code? is that an issue, that are 2 consecutive releases available and only should be the last one?

My config file is simple as

# Import all plugins from `rel/plugins`
# They can then be used by adding `plugin MyPlugin` to
# either an environment, or release definition, where
# `MyPlugin` is the name of the plugin module.
~w(rel plugins *.exs)
|> Path.join()
|> Path.wildcard()
|> Enum.map(&Code.eval_file(&1))

use Mix.Releases.Config,
    # This sets the default release built by `mix release`
    default_release: :default,
    # This sets the default environment used by `mix release`
    default_environment: Mix.env()

# For a full list of config options for both releases
# and environments, visit https://hexdocs.pm/distillery/configuration.html


# You may define one or more environments in this file,
# an environment's settings will override those of a release
# when building in that environment, this combination of release
# and environment configuration is called a profile

environment :dev do
  # If you are running Phoenix, you should make sure that
  # server: true is set and the code reloader is disabled,
  # even in dev mode.
  # It is recommended that you build with MIX_ENV=prod and pass
  # the --env flag to Distillery explicitly if you want to use
  # dev mode.
  set dev_mode: true
  set include_erts: false
  set cookie: :"Ht*Sd&uNNB]}}E;a~a/?&n~uogVhz>@|{,5`sX(>xK{A`@M,kj`0dF{s~`ry?XdJ"
end

environment :prod do
  set include_erts: true
  set include_src: false
  set cookie: :"Qf*;>$8`bG)vnRLU[AS(HLh9:]Qd:f)]%,`!Vfl^@Nek>OeeFRtl|&chJmdb{Ml("
end

# You may define one or more releases in this file.
# If you have not set a default release, or selected one
# when running `mix release`, the first release in the file
# will be used by default

release :evercam_media do
  set version: current_version(:evercam_media)
  set applications: [
    :runtime_tools
  ]
end

My question is: why 3rd release on upgrade looking for 1st release instead of 2nd one?

You might need to upgrade distillery to the latest (2.0.4) because 2.0 might not be working with your setup.

See https://github.com/bitwalker/distillery/issues/431

It seems like I am on the latest version already

"distillery": {:hex, :distillery, "2.0.4", "7fdc6647449f912540e827d51e1135ad3697ba09f33a6d5ca320e6755285437a", [:mix], [{:artificery, "~> 0.2", [hex: :artificery, repo: "hexpm", optional: false]}], "hexpm"},

Ok, my bad, I just saw some incompatibilities with prior to latest distillery, but You are already on latest.

My question is: why 3rd release on upgrade looking for 1st release instead of 2nd one?

I’m not a Hot Upgrade pro, but from what I’ve read, the code server only keeps two versions of the code. Also, in order to make use of the latest code, you need to make a call with the full module path.

Module.function() # picks up the latest code

function() # uses the old code until you make a fully qualified call, or you crash. :slight_smile:

I’m also not sure what happens if you’re passing and storing function references. IIRC there is no way to upgrade these and they will always crash.

Hopefully making some changes to call Module.function() will be a quick win for you.

It seems that the problem in OP is not with the in-memory code reload process, but with finding the upgrade releases … At least judging by the error posted and distillery’s script:

“Could not locate code path for release-evercam_media”,“1.0.1-08f6b0c!”

I’d guess something either deletes or doesn’t persist old releases.


As for why the second upgrade attempt looks for an older release, try looking into the generated appups. There might be an error there somewhere in your release process such that the third release is upgraded from the first one, and not the second one as you would’ve expected.

2 Likes