mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 10:07:28 +01:00
mq logstore: leave an older file unbounded when the next name was clamped
A file without a recorded last message time was bounded by the end of the next file's start second, on the reasoning that it ended before the next began. When the next file is a slower leader's window clamped into that second, its name says nothing about when its messages, or the older file's, end; the older file was bounded too early, a later mark qualified, and a resume past it skipped its remaining messages. The next file now bounds it only when its name is not later than its first message; otherwise the older file stays unbounded, no mark after it qualifies, and a resume lists from before it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
6073de4087
commit
9bc88511fb
2 files changed
+15
-6
No files matched your search
@@ -65,11 +65,13 @@ func (x *logFileIndex) add(entries []*filer_pb.Entry) {
|
||||
x.maxOffset = max(x.maxOffset, maxOffset)
|
||||
}
|
||||
if x.open {
|
||||
// a file without its last message time was named by its first, before any name was
|
||||
// moved later, and ended before the next file began
|
||||
// a file without its last message time was named by its first and ended before the
|
||||
// next file began, which only a next name not moved later than its messages tells
|
||||
nameEndTsNs := int64(math.MaxInt64)
|
||||
if nameTime, err := topic.ParseLogFileTime(entry.Name); err == nil {
|
||||
nameEndTsNs = nameTime.Add(time.Second).UnixNano() - 1
|
||||
if firstTsNs, ok := logFileTsNs(entry, mq.ExtendedAttrTimestampMin); !ok || firstTsNs >= nameTime.UnixNano() {
|
||||
nameEndTsNs = nameTime.Add(time.Second).UnixNano() - 1
|
||||
}
|
||||
}
|
||||
x.lastTsNs, x.open = max(x.lastTsNs, nameEndTsNs), false
|
||||
}
|
||||
|
||||
@@ -232,9 +232,12 @@ func TestReadFromDiskResumesPastManyLaterSortingFiles(t *testing.T) {
|
||||
for _, tc := range []struct {
|
||||
name string
|
||||
first time.Time
|
||||
// the earlier file predates recorded message times
|
||||
older bool
|
||||
}{
|
||||
{"names clamped to a slow leader's later second", second.Add(-time.Minute)},
|
||||
{"messages overlapping in one second", second.Add(100 * time.Millisecond)},
|
||||
{"names clamped to a slow leader's later second", second.Add(-time.Minute), false},
|
||||
{"messages overlapping in one second", second.Add(100 * time.Millisecond), false},
|
||||
{"names clamped after a file without its message times", second.Add(-time.Minute), true},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
timeAttrs := func(minTs, maxTs time.Time) map[string][]byte {
|
||||
@@ -245,7 +248,11 @@ func TestReadFromDiskResumesPastManyLaterSortingFiles(t *testing.T) {
|
||||
}
|
||||
volume := serveChunks(t, map[string][]byte{"/3,01": logChunk(t, second.UnixNano(), second.Add(4*time.Second).UnixNano())})
|
||||
a := volume.file(topic.LogFileName(second, 0), "3,01")
|
||||
a.Extended = timeAttrs(second, second.Add(4*time.Second))
|
||||
if tc.older {
|
||||
a.Name = second.Format(topic.TIME_FORMAT)
|
||||
} else {
|
||||
a.Extended = timeAttrs(second, second.Add(4*time.Second))
|
||||
}
|
||||
files := []*filer_pb.Entry{a}
|
||||
for i := range logFileIndexStride + 6 {
|
||||
ts := tc.first.Add(time.Duration(i) * time.Millisecond)
|
||||
|
||||
Reference in new issue
Block a user