summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* Fix should_create_no_conflicts_on_full_stem test caseoptimize-doc-updates-3Nick Vatamaniuc2018-01-151-1/+4
| | | | | Add comment explaining how full stem will be run in the repair_tree function when a common tree node is found.
* In couch_key_tree:stem/4 also update `Seen` set for a leaf child.Nick Vatamaniuc2018-01-151-6/+12
| | | | Moved set update to a separate function since it's common code.
* Automatically repair revision treesPaul J. Davis2018-01-152-32/+39
|
* Move sorting logic to couch_key_tree.erlPaul J. Davis2018-01-152-7/+11
|
* Fix should_create_no_conflicts_on_merge testPaul J. Davis2018-01-151-4/+4
| | | | | | | This test is actually testing that the old stemming algorithm with correct a badly formatted tree after a revision had been incorrectly merged. This is no renamed `full_stem` which only happens at compaction time.
* Fix should_merge_tree_of_odd_length testPaul J. Davis2018-01-151-3/+2
| | | | | | This test was invalid as merging does not support anything but a linear path. This merge failure was covered up by stemming completely disassembling and reassembling the badly merged tree.
* Fix should_merge_tree_to_itself testPaul J. Davis2018-01-151-2/+17
| | | | | | | This test was invalid as merging does not support anything other than a linear path. The fact that this was passing before is merely and oversight that was covered up by stemming completely disassembling and reassembling the tree after a failed merge.
* Optimize couch_key_tree:stem/2Paul J. Davis2018-01-152-4/+55
| | | | | | | | | | This changes the stemming algorithm to be a single pass O(N) operation rather than the existing O(N^2) operation. The old stemming algorithm works by taking the entire tree apart and then merging the resulting paths back into a single tree. The merging operation ends up causing the O(N^2) aspect because every branch has to be compared to every exisitng sub-tree.
* Sort document updates to guarantee proper mergingPaul J. Davis2018-01-151-1/+7
|
* Optimize document updatesPaul J. Davis2018-01-151-16/+20
| | | | | This works by delaying the stemming step until all updates to a given document have been processed.
* Optimize validating replicated updatesPaul J. Davis2018-01-151-4/+5
|
* Fix couch_peruser_testEric Avdey2018-01-151-22/+45
| | | | | Fix a random mashup of test object generators with normal assertions.
* Allow override of `-args_file` and `-config` parameters (#1095)Edwin Fine2018-01-131-2/+6
| | | | | | | | | | | | | | | | | The existing `couchdb` start script hard-codes the arguments to `-args_file` and `-config`. Although it is possible to copy this script and modify it, or modify it in place, that is less than ideal and can lead to all kinds of difficulties. This PR adds the following environment variables: - `ARGS_FILE`: By default, set to the existing hard-coded value. - `SYSCONFIG_FILE`: By default, set to the existing hard-coded value. - `COUCHDB_ARGS_FILE`: If non-empty, overrides `ARGS_FILE`. - `COUCHDB_SYSCONFIG_FILE`: If non-empty, overrides `SYSCONFIG_FILE`. By changing the script to use these environment variables, it makes it easily possible to use different settings without tinkering with the pristine installed CouchDB environment.
* Remove warning on `couch_epi_codegen` compileEric Avdey2018-01-122-7/+16
| | | | | | | | Change runtime choice between `erl_scan:token_info` and `erl_scan:line` to compilation conditional one. This is getting rid of compilation deprecation warning and also should speed up things a bit.
* Simplify couch_key_tree test setupNick Vatamaniuc2018-01-121-7/+11
| | | | | | | Avoid starting 4 applications (config, couch_log, ioq and couch_epi) just to handle a call to config:get. Instead just mock the config directly. This also speeds up the test suite a bit.
* fallback to "selector" on empty "partial_filter_selector" (#1098)Will Holley2018-01-093-12/+17
| | | | | | | | | | | | | | | | | | | | | | | Mango text indexes historically supported partial indexes defined via a "selector" field. This was renamed to "partial_filter_selector" in b98de40 but the fallback code did not correctly handle the case where a "selector" existed alongside a "partial_filter_selector". This situation can occur when a the _index endpoint is used to create a text index with a "selector". The resulting design document contains an empty "partial_filter_selector" field *and* the "selector" field that was passed in. The previous implementation of the fallback would detect the presence of "partial_filter_selector" and use the empty value (match all docs) instead of faling back to the "selector" field. This commit changes the behaviour so that a "selector" will be used even if an empty "partial_filter_selector" is present. A secondary fix would be to change the index creation so that we never use "selector" in the underlying index design document, even if it is passed to the _index API.
* Return friendly error message when creating user with invalid password (#1087)Peng Hui Jiang2018-01-062-2/+40
| | | | | | | | | | | | * Return friendly error message when creating user with invalid password - Return friendly error message instead of returning unknown_error and function_clause when creating a use with non-string password. issue 1051 * Add check for salt issue 1051
* Merge pull request #1091 from apache/better-mango-test-recreate-functionEric Avdey2018-01-041-6/+8
|\ | | | | Make sure mango tests's recreate fun creates db
| * Make sure mango tests's recreate fun creates dbEric Avdey2018-01-041-6/+8
|/ | | | | | | | | | Rapid same database deletion/creation is a known antipattern prone to a race condition, especially on slow VMs. This fix modifies mango test's helper function used for db recreation to ensure that we are actually starting tests when a database created and empty.
* Merge pull request #1092 from apache/use-uuid-in-eunit-dbnamesEric Avdey2018-01-041-7/+4
|\ | | | | Use uuid in tmp db names in unit tests
| * Use uuid in tmp db names in unit testsuse-uuid-in-eunit-dbnamesEric Avdey2018-01-041-7/+4
|/ | | | | | | | | | This changes naming of temporary eunit databases and files from using unique_monotonic_integer to couch_uuids:random to remove performance penalty and normalize naming across erlang releases. Also getting rid of unnecessary inter-types convertion.
* Merge pull request #1090 from apache/cleanup-on-setup_eunitEric Avdey2018-01-041-0/+20
|\ | | | | Cleanup data dirs in eunit_plugin before test run
| * Cleanup data dirs in eunit_plugin before test runEric Avdey2018-01-041-0/+20
|/ | | | | | | | | | | | | | | | We use `unique_monotonic_integer` to name the test databases in unit testing. That means that on erlang R > 18 we are always creating databases with same names. When unit tests crashing or don't properly cleaning up on teardown, they are leaving behind old database files, son on a next run tests' setup fails with `database exists` exception. This fix cleans up old database files making sure we are always running unit tests from same blank state.
* Merge pull request #1078 from cloudant/issue-832-couch_log-refactoriilyak2017-12-201-24/+9
|\ | | | | Refactor couch_log.erl
| * Refactor couch_logjiangphcn2017-12-211-24/+9
|/ | | | issue 832
* Fix mango native proc crash (#1067)Eric Avdey2017-12-202-2/+36
| | | | | | | | | | Don't crash on receiving cast stop When soft limit is reached couch_proc_manager evicts idle processes by casting on them `stop` message. Since mango_native_proc doesn't handle this message it results to its crash with `invalid_cast` reason.
* Mango: change catch-all field range priority (#1069)Will Holley2017-12-192-3/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 01252f97 introduced a "catch-all" feature to Mango that allowed queries to fall back on a full database scan (_all_docs) when no valid index was available. This worked by creating a special index range representing the full database scan. For example, a selector: { "_id": "foo" } would be translated into a field range of: [{ "startkey": "foo", "endkey": "foo"}] then prepending the catch-all field range, we would have: [ { "startkey": null, "endkey": max_json_value}, { "startkey": "foo", "endkey": "foo"} ] This set gets passed into mango_cursor_view:choose_best_index to determine most selective index and field range combination to use. Unfortunately, in the event that we have one possible index (all_docs) and multiple valid ranges, it just chooses the first range it finds - the full index scan in this case. This commit makes the catch-all field range the last available option, ensuring we use the more selective range where available.
* Fix haproxy stats (#1039)Geoff Cox2017-12-151-2/+2
| | | | | | - `stats scope .` ends up blocking all backends - Renaming endpoint from `_stats` to `_haproxy_stats` so that it doesn't collide with CouchDB's `_stats` endpoint - Added a commented out stats auth line so that you can easily password protect
* Add couch_stats tracking back to couch_log (#1064)Peng Hui Jiang2017-12-145-16/+35
| | | issue #832
* Add coverage reports to more applicationsNick Vatamaniuc2017-12-115-3/+10
|
* Multiple fixes and refactoring of couch tests. (#1062)Eric Avdey2017-12-113-134/+169
|
* Allow to use index with or (#1038)Will Holley2017-12-112-7/+181
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since #816, mango JSON index on compound fields can be selected only if the selector make sure that all the fields listed in the index are always present. This adds a special case where all clauses of an `$or` can ensure that a field is present. For instance, if I had an index: [A, B] is_usable would now return true for the selector: { "A": "foo", "$or": { "B": "bar", "B": "baz" } } but false for: { "A": "foo", "$or": { "B": "bar", "C": "bar" } }
* Make q configurable for peruser dbsjiangphcn2017-12-084-16/+70
| | | | issue 875
* Fix replicator create target options testNick Vatamaniuc2017-12-051-62/+51
| | | | | | | Don't need to use local as source since it doesn't test anything specific to the code in question. Use credentials with http requests as it's a more realistic scenario. Avoid spawning couch server twice - once to start chttpd and then to start other couch servers.
* Remove references to etapAdam Kocoloski2017-12-014-46/+0
|
* Remove Bob's 2.0 TODO listAdam Kocoloski2017-12-011-10/+0
| | | | :)
* Remove Spidermonkey as an "optional" depedencyAdam Kocoloski2017-12-011-1/+1
| | | | | | It's required, and thus would already have been isntalled via the instructions in the INSTALL file. Also we don't mention it for any other operating system here.
* Fix eunit "suites" exampleAdam Kocoloski2017-12-011-1/+1
| | | | | | | As far as I can tell rebar will run all tests in an application if the specified suites are not found. Also, rebar appends the _tests suffix to the name of the suite automatically when it executes the search.
* warn instead of error when use_index not valid (#962)Will Holley2017-11-306-81/+112
| | | | | | | | | | | | | | | | | | If a user specifies a value for use_index that is not valid for the selector - i.e. it does not meet the coverage requirements of the selector or sort fields - attempt to fall back to a valid index (or database scan) rather than returning a 400 error. When a fallback occurs, populate the "warning" field in the response (as we already do when a full database scan takes place) with details of the fallback. This change is partially as mitigation for #816, which may lead to some previously valid indexes being deemed invalid, and also to make use_index less brittle in general. If an index that is used explicitly by active queries is removed, Couch will now generate warnings and there may be a performance impact, but the client will still get correct results.
* Remove invalid meck unloadEric Avdey2017-11-302-4/+2
| | | | | Remove invalid meck unload and catch around unload that was hiding this issue.
* Add missing methods to fake indexEric Avdey2017-11-302-6/+9
| | | | | | | | | | | Mocked index module missing a couple of methods called on late compaction stages. This leads to a crash, but since it's happening after the test's assertions, it bring the test to fail. Also small refactoring to encapsulate all mocking in a single function and move unrelated parts back to test's setup.
* Allow replicator documents to include params for db creationjiangphcn2017-11-284-8/+177
| | | | | - specify q in "create_target_params": {"q": "1", ...} issue-887
* Fix _explain for sort descending (#1025)Will Holley2017-11-282-1/+9
| | | | | | | | Handle the case when startkey and endkey are reversed. To create valid JSON we need to replace the internal representation of the startkey with a string. Fixes #1023
* Test duplicate fields in Mango selector (#998)Will Holley2017-11-231-0/+12
| | | | | | | | | | | | | | | | | | | Adds a test to verify the behaviour of duplicate fields in a Mango selector. The fix for CVE-2017-12635 resulted in CouchDB's JSON parser only recognising the last instance of duplicated fields in a JSON object. This represents a breaking change to Mango (_find) because, previuously, all instances would have been considered when evaluating a selector. This test verifies that Mango now only considers the last instance of a field, silently ignoring those that appear before it. TBD whether we can or should show an error when this occurs, since this leads to predicates silently being ignored.
* Fix index validation for nested $and (#1014)Will Holley2017-11-232-13/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | mango_selector:has_required_fields checks that a list of indexed fields is covered by a given selector. The implementation recurses through the selector, tracking fields that encounters. Unfortunately, this skipped peers of combination operators. For example, "selector": { "$and":[ "$and":[ "A": "foo" ], "$and":[ "B": "bar" ] ] } would skip the first nested "$and" operator and only return "B" as a covered field. This commit explicitly handles this situation (the only combination operator we care about is $and), so for the above selector we would correctly indentify "A" and "B" as covered fields.
* Fix replicator cluster stability race conditionNick Vatamaniuc2017-11-221-10/+63
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Replicator clustering module is in charge of keeping track of when the cluster is stable or unstable. A cluster is said to be "stable" if there aren't any new nodes added or removed for some period of time. Replicator document processor uses cluster state to determine what to do with document updates as they come in. If a document update comes during a time when cluster is unstable, the update is skipped. The idea is that when cluster becomes stable again, all the documents will be rescanned anyway. In order for document updates to not be dropped, there is an implicit constraint when cluster becomes stable -- after(couch_replicator_notifier gen_event broadcasts `{cluster, stable}` event, any subsequent calls to `couch_replicator_clustering:is_stable()` would return `true`. If that's not the case then this sequence of events is possible: 1. `mem3_cluster` process calls the `cluster_stable` callback 2. `couch_replicator_notifier` broadcasts `{cluster, stable}` event 3. `couch_replicator_doc_processor` starts processing documents 4. On first document update `couch_replicator_clustering:is_stable()` is `false`, because that gen_server wasn't notifier yet. 5. Document update is dropped. 6. There won't be any rescans until cluster membership is changed again. To fix this, switch to setting stable state first via a `gen_server` call. This way after the `{cluster, stable}` has been called, `is_stable()` is guaranteed to return `true`. Note: This issue is mostly theoretical. It was noticed when examining the code related to another bug. The chance of the clustering process going to sleep immediately after gen_event broadcast, then not handling the cast long enough for a document to be processed by doc processor is pretty low in practice.
* Update COMMITTERS.mdDiana Thayer2017-11-201-1/+1
|
* Move cluster_start_period and cluster_quiet_period to replicator sectionNick Vatamaniuc2017-11-171-4/+4
| | | | | Somehow entries ended up under [couch_per_user] but should be in the [replicator] section.
* (typo) fetchig -> fetchingDiana Thayer2017-11-171-1/+1
|
* Improve Mango test suite performance (#995)Will Holley2017-11-162-8/+34
| | | | | | | | | | | | * Remove artificial delays from database and index create/delete. * Wait for indexes to report as created/deleted during test setup. * Skip unnecessary database delete/create cycles. * Default to n=1 when creating test databases. We don't have tests that explicitly test n=3 scenarios and the tests generally run on a single-node harness. Defaulting to n=1 allows the test behaviour to be consistent when run on multi-node clusters. * Add delay on cluster setup for Mango tests to mitigate tests running before async cluster setup completes.