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

Broker log recovery #2167

Merged
merged 2 commits into from
Apr 4, 2015
Merged

Broker log recovery #2167

merged 2 commits into from
Apr 4, 2015

Conversation

benbjohnson
Copy link
Contributor

Overview

This pull request adds recovery to the messaging.Topic when opening. If any partial messages are found then the file is truncated at that point and started from there. This can occur when ungracefully shutting down a server. It can leave half written messages at the end of segments.

@@ -1017,6 +1009,19 @@ func NewTopicReader(path string, index uint64, streaming bool) *TopicReader {
}
}

// Seek seeks to a position the current segment.
func (r *TopicReader) Seek(offset int64, whence int) (int64, error) {
assert(whence == os.SEEK_CUR, "topic reader can only seek to a relative position")
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like you could remove this assert by simply having this function ignore whence, and then calling Seek() with os.SEEK_CUR. Of course, you may wish to catch errors in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If someone passes a non-SEEK_CUR in the future I want to catch it immediately. If I silently override it then it'll be a pain to debug.

@otoolep
Copy link
Contributor

otoolep commented Apr 3, 2015

+1, change looks good to me. I do have some questions about the warnf statements in there, whether you meant to keep them.

Don't forget the CHANGELOG.

@toddboom
Copy link
Contributor

toddboom commented Apr 4, 2015

👍

This pull request adds recovery to the messaging.Topic when opening. If
any partial messages are found then the file is truncated at that point
and started from there. This can occur when ungracefully shutting down
a server. It can leave half written messages at the end of segments.
benbjohnson added a commit that referenced this pull request Apr 4, 2015
@benbjohnson benbjohnson merged commit fbca2b1 into master Apr 4, 2015
@benbjohnson benbjohnson deleted the broker-recovery branch April 4, 2015 14:24
mark-rushakoff pushed a commit that referenced this pull request Jan 9, 2019
Mock implementation of various services
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.

None yet

3 participants