-
Notifications
You must be signed in to change notification settings - Fork 21.5k
cmd/geth: Graceful shutdown if disk is full #22103
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
Merged
Merged
Changes from 5 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
b5adbc4
cmd/geth: monitoring free disk space to avoid db corruption
alex347 d6a22bf
code formatting
alex347 0a42462
revert sigterm channel global var
alex347 ccc95b8
prevent duplicate sigterm signals
alex347 4aba670
don't terminate geth if getFreeDiskSpace is not working
alex347 d98a93e
Update cmd/utils/diskusage.go
alex347 17e224a
friendly disk space formatting
alex347 bd99637
monitor free disk space only for mainnet and never in fast sync mode;
alex347 b8e1eb1
Update diskusage.go
fjl 6bf421c
cmd/geth: datadir.minfreedisk flag
alex347 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| // Copyright 2021 The go-ethereum Authors | ||
| // This file is part of the go-ethereum library. | ||
| // | ||
| // The go-ethereum library is free software: you can redistribute it and/or modify | ||
| // it under the terms of the GNU Lesser General Public License as published by | ||
| // the Free Software Foundation, either version 3 of the License, or | ||
| // (at your option) any later version. | ||
| // | ||
| // The go-ethereum library is distributed in the hope that it will be useful, | ||
| // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| // GNU Lesser General Public License for more details. | ||
| // | ||
| // You should have received a copy of the GNU Lesser General Public License | ||
| // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>. | ||
|
|
||
| // +build !windows | ||
|
|
||
| package utils | ||
|
|
||
| import ( | ||
| "fmt" | ||
|
|
||
| "golang.org/x/sys/unix" | ||
| ) | ||
|
|
||
| var stat unix.Statfs_t | ||
|
|
||
| func getFreeDiskSpace(path string) (uint64, error) { | ||
|
|
||
| err := unix.Statfs(path, &stat) | ||
| if err != nil { | ||
alex347 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| return 0, fmt.Errorf("failed to call Statfs: %v", err) | ||
| } | ||
|
|
||
| // Available blocks * size per block = available space in bytes | ||
| return stat.Bavail * uint64(stat.Bsize), nil | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| // Copyright 2021 The go-ethereum Authors | ||
| // This file is part of the go-ethereum library. | ||
| // | ||
| // The go-ethereum library is free software: you can redistribute it and/or modify | ||
| // it under the terms of the GNU Lesser General Public License as published by | ||
| // the Free Software Foundation, either version 3 of the License, or | ||
| // (at your option) any later version. | ||
| // | ||
| // The go-ethereum library is distributed in the hope that it will be useful, | ||
| // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| // GNU Lesser General Public License for more details. | ||
| // | ||
| // You should have received a copy of the GNU Lesser General Public License | ||
| // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>. | ||
|
|
||
| package utils | ||
|
|
||
| import ( | ||
| "fmt" | ||
|
|
||
| "golang.org/x/sys/windows" | ||
| ) | ||
|
|
||
| func getFreeDiskSpace(path string) (uint64, error) { | ||
|
|
||
| cwd, err := windows.UTF16PtrFromString(path) | ||
| if err != nil { | ||
| return 0, fmt.Errorf("failed to call UTF16PtrFromString: %v", err) | ||
| } | ||
|
|
||
| var freeBytesAvailableToCaller, totalNumberOfBytes, totalNumberOfFreeBytes uint64 | ||
| if err := windows.GetDiskFreeSpaceEx(cwd, &freeBytesAvailableToCaller, &totalNumberOfBytes, &totalNumberOfFreeBytes); err != nil { | ||
| return 0, fmt.Errorf("failed to call GetDiskFreeSpaceEx: %v", err) | ||
| } | ||
|
|
||
| return freeBytesAvailableToCaller, nil | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.