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

rocksdb: handle reuse of closed batches #66

Closed
wants to merge 1 commit into from

Conversation

erikgrinaker
Copy link
Contributor

Fixes a bug uncovered by new tests.

@erikgrinaker erikgrinaker self-assigned this Mar 9, 2020
Copy link
Contributor

@melekes melekes left a comment

Choose a reason for hiding this comment

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

🤗 great to see tests resulting in uncovering bugs

return err
func (b *rocksDBBatch) Write() error {
if b.batch == nil {
return nil
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe we need to return an error instead of silently ignoring write. we should help developer uncover his/her errors (not executing Set/Delete on batch), not ignoring them.

Copy link
Contributor Author

@erikgrinaker erikgrinaker Mar 9, 2020

Choose a reason for hiding this comment

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

Then why did you approve #67? 🙂 This can only be nil if we write a closed or empty batch, in which case we need to silently ignore the write to satisfy the semantics tested by #67. If we instead set b.batch to a new, empty batch on close we will have a memory leak.

Copy link
Contributor

Choose a reason for hiding this comment

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

This can only be nil if we write a closed or empty batch, in which case we need to silently ignore the write to satisfy the semantics tested by #67.

can't you modify #67 if you agree with my logic?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I'll submit a new PR. It will be a bit more breaking, because we have to change the Batch interface to return errors etc, but I agree it's a better solution.

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