From ca20a26d3145c1b730ab0304eaa61373b14fa58c Mon Sep 17 00:00:00 2001 From: ralph-hatoum Date: Sun, 1 Jun 2025 22:22:30 +0200 Subject: [PATCH] Fix segments sorting by id --- internal/wal/wal_forge.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/wal/wal_forge.go b/internal/wal/wal_forge.go index edd5bff4e..fed30b26c 100644 --- a/internal/wal/wal_forge.go +++ b/internal/wal/wal_forge.go @@ -293,14 +293,14 @@ func (wl *walForge) segments() ([]string, error) { return nil, err } + fullSegmentPrefix := filepath.Join(config.Config.WALDir, segmentPrefix) + sort.Slice(files, func(i, j int) bool { - s1, _ := strconv.Atoi(strings.Split(strings.TrimPrefix(files[i], segmentPrefix), ".")[0]) - s2, _ := strconv.Atoi(strings.Split(strings.TrimPrefix(files[i], segmentPrefix), ".")[0]) + s1, _ := strconv.Atoi(strings.Split(strings.TrimPrefix(files[i], fullSegmentPrefix), ".")[0]) + s2, _ := strconv.Atoi(strings.Split(strings.TrimPrefix(files[j], fullSegmentPrefix), ".")[0]) return s1 < s2 }) - // TODO: Check that the segment files are returned in the correct order - // The order has to be in ascending order of the segment index. return files, nil }