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

Do not require snapshot on Log.WriteEntriesTo(). #2453

Merged
merged 1 commit into from
Apr 30, 2015

Conversation

benbjohnson
Copy link
Contributor

Overview

This pull request fixes a bug where snapshots were always sent when connecting to the leader -- even when not required. This also fixes an issue where Log.entries were not being cleared out on close/open which isn't a problem in practice but can cause issues in tests.

This commit fixes a bug where snapshots were always sent when connecting
to the leader -- even when not required.
buf := make([]byte, logEntryHeaderSize+len(e.Data))
copy(buf, e.encodedHeader())
copy(buf[logEntryHeaderSize:], e.Data)
if len(l.entries) > 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is just about adding some checks to the code?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, this is to ensure that Log.entries is always contiguous. A similar check used to exist but was altered with some changes around Log.lastLogIndex

@otoolep
Copy link
Contributor

otoolep commented Apr 30, 2015

+1

benbjohnson added a commit that referenced this pull request Apr 30, 2015
Do not require snapshot on Log.WriteEntriesTo().
@benbjohnson benbjohnson merged commit dd93ce2 into master Apr 30, 2015
@toddboom
Copy link
Contributor

post-merge +1

@toddboom toddboom deleted the fix-write-entries-to branch May 5, 2015 08:02
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.

3 participants