mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
Revert "rename: delete source entry metadata only, skipping hard links"
This reverts commit 03466f955e
.
fix https://github.com/seaweedfs/seaweedfs/issues/3386
This commit is contained in:
parent
5fbe437ee9
commit
303bd067b5
|
@ -122,11 +122,7 @@ func (f *Filer) doDeleteEntryMetaAndData(ctx context.Context, entry *Entry, shou
|
||||||
|
|
||||||
glog.V(3).Infof("deleting entry %v, delete chunks: %v", entry.FullPath, shouldDeleteChunks)
|
glog.V(3).Infof("deleting entry %v, delete chunks: %v", entry.FullPath, shouldDeleteChunks)
|
||||||
|
|
||||||
if !entry.IsDirectory() && !shouldDeleteChunks {
|
if storeDeletionErr := f.Store.DeleteOneEntry(ctx, entry); storeDeletionErr != nil {
|
||||||
if storeDeletionErr := f.Store.DeleteOneEntrySkipHardlink(ctx, entry.FullPath); storeDeletionErr != nil {
|
|
||||||
return fmt.Errorf("filer store delete skip hardlink: %v", storeDeletionErr)
|
|
||||||
}
|
|
||||||
} else if storeDeletionErr := f.Store.DeleteOneEntry(ctx, entry); storeDeletionErr != nil {
|
|
||||||
return fmt.Errorf("filer store delete: %v", storeDeletionErr)
|
return fmt.Errorf("filer store delete: %v", storeDeletionErr)
|
||||||
}
|
}
|
||||||
if !entry.IsDirectory() {
|
if !entry.IsDirectory() {
|
||||||
|
|
|
@ -23,7 +23,6 @@ type VirtualFilerStore interface {
|
||||||
FilerStore
|
FilerStore
|
||||||
DeleteHardLink(ctx context.Context, hardLinkId HardLinkId) error
|
DeleteHardLink(ctx context.Context, hardLinkId HardLinkId) error
|
||||||
DeleteOneEntry(ctx context.Context, entry *Entry) error
|
DeleteOneEntry(ctx context.Context, entry *Entry) error
|
||||||
DeleteOneEntrySkipHardlink(ctx context.Context, fullpath util.FullPath) error
|
|
||||||
AddPathSpecificStore(path string, storeId string, store FilerStore)
|
AddPathSpecificStore(path string, storeId string, store FilerStore)
|
||||||
OnBucketCreation(bucket string)
|
OnBucketCreation(bucket string)
|
||||||
OnBucketDeletion(bucket string)
|
OnBucketDeletion(bucket string)
|
||||||
|
@ -217,18 +216,6 @@ func (fsw *FilerStoreWrapper) DeleteOneEntry(ctx context.Context, existingEntry
|
||||||
return actualStore.DeleteEntry(ctx, existingEntry.FullPath)
|
return actualStore.DeleteEntry(ctx, existingEntry.FullPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fsw *FilerStoreWrapper) DeleteOneEntrySkipHardlink(ctx context.Context, fullpath util.FullPath) (err error) {
|
|
||||||
actualStore := fsw.getActualStore(fullpath)
|
|
||||||
stats.FilerStoreCounter.WithLabelValues(actualStore.GetName(), "delete").Inc()
|
|
||||||
start := time.Now()
|
|
||||||
defer func() {
|
|
||||||
stats.FilerStoreHistogram.WithLabelValues(actualStore.GetName(), "delete").Observe(time.Since(start).Seconds())
|
|
||||||
}()
|
|
||||||
|
|
||||||
glog.V(4).Infof("DeleteOneEntrySkipHardlink %s", fullpath)
|
|
||||||
return actualStore.DeleteEntry(ctx, fullpath)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (fsw *FilerStoreWrapper) DeleteFolderChildren(ctx context.Context, fp util.FullPath) (err error) {
|
func (fsw *FilerStoreWrapper) DeleteFolderChildren(ctx context.Context, fp util.FullPath) (err error) {
|
||||||
actualStore := fsw.getActualStore(fp + "/")
|
actualStore := fsw.getActualStore(fp + "/")
|
||||||
stats.FilerStoreCounter.WithLabelValues(actualStore.GetName(), "deleteFolderChildren").Inc()
|
stats.FilerStoreCounter.WithLabelValues(actualStore.GetName(), "deleteFolderChildren").Inc()
|
||||||
|
|
|
@ -65,7 +65,7 @@ func (mc *MetaCache) doInsertEntry(ctx context.Context, entry *filer.Entry) erro
|
||||||
return mc.localStore.InsertEntry(ctx, entry)
|
return mc.localStore.InsertEntry(ctx, entry)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mc *MetaCache) AtomicUpdateEntryFromFiler(ctx context.Context, oldPath util.FullPath, newEntry *filer.Entry, shouldDeleteChunks bool) error {
|
func (mc *MetaCache) AtomicUpdateEntryFromFiler(ctx context.Context, oldPath util.FullPath, newEntry *filer.Entry) error {
|
||||||
//mc.Lock()
|
//mc.Lock()
|
||||||
//defer mc.Unlock()
|
//defer mc.Unlock()
|
||||||
|
|
||||||
|
@ -77,14 +77,8 @@ func (mc *MetaCache) AtomicUpdateEntryFromFiler(ctx context.Context, oldPath uti
|
||||||
// leave the update to the following InsertEntry operation
|
// leave the update to the following InsertEntry operation
|
||||||
} else {
|
} else {
|
||||||
glog.V(3).Infof("DeleteEntry %s", oldPath)
|
glog.V(3).Infof("DeleteEntry %s", oldPath)
|
||||||
if shouldDeleteChunks {
|
if err := mc.localStore.DeleteEntry(ctx, oldPath); err != nil {
|
||||||
if err := mc.localStore.DeleteEntry(ctx, oldPath); err != nil {
|
return err
|
||||||
return err
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if err := mc.localStore.DeleteOneEntrySkipHardlink(ctx, oldPath); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -121,12 +115,6 @@ func (mc *MetaCache) FindEntry(ctx context.Context, fp util.FullPath) (entry *fi
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mc *MetaCache) DeleteEntrySkipHardlink(ctx context.Context, fp util.FullPath) (err error) {
|
|
||||||
//mc.Lock()
|
|
||||||
//defer mc.Unlock()
|
|
||||||
return mc.localStore.DeleteOneEntrySkipHardlink(ctx, fp)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (mc *MetaCache) DeleteEntry(ctx context.Context, fp util.FullPath) (err error) {
|
func (mc *MetaCache) DeleteEntry(ctx context.Context, fp util.FullPath) (err error) {
|
||||||
//mc.Lock()
|
//mc.Lock()
|
||||||
//defer mc.Unlock()
|
//defer mc.Unlock()
|
||||||
|
|
|
@ -36,7 +36,7 @@ func SubscribeMetaEvents(mc *MetaCache, selfSignature int32, client filer_pb.Fil
|
||||||
glog.V(4).Infof("creating %v", key)
|
glog.V(4).Infof("creating %v", key)
|
||||||
newEntry = filer.FromPbEntry(dir, message.NewEntry)
|
newEntry = filer.FromPbEntry(dir, message.NewEntry)
|
||||||
}
|
}
|
||||||
err := mc.AtomicUpdateEntryFromFiler(context.Background(), oldPath, newEntry, message.DeleteChunks)
|
err := mc.AtomicUpdateEntryFromFiler(context.Background(), oldPath, newEntry)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if message.OldEntry != nil && message.NewEntry != nil {
|
if message.OldEntry != nil && message.NewEntry != nil {
|
||||||
oldKey := util.NewFullPath(resp.Directory, message.OldEntry.Name)
|
oldKey := util.NewFullPath(resp.Directory, message.OldEntry.Name)
|
||||||
|
|
|
@ -223,7 +223,7 @@ func (wfs *WFS) handleRenameResponse(ctx context.Context, resp *filer_pb.StreamR
|
||||||
if resp.EventNotification.NewEntry != nil {
|
if resp.EventNotification.NewEntry != nil {
|
||||||
// with new entry, the old entry name also exists. This is the first step to create new entry
|
// with new entry, the old entry name also exists. This is the first step to create new entry
|
||||||
newEntry := filer.FromPbEntry(resp.EventNotification.NewParentPath, resp.EventNotification.NewEntry)
|
newEntry := filer.FromPbEntry(resp.EventNotification.NewParentPath, resp.EventNotification.NewEntry)
|
||||||
if err := wfs.metaCache.AtomicUpdateEntryFromFiler(ctx, "", newEntry, false); err != nil {
|
if err := wfs.metaCache.AtomicUpdateEntryFromFiler(ctx, "", newEntry); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -248,7 +248,7 @@ func (wfs *WFS) handleRenameResponse(ctx context.Context, resp *filer_pb.StreamR
|
||||||
|
|
||||||
} else if resp.EventNotification.OldEntry != nil {
|
} else if resp.EventNotification.OldEntry != nil {
|
||||||
// without new entry, only old entry name exists. This is the second step to delete old entry
|
// without new entry, only old entry name exists. This is the second step to delete old entry
|
||||||
if err := wfs.metaCache.AtomicUpdateEntryFromFiler(ctx, util.NewFullPath(resp.Directory, resp.EventNotification.OldEntry.Name), nil, resp.EventNotification.DeleteChunks); err != nil {
|
if err := wfs.metaCache.AtomicUpdateEntryFromFiler(ctx, util.NewFullPath(resp.Directory, resp.EventNotification.OldEntry.Name), nil); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue