Skip to content

Conversation

@nowisesys
Copy link

In development mode (dev/run) the dreyfus_index module is loaded by
startup. For release mode no such loading is done, instead modules are
loaded "on demand". In mango code, all use of dreyfus_index is protected
by checking if module is loaded (by calling module_loaded(dreyfus_index)).

This commit adds startup.erl containing code to be run during startup
of couchdb release (rel/couchdb/bin/couchdb) that fixes the error
occuring from dreyfus_index not being loaded.

For a seasoned couchdb or erlang developer this might seem to be a
trivial thing to fix, as for them the use of .erlang in working directory
is a well-known feature. Others might find this useful as it makes
couchdb with dreyfus working "out-of-the-box" in release mode too.

Overview

Solves loading of dreyfus_index (and other modules) running couchdb in release mode.

Testing recommendations

Configure, build and start release mode:

bash$> ./configure --disable-fauxton --disable-docs
bash$> make release
bash$> ./rel/couchdb/bin/couchdb

In another shell, test create an index all text:

bash$> curl -XPUT -H "Content-Type: application/json" http://127.0.0.1:5984/test1
bash$> curl -XPOST -H "Content-Type: application/json" http://127.0.0.1:5984/test1/_index -d '{"index":{},"type":"text"}'

Related Issues or Pull Requests

Perhaps the startup.erl should be config protected by install as startup.erl.in from rel/reltool.config

Checklist

  • [x ] Code is written and works correctly;
  • Changes are covered by tests;
  • [x ] Documentation reflects the changes;

In development mode (dev/run) the dreyfus_index module is loaded by
startup. For release mode no such loading is done, instead modules are
loaded "on demand". In mango code, all use of dreyfus_index is protected
by checking if module is loaded (by calling module_loaded(dreyfus_index)).

This commit adds startup.erl containing code to be run during startup
of couchdb release (rel/couchdb/bin/couchdb) that fixes the error
occuring from dreyfus_index not being loaded.

For a seasoned couchdb or erlang developer this might seem to be a
trivial thing to fix, as for them the use of .erlang in working directory
is a well-known feature. Others might find this useful as it makes
couchdb with dreyfus working "out-of-the-box" in release mode too.
@kocolosk
Copy link
Owner

Hi @nowisesys thanks for this contribution! I didn't have notifications on over here and missed this request. We definitely want the dreyfus_index module loaded as part of a release; let me double-check if there's a more standard way to ensure that happens. I don't think we're doing anything particularly novel in Dreyfus that would require this extra work. I think it's more likely I missed a standard flag somewhere else.

@kocolosk
Copy link
Owner

Oooh, now I see what's going on -- these are some old guard clauses intended to avoid advertising the availability of text indexes unless the search system was configured.

Given that this PR is talking about including Dreyfus 100% of the time, I think what we need to do here is change those guards so that e.g. they look for a connected search system instead of just checking for the dreyfus_index module, which will have the side effect of fixing this issue where the Mango text system is inadvertantly disabled in release mode Let's continue that discussion on the Pull Request over in the Apache repo.

@nowisesys
Copy link
Author

nowisesys commented Jun 17, 2019 via email

@kocolosk
Copy link
Owner

I could see where that would be useful, yes.

I think we have the issue with lazy code loading blocking Mango text indexes sorted out in the PR - would you be interested in re-submitting this as a standalone PR with an empty startup.erl.in to the upstream repo?

@kocolosk
Copy link
Owner

Hi I think we've address the original problem of Dreyfus getting loaded correctly in the upstream PR (which is now merged). I'm going to go ahead and close this one but feel free to submit a PR to be able to customize the .erlang file to https://github.com/apache/couchdb 👍

@kocolosk kocolosk closed this Jun 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants