Database / Mnesia intermediate to advanced Interview questions
How does Mnesia's schema interact with OTP release upgrades (appup/relup)?
A release upgrade's appup instructions describe how to hot-swap module code and transform
running gen_server state via code_change/3, but Mnesia's schema and table data live outside that
per-process state entirely — changing a Mnesia record's shape isn't something code_change/3
touches, since it's stored data, not process memory.
flowchart TD
A[Release upgrade begins] --> B[appup: hot-swap module code]
B --> C[code_change/3: transforms gen_server process state]
C --> D{Mnesia table shape also changing?}
D -->|Yes| E[Separate step: mnesia:transform_table/3 run explicitly]
D -->|No| F[Upgrade complete, no table changes needed]
If a release upgrade also needs to change a table's record shape, that has to be handled as an explicit,
separate step — typically calling mnesia:transform_table/3 as part of the upgrade
procedure (often triggered from an application's own upgrade callback) — rather than something the
standard relup/appup machinery does for you automatically.
More Related questions...