-
Notifications
You must be signed in to change notification settings - Fork 362
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
Ranges cache: add ownership check #6004
Conversation
No linked issues found. Please add the corresponding issues in the pull request description. |
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.
Wow!
@@ -92,7 +92,13 @@ func (m *RangeManager) GetValueGE(ctx context.Context, ns committed.Namespace, i | |||
} | |||
return nil, ErrKeyNotFound | |||
} | |||
vBytes, _, err := value.Value(nil) | |||
vBytes, owned, err := value.Value(nil) | |||
if !owned { |
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.
Wow, great catch!
Is there any way for us to change this bad ownership status? IIUC when !owned
, iterator it
shares underlying state with some other iterator. I would expect this state to persist, and now very many calls (including future getValue()
s) will keep on copying every value. It might be considerably more efficient if we could convince Pebble to unshare the iterator -- say by creating future iterators on a new iterator hierarchy. (It goes without saying that this is no reason to delay this PR!)
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.
Since we pass
nil
when calling forValue
, the initialized buffer isn't owned by the calling function. This makes the behavior of the data inside the buffer unexpected. You can read about it here some more ([P1], [P2]).Closes 1578