From cea831914bebd1eb3603dab43f4d03dcbceabcb7 Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Tue, 3 May 2022 12:12:40 +0200 Subject: [PATCH] cmd/utils: double limit on free-disk monitor (#24781) This PR doubles the limit on which to trigger automatic shutdown, and also changes the timer to run once every 30s instead of 60s. --- cmd/geth/consolecmd_test.go | 3 ++- cmd/utils/cmd.go | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/cmd/geth/consolecmd_test.go b/cmd/geth/consolecmd_test.go index 845ede2f9c..6abf7a7ecb 100644 --- a/cmd/geth/consolecmd_test.go +++ b/cmd/geth/consolecmd_test.go @@ -43,7 +43,8 @@ func runMinimalGeth(t *testing.T, args ...string) *testgeth { // --networkid=1337 to avoid cache bump // --syncmode=full to avoid allocating fast sync bloom allArgs := []string{"--ropsten", "--networkid", "1337", "--syncmode=full", "--port", "0", - "--nat", "none", "--nodiscover", "--maxpeers", "0", "--cache", "64"} + "--nat", "none", "--nodiscover", "--maxpeers", "0", "--cache", "64", + "--datadir.minfreedisk", "0"} return runGeth(t, append(allArgs, args...)...) } diff --git a/cmd/utils/cmd.go b/cmd/utils/cmd.go index f8e40b187c..47ad3b22c8 100644 --- a/cmd/utils/cmd.go +++ b/cmd/utils/cmd.go @@ -77,11 +77,11 @@ func StartNode(ctx *cli.Context, stack *node.Node, isConsole bool) { signal.Notify(sigc, syscall.SIGINT, syscall.SIGTERM) defer signal.Stop(sigc) - minFreeDiskSpace := ethconfig.Defaults.TrieDirtyCache + minFreeDiskSpace := 2 * ethconfig.Defaults.TrieDirtyCache // Default 2 * 256Mb if ctx.GlobalIsSet(MinFreeDiskSpaceFlag.Name) { minFreeDiskSpace = ctx.GlobalInt(MinFreeDiskSpaceFlag.Name) } else if ctx.GlobalIsSet(CacheFlag.Name) || ctx.GlobalIsSet(CacheGCFlag.Name) { - minFreeDiskSpace = ctx.GlobalInt(CacheFlag.Name) * ctx.GlobalInt(CacheGCFlag.Name) / 100 + minFreeDiskSpace = 2 * ctx.GlobalInt(CacheFlag.Name) * ctx.GlobalInt(CacheGCFlag.Name) / 100 } if minFreeDiskSpace > 0 { go monitorFreeDiskSpace(sigc, stack.InstanceDir(), uint64(minFreeDiskSpace)*1024*1024) @@ -131,7 +131,7 @@ func monitorFreeDiskSpace(sigc chan os.Signal, path string, freeDiskSpaceCritica } else if freeSpace < 2*freeDiskSpaceCritical { log.Warn("Disk space is running low. Geth will shutdown if disk space runs below critical level.", "available", common.StorageSize(freeSpace), "critical_level", common.StorageSize(freeDiskSpaceCritical)) } - time.Sleep(60 * time.Second) + time.Sleep(30 * time.Second) } }