- 
                Notifications
    You must be signed in to change notification settings 
- Fork 21.5k
trie: use explicit errors in stacktrie (instead of panic) #28361
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
Conversation
80bf446    to
    76922a4      
    Compare
  
    abeef8a    to
    6e530c3      
    Compare
  
    6e530c3    to
    566818c      
    Compare
  
            
          
                trie/stacktrie.go
              
                Outdated
          
        
      | if bytes.Compare(t.last, k) >= 0 { | ||
| return errors.New("non-ascending key order") | ||
| } | ||
| if err := t.insert(t.root, k, value, nil); err != nil { | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to track/update the first/last markers, then do the insertion.
Otherwise the key of current inserted entry will be larger than last, can be detected as right boundary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right!
| Closing this for now, might not be needed any more | 
| @rjl493456442 PTAL | 
…8361) This PR removes panics from stacktrie (mostly), and makes the Update return errors instead. While adding tests for this, I also found that one case of possible corruption was not caught, which is now fixed.
…hereum#28361)" This reverts commit 5cbd950.
…hereum#28361)" This reverts commit 5cbd950.
…8361) This PR removes panics from stacktrie (mostly), and makes the Update return errors instead. While adding tests for this, I also found that one case of possible corruption was not caught, which is now fixed.
…8361) This PR removes panics from stacktrie (mostly), and makes the Update return errors instead. While adding tests for this, I also found that one case of possible corruption was not caught, which is now fixed.
Follow-up to #28350 .
This PR removes
panics from stacktrie (mostly), and makes theUpdatereturn errors instead. While adding tests for this, I also found that one case of possible corruption was not caught.If we inserted into an existing node, we noticed and panic:ed. However, it was possible to insert into an "empty slot" further back, so inserting at
0xaafollowed by0x10did not panic. To handle that, I now added alastPathto the stacktrie, to keep record of the path of the last inserted item.This can also be useful for keeping track of the right hand boundary.