LRU memory in Alpha server by default set to a negative value in MacOS

Moved from GitHub dgraph/4737

Posted by prashant-shahi:

What version of Dgraph are you using?

Dgraph version   : v1.2.0
Dgraph SHA-256   : ff6a20cdd76a03a37f916b039b82bf0120b1d8ffb89edba90cecbac0652cc207
Commit SHA-1     : 24b4b7439
Commit timestamp : 2020-01-27 15:53:31 -0800
Branch           : HEAD
Go version       : go1.13.5

What is the hardware spec (RAM, OS)?

MacOS Catlina version 10.15.2
Memory: 8 GB 1600 MHz DDR3

Steps to reproduce the issue (command/config used to run Dgraph).

curl -sSf https://get.dgraph.io | bash
$ /usr/local/bin/dgraph alpha
[Decoder]: Using assembly version of decoder

2020/02/06 02:04:39 LRU memory (--lru_mb) must be at least 1024 MB. Currently set to: -1.000000

For more information on --lru_mb please read https://docs.dgraph.io/deploy/#config

Expected behaviour and actual result.

Expected to bring up the Alpha server by setting LRU memory to 25% of the total memory as it is done in Linux.

MichelDiz commented :

This must be some characteristic of mac OS. As the --lru_mb isn’t defined at all by the binary or anything.

animesh2049 commented :

I think this is expected behavior, does it cause any problem on macOS? @prashant-shahi

prashant-shahi commented :

@animesh2049 It doesn’t work with the default settings on macOS as it does on Linux.
But yeah, it works when I manually set --lru_mb.

I also have a same issue

Something curious is happening. I don’t use Docker natively on my macOS. However, I am not able to reproduce this problem using binaries or a VM. The user (@zhouqiang-cl) reports that it happened to him using Docker with k8s enabled.

I tested using binaries locally, changing Shells. And all tests I managed to run without needing the flag. Apparently this problem was not supposed to be happening. Perhaps it is something related to permission. The docker instance may not have permissions to request values on the OS or machine.

Maybe, Dgraph should have a default value when it is unable to infer the values it needs (such as RAM size).