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

wal: release wal locks before renaming directory on init #5855

Merged
merged 1 commit into from
Jul 4, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions wal/wal.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,22 @@ func Create(dirpath string, metadata []byte) (*WAL, error) {
return nil, err
}

if err := os.RemoveAll(dirpath); err != nil {
// rename of directory with locked files doesn't work on windows; close
// the WAL to release the locks so the directory can be renamed
w.Close()
if err := os.Rename(tmpdirpath, dirpath); err != nil {
return nil, err
}
if err := os.Rename(tmpdirpath, dirpath); err != nil {
// reopen and relock
newWAL, oerr := Open(dirpath, walpb.Snapshot{})
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we delete this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Open will create the file pipeline

Copy link
Contributor

Choose a reason for hiding this comment

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

Right. thanks.

if oerr != nil {
return nil, oerr
}
if _, _, _, err := newWAL.ReadAll(); err != nil {
newWAL.Close()
return nil, err
}

w.fp = newFilePipeline(w.dir, segmentSizeBytes)
return w, nil
return newWAL, nil
}

// Open opens the WAL at the given snap.
Expand Down