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

[db] panic when writing db returns no space #3664

Closed
wants to merge 1 commit into from

Conversation

huof6829
Copy link
Contributor

Description

User can define different partition path for chaindb/indexdb/triedb... in config.yaml. Monitor chaindb is not enough.
These dbs are almost all large after a long time, so check writing db can be accurate.

Fixes #3629

Type of change

Please delete options that are not relevant.

  • [] Bug fix (non-breaking change which fixes an issue)
  • [] New feature (non-breaking change which adds functionality)
  • [] Code refactor or improvement
  • [] Breaking change (fix or feature that would cause a new or changed behavior of existing functionality)
  • [] This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • [] make test
  • [] fullsync
  • [] Other test (please specify)

Test Configuration:

  • Firmware version:
  • Hardware:
  • Toolchain:
  • SDK:

Checklist:

  • [] My code follows the style guidelines of this project
  • [] I have performed a self-review of my code
  • [] I have commented my code, particularly in hard-to-understand areas
  • [] I have made corresponding changes to the documentation
  • [] My changes generate no new warnings
  • [] I have added tests that prove my fix is effective or that my feature works
  • [] New and existing unit tests pass locally with my changes
  • [] Any dependent changes have been merged and published in downstream modules

@huof6829 huof6829 requested a review from a team as a code owner October 13, 2022 14:55
@sonarcloud
Copy link

sonarcloud bot commented Oct 13, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@codecov
Copy link

codecov bot commented Oct 13, 2022

Codecov Report

Merging #3664 (c1c2c96) into master (e9732a1) will decrease coverage by 0.17%.
The diff coverage is 81.36%.

@@            Coverage Diff             @@
##           master    #3664      +/-   ##
==========================================
- Coverage   74.95%   74.78%   -0.18%     
==========================================
  Files         269      266       -3     
  Lines       23819    23769      -50     
==========================================
- Hits        17854    17775      -79     
- Misses       5039     5069      +30     
+ Partials      926      925       -1     
Impacted Files Coverage Δ
db/config.go 100.00% <ø> (ø)
db/trie/mptrie/node.go 100.00% <ø> (ø)
ioctl/newcmd/action/action.go 89.09% <ø> (+9.55%) ⬆️
ioctl/newcmd/node/nodedelegate.go 70.19% <0.00%> (-0.95%) ⬇️
ioctl/newcmd/node/nodeprobationlist.go 90.90% <0.00%> (-4.33%) ⬇️
db/db_bolt.go 70.73% <20.00%> (-1.78%) ⬇️
action/protocol/execution/evm/evm.go 44.57% <26.66%> (-0.86%) ⬇️
db/trie/mptrie/hashnode.go 36.36% <41.17%> (-54.55%) ⬇️
db/trie/mptrie/merklepatriciatrie.go 78.73% <46.80%> (-12.70%) ⬇️
db/trie/mptrie/leafiterator.go 62.06% <50.00%> (ø)
... and 22 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@@ -86,6 +88,9 @@ func (b *BoltDB) Put(namespace string, key, value []byte) (err error) {
}
}
if err != nil {
if errors.Is(err, syscall.ENOSPC) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or should we use errors.Cause(err) == syscall.ENOSPC? can you look at bolt db source code to verify?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

errors.Cause(err) returns write /run/data/chain.db: no space left on device
syscall.ENOSPC is no space left on device
errors.Is means syscall.ENOSPC matches err

Copy link
Member

@Liuhaai Liuhaai Oct 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

errors.Is(ENOSPC, erros.Cause(err))

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// An error is considered to match a target if it is equal to that target or if
// it implements a method Is(error) bool such that Is(target) returns true.
func Is(err, target error) bool { return stderrors.Is(err, target) }

i think better to use errors.Cause() == xxx if possible? this is how error is decided in the codebase, try to be consistent

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// An error is considered to match a target if it is equal to that target or if
// it implements a method Is(error) bool such that Is(target) returns true.
func Is(err, target error) bool { return stderrors.Is(err, target) }

can you verify (or write a test case) this is the case?

@@ -86,6 +88,9 @@ func (b *BoltDB) Put(namespace string, key, value []byte) (err error) {
}
}
if err != nil {
if errors.Is(err, syscall.ENOSPC) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// An error is considered to match a target if it is equal to that target or if
// it implements a method Is(error) bool such that Is(target) returns true.
func Is(err, target error) bool { return stderrors.Is(err, target) }

can you verify (or write a test case) this is the case?

log.L().Panic("Failed to stop monitor disk space.", zap.Error(err))
}
}()

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like you are reverting an earlier commit? can you open another PR to just revert that commit?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. Split this pr into #3685 and #3686

@huof6829 huof6829 closed this Nov 4, 2022
@huof6829 huof6829 deleted the bolt_disk_full branch December 29, 2022 02:08
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 this pull request may close these issues.

Panic if no space is left
4 participants