-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Return callback module in supervisor format_status #1000
Conversation
7c0733f
to
9ef5502
Compare
Patch has passed first testings and has been assigned to be reviewed I am a script, I am not human |
The addition of supervisor:format_status/2 in this patch makes the patch backwards incompatible in the sense that sys:get_status(SomeSupervisor) will no longer return the same as in previous releases. Is this addition really necessary for the purpose of patch? |
@sirihansen that makes sense. I can definitely change this but before I would like to discuss if the format I am currently adopting is our best choice. I can think of at least three:
In particular, 2 and 3 could be backwards compatible if the calling code is matching on Another alternative is to not rely on {supervisor, Mod, _Args} = proc_lib:initial_call(Pid). Any preference on how to move this forward? I am ready to work on this since this feature is quite important for us. :) Thank you! |
We have discussed this for a while, and still no conclusion :( Just wondering how you incorporate the "other supervisor implementation" in the system? Is the alternative with Except for this, our thoughts right now are something like
|
We also thought about the possibility of just doing a call to the supervisor, instead of using sys or proc_lib. But I don't think we can guarantee that there is no suspended supervisor anywhere, so it seems too dangerous to do it this way. |
You are probably aware but, if it helps, both 2 and 3 are done by gen_event: https://github.com/erlang/otp/blob/maint/lib/stdlib/src/gen_event.erl#L772-L775
It would work in my case because I am setting :"$initial_call" to the same format the supervisor would. Even though it is not documented, I decided to use the same format because tools may rely on it. Since some context may be helpful, the supervisor I am implementing is just the That said, although Thank you for the follow up! |
I have sent a new PR with the proc_lib approach to facilitate the discussion: #1079. |
I'm sorry for the slow progress, but finally we have come to a decision - we will use alternative 3, slightly modified:
And we will keep your new How soon would you be able to do this, @josevalim ? |
No problem! I am on it right now. :) |
9ef5502
to
552d389
Compare
@sirihansen I have pushed the new code. Some decisions I took:
Regarding the usage of It is also worth pointing out many places in tests use |
Great, thanks! I have now included the branch in our nightly tests. I'll have a closer look at |
Ah - there is at least one place in release_handler_SUITE where this will fail.. It calls |
And please have a look at |
552d389
to
fac9af0
Compare
@sirihansen great catch! I have run a search for "sys, get_status" now and I have analyzed the new results. It seems we don't parse the Other than that, I have fixed |
Great, I'll update the branch with your changes, but there is indeed a problem in release_handler_SUITE. From yesterdays test - failed on all test machines: === Ended at 2016-06-03 22:41:59 === Location: [{release_handler_SUITE,upgrade_supervisor,1373}, {test_server,ts_tc,1529}, {test_server,run_test_case_eval1,1045}, {test_server,run_test_case_eval,977}] === Reason: no match of right hand side value {status,<15680.79.0>, {module,gen_server}, [[{'$initial_call',{supervisor,a_sup,1}}, {'$ancestors',[<15680.78.0>]}], running,<15680.78.0>,[], [{header,"Status for generic server a_sup"}, {data, [{"Status",running}, {"Parent",<15680.78.0>}, {"Logged events",[]}]}, {data, [{"State", {state, {local,a_sup}, one_for_all, [{child,<15680.80.0>,a, {a,start_link,[]}, permanent,brutal_kill,worker, [a]}], undefined,4,3600,[],0,a_sup,[]}}]}, {supervisor,[{"Callback",a_sup}]}]]} in function release_handler_SUITE:upgrade_supervisor/1 (release_handler_SUITE.erl, line 1373) in call from test_server:ts_tc/3 (test_server.erl, line 1529) in call from test_server:run_test_case_eval1/6 (test_server.erl, line 1045) in call from test_server:run_test_case_eval/9 (test_server.erl, line 977) |
The previous implementation of supervisor:get_callback_module/1 used sys:get_status/1 to get the supervisor inner state and retrieve the callback module. Such implementation forbids any other supervisor implementation that has an internal state different than the #state{} record in supervisor.erl. This patch allows supervisors to return the callback module as part of the sys:get_status/1 data, no longer coupling the callback module implementation with the inner #state{} record. Notice we have kept the clause matching the previous sys:get_status/1 reply for backwards compatibility purposes.
fac9af0
to
e257753
Compare
Ouch, the reason I did not find this one is because I searched for "sys, get_status" and this one is using "sys,get_status". 😨 I have fixed it and force pushed once more! Thanks for all the feedback! |
ok, let's hope it was the last one :) I've included the latest in the tests now. |
Patch has passed first testings and has been assigned to be reviewed I am a script, I am not human |
The previous implementation of supervisor:get_callback_module/1
used sys:get_status/1 to get the supervisor inner state and
retrieve the callback module. Such implementation forbids any
other supervisor implementation that has an internal state
different than the #state{} record in supervisor.erl.
This patch allows supervisors to return the callback module
as part of the sys:get_status/1 data, no longer coupling the
callback module implementation with the inner #state{} record.
Notice we have kept the clause matching the previous
sys:get_status/1 reply for backwards compatibility purposes.