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

Fix LRU deadlock + regression test and improve comments / logging #862

Merged
merged 17 commits into from
Aug 29, 2018

Conversation

richardartoul
Copy link
Contributor

@richardartoul richardartoul commented Aug 28, 2018

  • Fix LRU deadlock that could occur when the events channel was filled up. Achieved this by making the series object call WiredList.Update() outside of a lock as well as adding the concept of a NonBlockingUpdate. Also added a regression test.
  • Made LRU events channel size configurable for stress testing purposes.
  • Improve "invariant violated" style logging so that metrics are emitted if wired list invariants are violated.
  • Added a new "CloseIfFromDisk" method to the database block as an additional layer of protection.

@richardartoul richardartoul changed the title Fix LRU deadlock + regression test and improve comments / logging [WIP] Fix LRU deadlock + regression test and improve comments / logging Aug 28, 2018
@richardartoul richardartoul changed the title [WIP] Fix LRU deadlock + regression test and improve comments / logging Fix LRU deadlock + regression test and improve comments / logging Aug 28, 2018
@richardartoul richardartoul changed the title Fix LRU deadlock + regression test and improve comments / logging [WIP] Fix LRU deadlock + regression test and improve comments / logging Aug 28, 2018
@richardartoul richardartoul changed the title [WIP] Fix LRU deadlock + regression test and improve comments / logging Fix LRU deadlock + regression test and improve comments / logging Aug 28, 2018
@codecov
Copy link

codecov bot commented Aug 28, 2018

Codecov Report

Merging #862 into master will decrease coverage by 0.06%.
The diff coverage is 62.19%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #862      +/-   ##
==========================================
- Coverage   78.43%   78.36%   -0.07%     
==========================================
  Files         391      391              
  Lines       33222    33268      +46     
==========================================
+ Hits        26058    26072      +14     
- Misses       5372     5392      +20     
- Partials     1792     1804      +12
Flag Coverage Δ
#dbnode 81.28% <62.19%> (-0.09%) ⬇️
#m3ninx 71.99% <ø> (ø) ⬆️
#query 67.81% <ø> (-0.04%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8e93c11...45cbf94. Read the comment docs.

if shouldUnlock {
s.Unlock()
}
}()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we refactor this to avoid multiple unlock calls? Perhaps something like:

var (
  b block.DatabaseBlock
  updateList *block.WiredList
)

s.Lock()
defer func() {
  s.Unlock()
  if b != nil && updateList != nil {
    updateList.BlockingUpdate(b) // Update outside of lock
  }
}()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh yeah thats better thanks

Copy link
Collaborator

@robskillington robskillington left a comment

Choose a reason for hiding this comment

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

LGTM

@richardartoul richardartoul merged commit 399d904 into master Aug 29, 2018
@prateek prateek deleted the ra/improve-lru branch September 29, 2018 18: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.

2 participants