mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-05 02:27:26 +01:00
* filer: let a suppressing caller collect the parents it creates
Under suppressed metadata events, ensureParentDirectoryEntry creates
missing parent directories without announcing them and releases their
stamps, since the caller's own event covers only its entry.
WithCreatedParents keeps the suppression and also collects those
directories, with their stamps, so the caller can announce them once its
change commits.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: announce the directories a rename creates at its destination
A rename into a path whose parents do not exist yet created them without
metadata events. A peer filer with its own store replays events into that
store and never got the new directories: it found the moved entry by path,
but listing its new parent's parent showed nothing. The rename now
publishes a create event for each new parent ahead of its own event, after
the commit, and releases their stamps if it fails.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: announce a parent a rename promotes from a file to a directory
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: announce a promoted parent as replacing the file
A parent promoted from a file to a directory was announced as a create,
so a peer whose store does not upsert refused the insert over the file
row it already held and could not move past the event. Announce the
promotion with the file as the old entry, both from a plain create and
from a rename's collected parents, so a peer replays it as a replacement.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: keep announcing a promoted parent as a create
filer.sync applies a same-path update through FilerSink.UpdateEntry, and
the destination filer refuses to turn its file into a directory, so an
event carrying the file as OldEntry stalls the sync. Ordinary writes have
always published a promotion as a create; the rename publishes the same.
This reverts commit 85760c084f.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
40 lines
1.2 KiB
Go
40 lines
1.2 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
|
|
}
|