mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-05 02:27:26 +01:00
* filer: pass the reader's context to persisted metadata log listings The day and minute listings behind ReadPersistedLogBuffer used context.Background(), so nothing scoped to the subscription reached them. List through one helper that takes the caller's context. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: aggregated metadata stream reads the log files of peers with their own store A filer with its own store never holds another filer's persisted metadata log: log file writes emit no events and the bootstrap traverse skips the log directory. The aggregated stream read history from the local log directory and the in-memory aggregate ring only, and the ring restarts empty, refilled from each peer's saved offset. A subscriber whose cursor was older than that missed every event a peer recorded before it, for example the S3 lifecycle worker replaying expirations. Aggregated reads now also list the log directories of followed peers not known to share this filer's store, merged by file name, so the existing ordered reader and chunk-ref path serve their history. Local streams, which peers aggregate from, stay local. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: bound peer log listings and fail the read when one fails Each peer listing gets its own deadline, so a peer that stalls mid-listing cannot hold the read. A failed listing now fails the read instead of silently hiding that peer's persisted files; peers already retired as unreachable are left out. Peers are asked from the same start name the caller uses for its own store instead of the whole directory. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: keep a still-unreachable peer out of log listings after its mark expires A followed peer that keeps refusing connections is marked removed once, and the mark is dropped with its resume point an hour later. It was then listed again and its failing listing ended every aggregated persisted-log read. Leave out any peer refusing connections for peerUnreachableRemovalAfter, marked or not. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: subscribe tests track their peers on the test filer's store Aggregated reads now list the log files of followed peers with their own store. The subscribe tests' peers have no server and share the test filer's store, so record that instead of dialing them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
57 lines
1.7 KiB
Go
57 lines
1.7 KiB
Go
package filer
|
|
|
|
import "context"
|
|
|
|
type suppressMetadataEventsKey struct{}
|
|
|
|
type createdParentsKey struct{}
|
|
|
|
// WithSuppressedMetadataEvents disables automatic metadata event emission for
|
|
// nested filer operations that are part of a larger logical change, such as a
|
|
// rename implemented via create+delete.
|
|
func WithSuppressedMetadataEvents(ctx context.Context) context.Context {
|
|
return context.WithValue(ctx, suppressMetadataEventsKey{}, true)
|
|
}
|
|
|
|
func metadataEventsSuppressed(ctx context.Context) bool {
|
|
if ctx == nil {
|
|
return false
|
|
}
|
|
suppressed, _ := ctx.Value(suppressMetadataEventsKey{}).(bool)
|
|
return suppressed
|
|
}
|
|
|
|
// WithCreatedParents suppresses events like WithSuppressedMetadataEvents and
|
|
// collects the parent directories created, or promoted from files, on the way.
|
|
// No event of the caller covers them, so it announces them once its change
|
|
// commits.
|
|
func WithCreatedParents(ctx context.Context, created *[]*Entry) context.Context {
|
|
return context.WithValue(WithSuppressedMetadataEvents(ctx), createdParentsKey{}, created)
|
|
}
|
|
|
|
func recordCreatedParent(ctx context.Context, dirEntry *Entry) bool {
|
|
created, _ := ctx.Value(createdParentsKey{}).(*[]*Entry)
|
|
if created == nil {
|
|
return false
|
|
}
|
|
*created = append(*created, dirEntry)
|
|
return true
|
|
}
|
|
|
|
type peerLogFilesKey struct{}
|
|
|
|
// WithPeerLogFiles makes persisted-log reads under ctx also list the log
|
|
// files of followed peers that keep their own store. The aggregated stream
|
|
// needs them: those files never reach this filer's store.
|
|
func WithPeerLogFiles(ctx context.Context) context.Context {
|
|
return context.WithValue(ctx, peerLogFilesKey{}, true)
|
|
}
|
|
|
|
func readsPeerLogFiles(ctx context.Context) bool {
|
|
if ctx == nil {
|
|
return false
|
|
}
|
|
peers, _ := ctx.Value(peerLogFilesKey{}).(bool)
|
|
return peers
|
|
}
|