mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-06 19:17:28 +01:00
* filer: grow the metadata log collection on its own, fall back when it is full metaLog.volumeGrowthCount (default 2) is sent with assigns into the metadata log collection, so it grows by a few volumes instead of the master's default growth. When that collection cannot take the piece, the assign falls back to the collection the log uses without the override, so a full cluster does not stall the log. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: keep the metadata log in its own collection by default metaLog.collection now defaults to filer-meta, so purging old log days empties whole volumes instead of leaving log chunks scattered across the default collection's volumes. Setting it to "" keeps the log in the filer's -collection as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: default -max to 10 to leave room for the metadata log collection The default collection still grows by 7 volumes; the extra slots keep the filer's metadata log collection (2 volumes by default) from taking them. Go and Rust volume servers share the new default. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: bound the meta log collection's share of the assign budget A meta log collection that cannot grow (for example a replication the cluster cannot place) keeps answering with retryable errors, so the first assign used the whole shared budget and the fallback was never tried. Give it 10s, then fall back, and skip it for a minute after a failure instead of waiting on it at every flush. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: name the default meta log collection so no bucket maps to it A bucket named filer-meta mapped to the same collection, and deleting it from the admin page or weed shell drops the collection directly at the master, taking the metadata log with it. Bucket names cannot contain "_", and filer group buckets map to "<group>_<bucket>". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: clear the meta log overrides after the viper test Setting the collection back to its default value kept an explicit override, so the defaults test passed even without the SetDefault. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: retry the meta log collection once its fallback also fails The pause after a failed meta collection assign kept pieces on the shared collection for a full minute even when that assign failed too, so meta volumes that finished growing stayed unused while every flush failed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: pick a default meta log collection no grouped bucket maps to Filer group "_filer" with bucket "meta" maps to "_filer_meta". The default now keeps its only "_" in front, and the test checks every group and bucket split of it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: default the meta log collection to _meta Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: keep the default meta log collection on bucket delete A filer that logs elsewhere did not treat _meta as reserved, so deleting a bucket a storage rule maps to _meta dropped the collection other filers write their logs to. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
167 lines
5.6 KiB
Go
167 lines
5.6 KiB
Go
package filer
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/seaweedfs/seaweedfs/weed/pb"
|
|
"github.com/seaweedfs/seaweedfs/weed/pb/filer_pb"
|
|
"github.com/seaweedfs/seaweedfs/weed/s3api/s3bucket"
|
|
"github.com/seaweedfs/seaweedfs/weed/util"
|
|
)
|
|
|
|
// The metadata log's collection resolution must let operators redirect the
|
|
// internal /topics/.system/log chunks into their own collection without
|
|
// touching where user data goes, and must be strictly backward compatible
|
|
// when the override is unset.
|
|
|
|
func TestMetaLogCollectionResolution(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
target string // filer.options.metaLog.collection override
|
|
filerDefault string // -collection flag value
|
|
ruleCollection string // storage rule matched on the log path
|
|
want string
|
|
}{
|
|
{
|
|
name: "no override: filer default wins (today's behaviour)",
|
|
target: "",
|
|
filerDefault: "mydata",
|
|
ruleCollection: "",
|
|
want: "mydata",
|
|
},
|
|
{
|
|
name: "no override anywhere: still empty (default collection)",
|
|
target: "",
|
|
filerDefault: "",
|
|
ruleCollection: "",
|
|
want: "",
|
|
},
|
|
{
|
|
name: "override wins over filer default",
|
|
target: "filer-meta",
|
|
filerDefault: "mydata",
|
|
ruleCollection: "",
|
|
want: "filer-meta",
|
|
},
|
|
{
|
|
name: "override wins over matched rule",
|
|
target: "filer-meta",
|
|
filerDefault: "",
|
|
ruleCollection: "rulecol",
|
|
want: "filer-meta",
|
|
},
|
|
{
|
|
name: "no override but rule set: rule used (unchanged fallback chain)",
|
|
target: "",
|
|
filerDefault: "",
|
|
ruleCollection: "rulecol",
|
|
want: "rulecol",
|
|
},
|
|
}
|
|
|
|
for _, tc := range tests {
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
// Drive the same setter a running filer would use post-construction.
|
|
f := &Filer{}
|
|
f.metaLogTargetCollection = tc.target
|
|
f.metaLogCollection = tc.filerDefault
|
|
if got := f.metaLogCollectionFor(tc.ruleCollection); got != tc.want {
|
|
t.Errorf("metaLogCollectionFor(%q) = %q, want %q", tc.ruleCollection, got, tc.want)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestMetaLogReplicationResolution(t *testing.T) {
|
|
f := &Filer{}
|
|
f.metaLogTargetReplication = "110"
|
|
f.metaLogReplication = "010"
|
|
if got := f.metaLogReplicationFor("001"); got != "110" {
|
|
t.Errorf("override must win, got %q", got)
|
|
}
|
|
f.metaLogTargetReplication = ""
|
|
if got := f.metaLogReplicationFor("001"); got != "010" {
|
|
t.Errorf("filer replication must win when no override, got %q", got)
|
|
}
|
|
f.metaLogReplication = ""
|
|
if got := f.metaLogReplicationFor("001"); got != "001" {
|
|
t.Errorf("rule replication must be used last, got %q", got)
|
|
}
|
|
}
|
|
|
|
// TestViperReadsMetaLogOverrides proves the exact viper keys the docs promise
|
|
// are read into the fields a running filer uses.
|
|
func TestViperReadsMetaLogOverrides(t *testing.T) {
|
|
v := util.GetViper()
|
|
v.Set("filer.options.metaLog.collection", "meta-elsewhere")
|
|
v.Set("filer.options.metaLog.replication", "100")
|
|
defer func() {
|
|
// nil drops the override, so later reads see the defaults again.
|
|
v.Set("filer.options.metaLog.collection", nil)
|
|
v.Set("filer.options.metaLog.replication", nil)
|
|
}()
|
|
|
|
f := NewFiler(pb.ServerDiscovery{}, nil, "", "", "", "", "", 255, nil)
|
|
defer func() {
|
|
close(f.deletionQuit)
|
|
f.flushCancel()
|
|
f.LocalMetaLogBuffer.ShutdownLogBuffer()
|
|
f.LocalMetaLogBuffer.WaitForShutdown()
|
|
}()
|
|
if got := f.metaLogTargetCollection; got != "meta-elsewhere" {
|
|
t.Fatalf("NewFiler did not read the collection override: %q", got)
|
|
}
|
|
if got := f.metaLogTargetReplication; got != "100" {
|
|
t.Fatalf("NewFiler did not read the replication override: %q", got)
|
|
}
|
|
}
|
|
|
|
// TestBucketCollectionKeepsMetaLogTargetCollection mirrors the guarantee that
|
|
// protects the filer's default collection: when a bucket resolves to the
|
|
// collection the system metadata log was redirected to, deleting the bucket
|
|
// must not drop that collection (it backs internal log volumes).
|
|
func TestBucketCollectionKeepsMetaLogTargetCollection(t *testing.T) {
|
|
f, store, master := newFilerWithFakeMaster(t)
|
|
// Operator redirected the meta log to its own collection...
|
|
f.metaLogTargetCollection = "filer-meta"
|
|
// ...and a bucket happens to resolve to that very collection.
|
|
f.FilerConf.SetLocationConf(&filer_pb.FilerConf_PathConf{
|
|
LocationPrefix: "/buckets/a",
|
|
Collection: "filer-meta",
|
|
})
|
|
seedBucket(t, store, util.FullPath("/buckets/a"))
|
|
|
|
if err := f.DeleteEntryMetaAndData(context.Background(), "/buckets/a", true, false, true, false, nil, time.Time{}); err != nil {
|
|
t.Fatalf("DeleteEntryMetaAndData: %v", err)
|
|
}
|
|
|
|
select {
|
|
case call := <-master.calls:
|
|
t.Fatalf("the meta-log target collection was deleted by a bucket delete: %q", call.name)
|
|
default:
|
|
}
|
|
}
|
|
|
|
func TestMetaLogDefaultsToOwnCollection(t *testing.T) {
|
|
f := NewFiler(pb.ServerDiscovery{}, nil, "", "", "", "", "", 255, nil)
|
|
defer func() {
|
|
close(f.deletionQuit)
|
|
f.flushCancel()
|
|
f.LocalMetaLogBuffer.ShutdownLogBuffer()
|
|
f.LocalMetaLogBuffer.WaitForShutdown()
|
|
}()
|
|
if f.metaLogTargetCollection != "_meta" || f.metaLogVolumeGrowthCount != 2 {
|
|
t.Fatalf("defaults: collection %q growth %d", f.metaLogTargetCollection, f.metaLogVolumeGrowthCount)
|
|
}
|
|
if s3bucket.VerifyS3BucketName(defaultMetaLogCollection) == nil {
|
|
t.Fatalf("a bucket can be named %q, so deleting it would drop the metadata log", defaultMetaLogCollection)
|
|
}
|
|
for i, c := range defaultMetaLogCollection {
|
|
if c == '_' && i > 0 && s3bucket.VerifyS3BucketName(defaultMetaLogCollection[i+1:]) == nil {
|
|
t.Fatalf("filer group %q with bucket %q maps to %q", defaultMetaLogCollection[:i], defaultMetaLogCollection[i+1:], defaultMetaLogCollection)
|
|
}
|
|
}
|
|
}
|