Skip to content
This repository was archived by the owner on Jun 23, 2025. It is now read-only.

Commit ca20a26

Browse files
committed
Fix segments sorting by id
1 parent ebad5d9 commit ca20a26

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

internal/wal/wal_forge.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,14 +293,14 @@ func (wl *walForge) segments() ([]string, error) {
293293
return nil, err
294294
}
295295

296+
fullSegmentPrefix := filepath.Join(config.Config.WALDir, segmentPrefix)
297+
296298
sort.Slice(files, func(i, j int) bool {
297-
s1, _ := strconv.Atoi(strings.Split(strings.TrimPrefix(files[i], segmentPrefix), ".")[0])
298-
s2, _ := strconv.Atoi(strings.Split(strings.TrimPrefix(files[i], segmentPrefix), ".")[0])
299+
s1, _ := strconv.Atoi(strings.Split(strings.TrimPrefix(files[i], fullSegmentPrefix), ".")[0])
300+
s2, _ := strconv.Atoi(strings.Split(strings.TrimPrefix(files[j], fullSegmentPrefix), ".")[0])
299301
return s1 < s2
300302
})
301303

302-
// TODO: Check that the segment files are returned in the correct order
303-
// The order has to be in ascending order of the segment index.
304304
return files, nil
305305
}
306306

0 commit comments

Comments
 (0)