[SERVER-18113] Packages should disable transparent hugepages Created: 18/Apr/15  Updated: 06/Feb/23  Resolved: 06/Feb/23

Status: Closed
Project: Core Server
Component/s: Packaging
Affects Version/s: 3.0.0, 3.0.1, 3.0.2
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Ben McCann Assignee: [DO NOT ASSIGN] Backlog - Server Development Platform Team (SDP) (Inactive)
Resolution: Won't Do Votes: 0
Labels: initscript, sdp-backlog-purge
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to DOCS-5330 Using /etc/rc.local to disable THP re... Closed
related to SERVER-17522 THP startup warnings can become stale Closed
Assigned Teams:
Server Development Platform
Operating System: ALL
Steps To Reproduce:

Install MongoDB 3.0.2 and run with WiredTiger

cat /var/log/mongodb/mongodb.log

Look for warnings in the log:

2015-04-18T05:16:30.880+0000 I CONTROL  [initandlisten] 
2015-04-18T05:16:30.880+0000 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2015-04-18T05:16:30.880+0000 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2015-04-18T05:16:30.880+0000 I CONTROL  [initandlisten] 
2015-04-18T05:16:30.880+0000 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2015-04-18T05:16:30.880+0000 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2015-04-18T05:16:30.880+0000 I CONTROL  [initandlisten] 

Participants:

 Description   

The script in /etc/init.d/mongod should disable transparent hugepages. WiredTiger is complaining on startup because this isn't being done.

Here's a patch:

        if [ -f /sys/kernel/mm/transparent_hugepage/enabled ]; then
            if grep -q "\[always\]" /sys/kernel/mm/transparent_hugepage/enabled; then
                echo never > /sys/kernel/mm/transparent_hugepage/enabled
                if [ "$?" != 0 ]; then
                    echo "Error disabling transparent_hugepages, are you running in a linux container?" >&2
                    echo "If the server fails to start, check that transparent hugepages are disabled." >&2
                fi
            fi
        fi



 Comments   
Comment by Iryna Zhuravlova [ 16/Nov/22 ]

After a careful backlog refinement, the team decided to close this ticket because of its low priority and limited resource capacity. If you believe that this ticket requires additional attention from the team and should be re-opened, feel free to change the status to "Needs Scheduling" and ping me or @alexander.neben

Comment by Ramon Fernandez Marina [ 22/May/15 ]

The jury is still out on whether it's a good idea for MongoDB init scripts to make system-wide changes that may affect other parts of the system, or whether it's better to leave it up to the users to decide what system-wide settings are better for their deployments. While the former approach may seem more convenient, the latter one is less intrusive and closer to the principle of least surprise.

This ticket remains open to evaluate the benefits of both approaches.

Comment by Ben McCann [ 21/May/15 ]

The warnings are unsettling especially for folks not very familiar transparent hugepages. I'm curious what people think about the solution posted by Kevin Pulo on https://jira.mongodb.org/browse/DOCS-5330

Comment by Kevin Pulo [ 05/May/15 ]

The THP-related MongoDB documentation is available at http://docs.mongodb.org/manual/reference/transparent-huge-pages/. However, you should also note SERVER-17522 and DOCS-5330.

Comment by Ramon Fernandez Marina [ 19/Apr/15 ]

chengas123, it's not uncommon to disable THP at the end of init (e.g.: /etc/rc.local) even after mongod has started; you'll get a warning in the logs but mongod won't use THP.

I believe the reason toku disables THP in the init scripts is because it will refuse to start if THP are enabled, which is not the case for mongod.

Comment by Ben McCann [ 18/Apr/15 ]

Hmm, I sort of see what you're saying. I'm having a hard time figuring out how to do that though. I spent hours trying to make this setting persist across reboots on an EC2 instance and couldn't figure out how to do that. Part of the problem is that many of the ways I've seen suggested for setting this take effect after init and so you'll still get this warning with each boot when MongoDB starts. We were using TokuMX on some servers and I notice that they do this in their init script, which was the only way I could figure out how to fix the warning.

If we decide that it shouldn't be added to the init script, it would at least be nice to document a way of setting this that will solve the problem such that the warning no longer appears in our logs.

Comment by Ernie Hershey [ 18/Apr/15 ]

I don't think we want to make changes like this in the init script that would have system-wide impact beyond mongodb processes and override the setting being made elsewhere.

It might be a good idea later to optionally do this at package installation time, but for now we leave any system-wide changes like this or filesystem readahead settings up to users to tune themselves based on suggested settings in our documentation.

If it were possible to set this on a per-process basis, like ulimits and numa settings, it would make more sense in the init script.

Generated at Thu Feb 08 03:46:36 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.