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

cache: Handle missing tiles stricter #2406

Merged
merged 2 commits into from
Mar 18, 2021
Merged

Conversation

pav-kv
Copy link
Contributor

@pav-kv pav-kv commented Mar 18, 2021

GetMerkleNodes is always called with existing nodes, therefore SubtreeCache.preload
will always try to read existing tiles. We should return an error if some tile is not found,
instead of silently creating an empty tile.

Addresses some comments in #2404.
Part of #2378.

@pav-kv pav-kv requested a review from Martin2112 March 18, 2021 13:18
@pav-kv pav-kv requested a review from a team as a code owner March 18, 2021 13:18
@pav-kv pav-kv mentioned this pull request Mar 18, 2021
2 tasks
@pav-kv
Copy link
Contributor Author

pav-kv commented Mar 18, 2021

Interesting, there is some failing MySQL unit test. Looking.

@pav-kv pav-kv changed the title cache: Handle some error cases cache: Handle missing tiles strictly Mar 18, 2021
@pav-kv pav-kv changed the title cache: Handle missing tiles strictly cache: Handle missing tiles stricter Mar 18, 2021
if err := s.cacheSubtree(s.newEmptySubtree(id)); err != nil {
return err
}
if r := len(want); r != 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not 100% sure if there's an edge case where this happens. It might possibly be where the tree grows enough to require a new tile that wasn't previously written.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The key point is in the PR description: we will not try to read this new tile with GetMerkleNodes (and hence SubtreeCache.preload). The latter method is used in 2 scenarios:

  1. Sequencer's transaction: read compact range of the current tree. These nodes (and hence tiles) always exist, unless someone removed them from the DB.
  2. Reading proofs. These "read" transactions also know the current tree size, and request the existing nodes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a leftover from maps, I believe. There we could read a leaf which previously did not exist, so we would need empty tiles silently added.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe it was added for the map. It's a long time ago now.

@codecov
Copy link

codecov bot commented Mar 18, 2021

Codecov Report

Merging #2406 (0783cec) into master (293f83b) will not change coverage.
The diff coverage is 0.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2406   +/-   ##
=======================================
  Coverage   65.80%   65.80%           
=======================================
  Files         106      106           
  Lines        7670     7670           
=======================================
  Hits         5047     5047           
+ Misses       2100     2097    -3     
- Partials      523      526    +3     
Impacted Files Coverage Δ
storage/cache/subtree_cache.go 58.85% <0.00%> (ø)
client/log_client.go 70.93% <0.00%> (-2.33%) ⬇️
log/operation_manager.go 87.30% <0.00%> (-1.06%) ⬇️
storage/mysql/tree_storage.go 52.84% <0.00%> (+3.10%) ⬆️

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 293f83b...0783cec. Read the comment docs.

@pav-kv
Copy link
Contributor Author

pav-kv commented Mar 18, 2021

Fixed the tests.

@pav-kv pav-kv merged commit 6080b90 into google:master Mar 18, 2021
@pav-kv pav-kv deleted the cache_errors branch March 18, 2021 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants