mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-06 02:57:37 +01:00
* filer: end a listing at a short page from a store that fills its pages ListEntries read a directory a page at a time and stopped at the first empty page, so every listing the caller's limit did not cut ended with one more scan of the store, from the last name on, that returned nothing: two scans for a directory smaller than a page. A page that comes back short of its limit now ends the listing when the store says it fills its pages (the new optional FullPageListingStore). leveldb, leveldb2, leveldb3 and TiKV do: they iterate the directory's keys until the limit is handed over or the keys end. A store that cuts a page of names to the limit and then drops some (the Redis stores, for a name whose entry is gone or expired) can end a page short with names behind it; it does not declare the interface and is asked until a page comes back empty, as before. TiKV's listing swallowed an iterator error while it skipped the start name or an expired entry, and ended the page there. It returns the error now: a page that ends short must mean the keys ended. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * filer: see through the path translator for a store that fills its pages A path-specific store is wrapped in FilerStorePathTranslator, which does not implement FullPageListingStore, so its directories kept the extra empty scan. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: keep the last listed name when a refill lists nothing A page that lost entries to expiry is refilled from its last name. A refill that found nothing returned an empty last name, so the next page of a store that does not fill its pages started over at the top of the directory and listed every entry again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: name the stores that fill their pages instead of an interface A short list of store names in Filer.ListsFullPages replaces the FullPageListingStore interface, the wrapper method and the per-store declarations. A path translator reports its backend's name, so it needs no unwrapping. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * foundationdb: read a listing in batches until it fills the page Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * redis: fill a listing page past orphaned and expired members Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * redis2: fill a listing page past orphaned and expired members Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mongodb: report a cursor error that ends a listing Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * tarantool: fail a listing on a malformed reply Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: test the last listed name after a refill that lists nothing Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: end a listing at a short page from any store Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * rocksdb: build the tests against the current NewFiler Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * rocksdb: count only listed entries toward the page limit Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * rocksdb: return the decode error instead of ending the listing Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: MapleWhiteZZZ <18653045+MapleWhiteZZZ@users.noreply.github.com> Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com>
36 lines
988 B
Go
36 lines
988 B
Go
package filer
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
// A page that lost entries to expiry is filled again from its last name. When
|
|
// that refill lists nothing, the page still ends at the last name it listed: a
|
|
// caller resuming from an empty name would list the directory again.
|
|
func TestStreamListKeepsTheLastNameWhenARefillListsNothing(t *testing.T) {
|
|
f, store := newTestFilerWithStubStore(t)
|
|
putSweepTestEntry(t, store, "/dir", true, 0, time.Now())
|
|
for i := 0; i < 20; i++ {
|
|
crtime := time.Now()
|
|
if i < 5 {
|
|
crtime = crtime.Add(-time.Hour)
|
|
}
|
|
putSweepTestEntry(t, store, fmt.Sprintf("/dir/f%02d", i), false, 60, crtime)
|
|
}
|
|
|
|
listed := 0
|
|
last, err := f.StreamListDirectoryEntries(context.Background(), "/dir", "", false, 100, "", "", "", func(*Entry) (bool, error) {
|
|
listed++
|
|
return true, nil
|
|
})
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if listed != 15 || last != "f19" {
|
|
t.Fatalf("listed %d entries ending at %q, want 15 ending at f19", listed, last)
|
|
}
|
|
}
|