Erlang / Erlang Advanced Interview questions
Explain the internal working of a relup-based hot upgrade?
A relup (release upgrade) file is a generated script describing exactly how to move a running
system from one release version to another without a restart: which applications to stop/start, which modules
to load, in what order, and which processes need their internal state transformed via
code_change/3.
flowchart TD
A[release_handler:install_release] --> B[Suspend affected processes]
B --> C[Load new module code]
C --> D[Call code_change/3 on running gen_server state]
D --> E[Resume processes with upgraded code + transformed state]
E --> F{Upgrade successful?}
F -->|No| G[Roll back using matching downgrade instructions]
release_handler:install_release/1 reads the relup script and executes its instructions in
order, pausing affected gen_servers just long enough to swap in new code and let
code_change/3 reshape their existing state to match the new version's expectations. Because the
relup also contains the reverse (downgrade) instructions, a failed upgrade can be rolled back to the previous
known-good release rather than leaving the system in a broken intermediate state.
More Related questions...