NiloCK opened a new pull request, #5872: URL: https://github.com/apache/couchdb/pull/5872
against issue https://github.com/apache/couchdb/issues/5871 1. Keep a single `mem3_cluster` process for the entire lifetime of the `couch_peruser` gen_server instead of creating a new one on each state reset. 2. Refactored `init_state/0` to `init_state/1` which accepts an optional existing `mem3_cluster` pid to reuse. When called from `init/1`, it passes `undefined` to create a new process. When called from `handle_cast(update_config, ...)`, it passes the existing pid to reuse. 3. Simplified `handle_cast(cluster_unstable, ...)` to only clean up changes handlers and reset the `states` and `cluster_stable` fields, without calling `init_state` at all. The existing `mem3_cluster` process continues monitoring cluster changes. 4. Added `terminate/2` callback to properly clean up both changes handlers and the `mem3_cluster` process when the gen_server stops. 5. Added guard clause to `start_listening/1` to handle the case when peruser is disabled (`mem3_cluster_pid` is `undefined`). 6. Fixed `exit_changes/1` to handle `undefined` states (when changes haven't been started yet). <!-- Thank you for your contribution! Please file this form by replacing the Markdown comments with your text. If a section needs no action - remove it. Also remember, that CouchDB uses the Review-Then-Commit (RTC) model of code collaboration. Positive feedback is represented +1 from committers and negative is a -1. The -1 also means veto, and needs to be addressed to proceed. Once there are no objections, the PR can be merged by a CouchDB committer. See: http://couchdb.apache.org/bylaws.html#decisions for more info. --> ## Overview <!-- Please give a short brief for the pull request, what problem it solves or how it makes things better. --> Solves unbounded memory usage described in #5871 ## Testing recommendations <!-- Describe how we can test your changes. Does it provide any behaviour that the end users could notice? --> Uncertain. Existing issue is not documented / demonstrated under test. ## Related Issues or Pull Requests <!-- If your changes affect multiple components in different repositories please put links to those issues or pull requests here. --> ## Checklist - [ ] Code is written and works correctly - [ ] Changes are covered by tests - [ ] Any new configurable parameters are documented in `rel/overlay/etc/default.ini` - [ ] Documentation changes were made in the `src/docs` folder - [ ] Documentation changes were backported (separated PR) to affected branches -- 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]
