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: open wal SIGSEGV #86

Closed
wants to merge 2 commits into from
Closed
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
6 changes: 5 additions & 1 deletion stream/changelog/changelog.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,10 @@ func (stream *Stream) Close() error {

// open opens the replay log, try to truncate the corrupted tail if there's any
func open(dir string, opts *wal.Options) (*wal.Log, error) {
// if opts is nil, use the default options
if opts == nil {
opts = &wal.Options{}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe change to wal.DefaultOptions is better?

}
rlog, err := wal.Open(dir, opts)
if errors.Is(err, wal.ErrCorrupt) {
// try to truncate corrupted tail
Expand All @@ -248,7 +252,7 @@ func open(dir string, opts *wal.Options) (*wal.Log, error) {
}

if len(lastSeg) == 0 {
return nil, err
return nil, fmt.Errorf("no valid segments in %s: %w", dir, err)
}
if err = truncateCorruptedTail(filepath.Join(dir, lastSeg), opts.LogFormat); err != nil {
return nil, fmt.Errorf("truncate corrupted tail fail: %w", err)
Expand Down
Loading