From 5caff2c0f0bf2038b731b1a9ba557f8234ff78ef Mon Sep 17 00:00:00 2001 From: Konstantin Lebedev <9497591+kmlebedev@users.noreply.github.com> Date: Tue, 6 Jun 2023 21:08:27 +0500 Subject: [PATCH] fix: deletes newly created volumes (#4551) https://github.com/seaweedfs/seaweedfs/issues/4531 Co-authored-by: Konstantin Lebedev <9497591+kmlebedev@users.noreply.github.co> --- weed/shell/command_volume_delete_empty.go | 2 +- weed/topology/volume_growth.go | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/weed/shell/command_volume_delete_empty.go b/weed/shell/command_volume_delete_empty.go index 1fa7742b3..4f4e5079d 100644 --- a/weed/shell/command_volume_delete_empty.go +++ b/weed/shell/command_volume_delete_empty.go @@ -57,7 +57,7 @@ func (c *commandVolumeDeleteEmpty) Do(args []string, commandEnv *CommandEnv, wri eachDataNode(topologyInfo, func(dc string, rack RackId, dn *master_pb.DataNodeInfo) { for _, diskInfo := range dn.DiskInfos { for _, v := range diskInfo.VolumeInfos { - if v.Size <= 8 && v.ModifiedAtSecond+quietSeconds < nowUnixSeconds { + if v.Size <= 8 && v.ModifiedAtSecond > 0 && v.ModifiedAtSecond+quietSeconds < nowUnixSeconds { if *applyBalancing { log.Printf("deleting empty volume %d from %s", v.Id, dn.Id) if deleteErr := deleteVolume(commandEnv.option.GrpcDialOption, needle.VolumeId(v.Id), pb.NewServerAddressFromDataNode(dn)); deleteErr != nil { diff --git a/weed/topology/volume_growth.go b/weed/topology/volume_growth.go index 71610730f..0d8893605 100644 --- a/weed/topology/volume_growth.go +++ b/weed/topology/volume_growth.go @@ -6,6 +6,7 @@ import ( "github.com/seaweedfs/seaweedfs/weed/pb/master_pb" "math/rand" "sync" + "time" "google.golang.org/grpc" @@ -240,6 +241,7 @@ func (vg *VolumeGrowth) grow(grpcDialOption grpc.DialOption, topo *Topology, vid Ttl: option.Ttl, Version: needle.CurrentVersion, DiskType: option.DiskType.String(), + ModifiedAtSecond: time.Now().Unix(), }) glog.V(0).Infof("Created Volume %d on %s", vid, server.NodeImpl.String()) } else {