community.mongodb icon indicating copy to clipboard operation
community.mongodb copied to clipboard

mongodb_linux: Check rhel7/8 thp settings

Open rhysmeister opened this issue 1 year ago • 5 comments

SUMMARY

The following tasks checks the transparent huge pages settings...

https://github.com/ansible-collections/community.mongodb/blob/master/roles/mongodb_linux/tasks/main.yml#L129

Looks like there could be a difference with how RHEL 7 and 8 display this data meaning it's broken.

In RHEL8 it's

cat /sys/kernel/mm/transparent_hugepage/enabled [always] madvise never

RHEL7 the value is just a single word, i.e. "never" or "always"

ISSUE TYPE
  • Bug Report
COMPONENT NAME

mongodb_linux

rhysmeister avatar Oct 12 '22 14:10 rhysmeister

Either change the check to:

cat /sys/kernel/mm/transparent_hugepage/enabled | grep -o "\[never\]"

Or don't check at all and just enable the service!

I would go w/ the second option.

eRadical avatar Oct 22 '22 16:10 eRadical

I guess this was done for idempotency reasons so it probably needs option 1

rhysmeister avatar Oct 23 '22 10:10 rhysmeister

Check this on a couple of docker images and the output seems the same for RHEL 7/8 versions.

➜ ~ docker run -ti roboxes/rhel7 bash Unable to find image 'roboxes/rhel7:latest' locally latest: Pulling from roboxes/rhel7 5c526373c5e2: Pull complete Digest: sha256:27979023e0819ff152dd7c20f37d4204212faa11602d617c3065de05b99241f5 Status: Downloaded newer image for roboxes/rhel7:latest bash: /sbin/consoletype: No such file or directory [root@9337841b8ffd ~]# cat /sys/kernel/mm/transparent_hugepage/enabled always [madvise] never [root@9337841b8ffd ~]# exit exit ➜ ~ docker run -ti roboxes/rhel8 bash Unable to find image 'roboxes/rhel8:latest' locally latest: Pulling from roboxes/rhel8 57040e96b1fd: Pull complete Digest: sha256:855975aecdf9673542d7af8e896707c049dfde9c70419a5b098123ca760bfa08 Status: Downloaded newer image for roboxes/rhel8:latest [root@d4c5c4e5de2c ~]# cat /sys/kernel/mm/transparent_hugepage/enabled always [madvise] never

rhysmeister avatar Oct 23 '22 11:10 rhysmeister

Attempted various older version of CentOS 7 and I can't find a single instance where this setting is a single word...

It's always like this...

Status: Downloaded newer image for centos:7.1.1503 [root@196b1c2dcf59 /]# cat /sys/kernel/mm/transparent_hugepage/enabled always [madvise] never

rhysmeister avatar Oct 23 '22 11:10 rhysmeister

Yes... that is expected.

# cat /sys/kernel/mm/transparent_hugepage/enabled
always [madvise] never
# echo always > /sys/kernel/mm/transparent_hugepage/enabled
# cat /sys/kernel/mm/transparent_hugepage/enabled
[always] madvise never

I would go w/ second option but w/ an addition to the systemd unit file:

RemainAfterExit=yes

This will consider the unit running even if it's oneshot.

But still we are in a situation where someone can change the hugepages at runtime. For that we ought to setup a systemd timer.

eRadical avatar Oct 24 '22 15:10 eRadical