Increasing memory usage with debug log level and noisy logs from reduce functions
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- erlang
- Domain
- databases, performance
Research direction
Start by running the linked gist and its compose.yml against the reported CouchDB versions, comparing debug and info logging while the reduce view processes continuous writes. Trace the reduce-function logging path and verify that debug-level reproduction no longer shows steadily increasing memory usage under sustained indexing.
Written by the indexing model from the issue text.
Description
Description
When log level is set to debug, there exists at least one view with "lengthy" emissions (many characters, for example uuids) with a reduce function, and there is a constant inflow of documents, CouchDb will gradually increase RAM usage, until it runs out of memory.
Steps to Reproduce
This can be replicated on latest version of CouchDb (I just launched a local instance in a docker container) in single node.
In this gist https://gist.github.com/dianabarsan/408ed8b08bb653a6d16c04ba2126556b, there is a script that:
- sets log level to debug
- creates a database with one ddoc with one reduce function
- pushes 1 million documents that would be indexed
- triggers view indexes
Running this script against a CouchDb in a docker container (compose.yml also provided in the gist) should trigger gradually increasing RAM usage.
Expected Behaviour
Memory should be released, even when log level is debug.
Your Environment
Production server: docker image of CouchDb v. 3.3.3 launched in Kubernetes cluster hosted on AWS
Local test server: docker image of CouchDb 3.4.2, launched in docker container on Manjaro Linux.
Additional Context
In a three node CouchDb cluster, we have observed one node gradually increasing RAM usage compared to the other two nodes - up to 200GB vs 3GB. The k8s node would eventually run out of RAM and be expelled.
Our deployment receives a rather constant flow of new documents.
The only difference between the cluster nodes was that the runaway RAM node had the log level set to debug.
Upon further investigation, it turned out that having reduce functions (in our case _stats) for views that have "lengthy" emissions was triggering the high RAM usage, presumably due to accumulating large debug logs.
After reverting the log level to info, this behavior disappeared and RAM usage became consistent within the CouchDb cluster.
For my local deployment, I have noticed that RAM does eventually get released gradually AFTER there are no more writes. In our production environment this was never the case.
- Dominant language
- Erlang
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 5h 24m
- Merged PRs (30d)
- 10
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from apache/couchdb
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 40/100
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 40/100
-
enhancement
Difficulty 5/5 Over a week Newbie friendliness 45/100
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 45/100
-
enhancement needs-triage
Difficulty 3/5 1-2 days Newbie friendliness 55/100
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
xinnan-tech/xiaozhi-fde-talk#263 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
avniproject/avni-server#1074 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100