[erlang-bugs] reltool upsetting the order of things

Ulf Wiger ulf@REDACTED
Tue Jan 24 11:23:51 CET 2012


As I'm standing knee-deep in rebar and retool fun, I've noticed that reltool doesn't seem to respect the given order of applications in the 'rel' config.

It is perhaps a less known aspect of sys tools that it will do its best to preserve the application order in the .rel file, and only move apps as needed to account for application dependencies.

There was a concrete reason for this too.

Back in the days (here comes another history lesson), we discovered that there were some nasty error situations in mnesia, where the tables would never load. As we were building a system that really had to come up, no matter what, we created a little program that started *before* mnesia, and monitored table loading progress. It was vital that it started before mnesia, because if we decided to do a force_load to break a table loading deadlock, we had to ensure that other mnesia nodes didn't start going on-line at the same time. This was handled with a global lock in the application that started before mnesia.

So this was a new (reverse) application dependency of sorts. We didn't want to hack mnesia's .app file, so we agreed with OTP (actually, I and Magnus Björklund agreed - things were easier then), that the sorting function in systools_make should not change the order unless it really had to.

The sorting function is here:
https://github.com/erlang/otp/blob/master/lib/sasl/src/systools_make.erl#L1243

(It says there that I wrote it. I thought it was Martin. But at least you can see that it's documented, sort of).

Now, retool (after I've experimented with various settings), now filters the way I want, but then calls reltool_target:sort_apps/1 and *changes* the original order. I haven't studied the algorithm to figure out which order it prefers over mine, but I had already put the apps in the order I wanted.

A few debug printouts from reltool_target:merge_apps/2 to illustrate:

MergedApps2("setup") = [stdlib,kernel,sasl,setup]
Embedded("setup") = []
Sorted("setup") = [kernel,stdlib,setup,sasl]

I maintain that reltool doesn't have to sort the list, since systools does whatever sorting is needed. Indeed, reltool should *refrain* from upsetting the original order.

If it has added applications to the list, it should add those at the end.

BR,
Ulf W
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-bugs/attachments/20120124/6fdbdef3/attachment.htm>


More information about the erlang-bugs mailing list