[
https://issues.apache.org/jira/browse/COUCHDB-755?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13669361#comment-13669361
]
Adam Kocoloski commented on COUCHDB-755:
----------------------------------------
The following two OTP applications replace couch_config and couch_db_update and
only allow exported functions as callbacks:
https://github.com/cloudant/config
https://github.com/cloudant/couch_event
> use exported functions when registering for config changes / db updates to
> allow hot upgrading
> ----------------------------------------------------------------------------------------------
>
> Key: COUCHDB-755
> URL: https://issues.apache.org/jira/browse/COUCHDB-755
> Project: CouchDB
> Issue Type: Improvement
> Components: Database Core
> Affects Versions: 0.11
> Reporter: Adam Kocoloski
>
> This is a common idiom in our current codebase:
> couch_config:register(fun("couchdb", "os_process_timeout", NewTimeout) ->
> couch_os_process:set_timeout(Pid, list_to_integer(NewTimeout))
> end),
> It proves problematic for hot code upgrades. The issue is that the anonymous
> fun is held by the couch_config process but belongs to the module in which it
> is defined (here, couch_external_server.erl). If an expert user loads a new
> version of couch_external_server, the anonymous fun will belong to the 'old'
> version of the module. If she upgrades the module again, couch_config will
> be killed. That's no good.
> The solution is to export the function that handles the configuration change
> or db update event. For instance
> -export(config_change/3).
> ...
> couch_config:register(fun ?MODULE:config_change/3),
> ...
> config_change("couchdb", "os_process_timeout", NewTimeout) ->
> couch_os_process:set_timeout(Pid, list_to_integer(NewTimeout)).
> I have a patch for this that we've been using for some time in Cloudant, just
> need to clean it up and apply it to trunk.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira