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

Fix two panics in the WAL #3884

Merged
merged 3 commits into from
Aug 28, 2015
Merged

Fix two panics in the WAL #3884

merged 3 commits into from
Aug 28, 2015

Conversation

jwilder
Copy link
Contributor

@jwilder jwilder commented Aug 28, 2015

These are panics that occur when the server is starting but hits errors. You can recreate them by truncating the metadata index file a few bytes. I managed to get a truncated file locally from a bad shutdown.

If LoadMetadataIndex() tries to log an error, it causes a panic because the
logger is not set until Open() is called, which is after LoadMetaDataIndex() returns.
Instead, just set the logger up when the WAL is created.
addToCache is called in a goroutine and can panic if the server is closed while opening.  If
part of the open func errors, it returns an error and immediately calls close.  close sets
p.cache to nil which causes the goroutine trying to initialized the cache to panic as well.  The
goroutine should run under a write lock to avoid this race/panic.
@@ -500,6 +500,9 @@ func (l *Log) openPartitionFiles() error {
for _, p := range l.partitions {

go func(p *Partition) {
p.mu.Lock()
Copy link
Contributor

Choose a reason for hiding this comment

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

Why does this address the issue?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See the commit message for f5f8f04

@otoolep
Copy link
Contributor

otoolep commented Aug 28, 2015

Sounds reasonable, thanks @jwilder

jwilder added a commit that referenced this pull request Aug 28, 2015
Fix two panics in the WAL
@jwilder jwilder merged commit ef1699a into master Aug 28, 2015
@jwilder jwilder deleted the jw-wal branch August 28, 2015 20:03
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

2 participants