1. CouchDB
  2. COUCHDB-755

use exported functions when registering for config changes / db updates to allow hot upgrading


    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 0.11
    • Fix Version/s: 2.0.0
    • Component/s: Database Core
    • Labels:
    • Skill Level:
      Committers Level (Medium to Hard)


      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))

      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

      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.


        Adam Kocoloski made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Skill Level Regular Contributors Level (Easy to Medium) [ 10445 ] Committers Level (Medium to Hard) [ 10446 ]
        Adam Kocoloski made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 2.0.0 [ 12315572 ]
        Assignee Adam Kocoloski [ kocolosk ]
        Resolution Fixed [ 1 ]
        Jan Lehnardt made changes -
        Fix Version/s 1.1 [ 12314933 ]
        Paul Joseph Davis made changes -
        Field Original Value New Value
        Skill Level Regular Contributors Level (Easy to Medium)
        Adam Kocoloski created issue -


          • Assignee:
            Adam Kocoloski
            Adam Kocoloski
          • Votes:
            0 Vote for this issue
            1 Start watching this issue


            • Created: