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

Restoring large databases eats up all the RAM #714

Closed
magik6k opened this issue Feb 15, 2019 · 6 comments
Closed

Restoring large databases eats up all the RAM #714

magik6k opened this issue Feb 15, 2019 · 6 comments
Labels
kind/maintenance Maintenance tasks, such as refactoring, with no impact in features. priority/P0 Critical issue that requires immediate attention.

Comments

@magik6k
Copy link

magik6k commented Feb 15, 2019

When trying to restore a large backup, Badger starts taking lots of memory, eventually crashing with OOM.

  • Backup size: 107G (11457947 keys)
  • System: Linux (4.20.6, Arch), 64G RAM
  • Badger commit: 2f79792
@magik6k
Copy link
Author

magik6k commented Feb 15, 2019

@magik6k
Copy link
Author

magik6k commented Feb 15, 2019

I also tried setting opts.ValueLogLoadingMode = options.FileIO in badger/cmd/restore.go as I had issues with mmaped pages getting locked up in the past, but it didn't help.

@manishrjain manishrjain added the priority/P0 Critical issue that requires immediate attention. label Feb 15, 2019
@manishrjain
Copy link
Contributor

Based on the heap, it is using around 5GB of RAM, which is not extreme but not ideal either. I think what's happening is that the restore is going full throttle, without any bounds, i.e. it is creating writes, without considering how many are in fly already. We can add a throttle control, so it doesn't create too many pending writes.

Changing this to case over a buffered channel would be the easiest way to throttle it:

default:

@manishrjain
Copy link
Contributor

There's also the Throttle lib that I wrote, available in y package, which can do this in a better way.

@magik6k
Copy link
Author

magik6k commented Feb 15, 2019

Might also be worth noting - this ran restoring to/from NFS storage on ZFS HDDs, and the backup file might have been cached in RAM, so writes could be way slower than reads.

@manishrjain manishrjain added the kind/maintenance Maintenance tasks, such as refactoring, with no impact in features. label Mar 18, 2019
@ashish-goswami
Copy link
Contributor

Fixed in #762

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/maintenance Maintenance tasks, such as refactoring, with no impact in features. priority/P0 Critical issue that requires immediate attention.
Development

No branches or pull requests

3 participants