Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReadDir inode leak causes memory leak #785

Open
1978629634 opened this issue Jan 11, 2024 · 0 comments · May be fixed by #786
Open

ReadDir inode leak causes memory leak #785

1978629634 opened this issue Jan 11, 2024 · 0 comments · May be fixed by #786

Comments

@1978629634
Copy link

1978629634 commented Jan 11, 2024

What happened?

The memory of the goofys process keeps growing and cannot reclaim the memory via
sync;echo 3 > /proc/sys/vm/drop_caches;killall -USR1 goofys;
Use go pprof heap to analyze memory
image
The inode created by ReadDir takes up a lot of memory

How can we reproduce it

I wrote a simple go program to reproduce the problem

package main

import (
	"fmt"
	"os"
)

func main() {
	_, err := os.ReadDir(os.Args[1])
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Println(os.Args[1])
}

Create 1000 files in the /mnt/goofys/test directory
Repeat run

go run main.go /mnt/goofys/test
sync;echo 3 > /proc/sys/vm/drop_caches;killall -USR1 goofys;

goofys log

/root/goofys: main.INFO Received user defined signal 1
/root/goofys: main.INFO forgot xxx inodes
/root/goofys: main.INFO 1004 inodes

/root/goofys: main.INFO Received user defined signal 1
/root/goofys: main.INFO forgot xxx inodes
/root/goofys: main.INFO 2003 inodes

/root/goofys: main.INFO Received user defined signal 1
/root/goofys: main.INFO forgot xxx inodes
/root/goofys: main.INFO 3006 inodes
...

The number of unrecyclable inodes will continue to increase

Problem causes

goofys ReadDir will cache all child inodes, but OS only caches the inodes of the parent directory. When memory is tight or echo 3 > drop_caches. OS call goofys to forget the parent inode. At this time, all child nodes will become dirty data exist in The fs.inodes map cannot be recycled.

What did you expect to happen?

sync;echo 3 > /proc/sys/vm/drop_caches;killall -USR1 goofys;can reclaim the memory

@1978629634 1978629634 linked a pull request Jan 11, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant