jaydoane opened a new issue, #4892:
URL: https://github.com/apache/couchdb/issues/4892

   [NOTE]: # ( ^^ Provide a general summary of the issue in the title above. ^^ 
)
   
   ## Description
   
   [NOTE]: # ( Describe the problem you're encountering. )
   [TIP]:  # ( Do NOT give us access or passwords to your actual CouchDB! )
   
   A CouchDB configuration feature is described in a Note at the end of [this 
section of the 
docs](https://docs.couchdb.org/en/stable/config/intro.html#setting-parameters-via-the-configuration-file):
   
   > In case when you’d like to remove some parameter from the default.ini 
without modifying that file, you may override in local.ini, but without any 
value:
   ```
   [compactions]
   _default =
   ```
   > This could be read as: “remove the _default parameter from the compactions 
section if it was ever set before”.
   
   The source code refers to a construct such as `val =` as a "delete marker", 
so I also adopt that term.
   
   Although delete markers are treated as described in the docs when the 
`config` app starts, the `config:reload/0` function effectively ignores them, 
leading to an inconsistent state.
   
   ## Steps to Reproduce
   
   [NOTE]: # ( Include commands to reproduce, if possible. curl is preferred. )
   
   For clarity, add a new section to `default.ini` and `local.ini`:
   ```diff
   diff --git a/rel/overlay/etc/default.ini b/rel/overlay/etc/default.ini
   index c7f3744ce..e727d48e3 100644
   --- a/rel/overlay/etc/default.ini
   +++ b/rel/overlay/etc/default.ini
   @@ -1,4 +1,7 @@
    ; Upgrading CouchDB will overwrite this file.
   +[section]
   +inifile = default.ini
   +
    [vendor]
    name = {{package_author_name}}
   
   diff --git a/rel/overlay/etc/local.ini b/rel/overlay/etc/local.ini
   index ba76ebfdf..1268f05e2 100644
   --- a/rel/overlay/etc/local.ini
   +++ b/rel/overlay/etc/local.ini
   @@ -1,5 +1,8 @@
    ; CouchDB Configuration Settings
   
   +[section]
   +inifile = local.ini
   +
    ; Custom settings should be made in this file. They will override settings
    ; in default.ini, but unlike changes made to default.ini, this file won't be
    ; overwritten on server upgrade.
   ```
   Then `dev/run`:
   ```
   ([email protected])1> string:trim(os:cmd("grep inifile 
dev/lib/node1/etc/local.ini")).
   "inifile = local.ini"
   ([email protected])2> string:trim(os:cmd("grep inifile 
dev/lib/node1/etc/default.ini")).
   "inifile = default.ini"([email protected])3> config:get("section", "inifile").
   "local.ini"
   ([email protected])4> config:delete("section", "inifile").
   ok
   ([email protected])5> string:trim(os:cmd("grep inifile 
dev/lib/node1/etc/local.ini")).
   "inifile ="
   ([email protected])6> config:get("section", "inifile").
   undefined
   ([email protected])7> config:reload().
   ok
   ([email protected])8> config:get("section", "inifile").
   "default.ini"
   (search)`where': exit(whereis(config), kill).
   true
   ([email protected])10> config:get("section", "inifile").
   undefined
   ```
   
   ## Expected Behaviour
   
   [NOTE]: # ( Tell us what you expected to happen. )
   
   I would expect `config:init/1` and `config:reload/0` to treat delete markers 
consistently.
   
   ## Your Environment
   
   [TIP]:  # ( Include as many relevant details about your environment as 
possible. )
   [TIP]:  # ( You can paste the output of curl http://YOUR-COUCHDB:5984/ here. 
)
   
   * CouchDB version used: 
https://github.com/apache/couchdb/commit/2af3cd811f5c714dc9f23320b797be54f6ed0f14
   * Browser name and version: N/A
   * Operating system and version: N/A
   
   ## Additional Context
   
   This behavior appears to have existed since the [introduction of the 
`reload` 
function](https://github.com/apache/couchdb-config/commit/e358fbbf2b287c3f4975e8b99c6f55c0dd33497e),
 so it's not a new problem. In fact, the current behavior of `reload` to ignore 
delete markers is **relied** on by operators at Cloudant where 
`config:reload()` is used extensively. So simply "fixing" `reload` to stop 
ignoring delete markers, as I naively attempted to do 
[here](https://github.com/apache/couchdb/pull/4813), would actually be a fiasco.
   
   ### Possible solutions
   
   It would be nice to just create a config option, say 
`ignore_delete_markers`, but that's not possible for the `config` app itself.
   
   The Erlang way to configure an OTP application would be to add an 
environment variable to `vm.args`. However, an attempt to add a line like the 
following:
   ```
   -config ignore_delete_markers true
   ```
   results in this error
   ```
   {"could not start kernel pid",application_controller,"error in config file 
\"./ignore_delete_markers.config\" (none): configuration file not found"}
   ```
   because Erlang uses the `-config` in `vm.args` as a way to [specify the name 
of one or more configuration files](https://www.erlang.org/doc/man/erl.html). 
In short, the application being named `config` prevents using the normal OTP 
way of configuring it. Bummer!
   
   [TIP]:  # ( Add any other context about the problem here. )
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to