diff options
| author | chrislu <chris.lu@gmail.com> | 2024-04-25 23:42:19 -0700 |
|---|---|---|
| committer | chrislu <chris.lu@gmail.com> | 2024-04-25 23:42:19 -0700 |
| commit | 8948fb51e363bf1011fb754cddd98038bce682cb (patch) | |
| tree | 1cf6d1d65f126a07ed685b39835f1611ec427161 /weed | |
| parent | 63036133ffa04efc95f8751435ef6b80711c6657 (diff) | |
| parent | abf01a0eb724aa82a5b2465c1dbde67bcc795727 (diff) | |
| download | seaweedfs-8948fb51e363bf1011fb754cddd98038bce682cb.tar.xz seaweedfs-8948fb51e363bf1011fb754cddd98038bce682cb.zip | |
Merge branch 'master' into mq-subscribe
Diffstat (limited to 'weed')
| -rw-r--r-- | weed/cluster/lock_manager/lock_ring.go | 2 | ||||
| -rw-r--r-- | weed/images/cropping.go | 2 | ||||
| -rw-r--r-- | weed/images/resizing.go | 2 | ||||
| -rw-r--r-- | weed/shell/command_volume_balance.go | 6 | ||||
| -rw-r--r-- | weed/shell/command_volume_fix_replication.go | 21 | ||||
| -rw-r--r-- | weed/shell/command_volume_tier_move.go | 11 | ||||
| -rw-r--r-- | weed/util/http_util.go | 2 | ||||
| -rw-r--r-- | weed/util/log_buffer/log_read.go | 10 |
8 files changed, 37 insertions, 19 deletions
diff --git a/weed/cluster/lock_manager/lock_ring.go b/weed/cluster/lock_manager/lock_ring.go index c59aab184..9edee1e96 100644 --- a/weed/cluster/lock_manager/lock_ring.go +++ b/weed/cluster/lock_manager/lock_ring.go @@ -72,7 +72,9 @@ func (r *LockRing) SetSnapshot(servers []pb.ServerAddress) { return servers[i] < servers[j] }) + r.Lock() r.lastUpdateTime = time.Now() + r.Unlock() r.addOneSnapshot(servers) diff --git a/weed/images/cropping.go b/weed/images/cropping.go index 10e8620d4..8f9525d1a 100644 --- a/weed/images/cropping.go +++ b/weed/images/cropping.go @@ -8,7 +8,7 @@ import ( "image/png" "io" - "github.com/disintegration/imaging" + "github.com/cognusion/imaging" "github.com/seaweedfs/seaweedfs/weed/glog" ) diff --git a/weed/images/resizing.go b/weed/images/resizing.go index 9d7780e45..aee096cfb 100644 --- a/weed/images/resizing.go +++ b/weed/images/resizing.go @@ -8,7 +8,7 @@ import ( "image/png" "io" - "github.com/disintegration/imaging" + "github.com/cognusion/imaging" "github.com/seaweedfs/seaweedfs/weed/glog" diff --git a/weed/shell/command_volume_balance.go b/weed/shell/command_volume_balance.go index cb201e064..e9a483f41 100644 --- a/weed/shell/command_volume_balance.go +++ b/weed/shell/command_volume_balance.go @@ -402,14 +402,12 @@ func adjustAfterMove(v *master_pb.VolumeInformationMessage, volumeReplicas map[u replica.location = &loc for diskType, diskInfo := range fullNode.info.DiskInfos { if diskType == v.DiskType { - diskInfo.VolumeCount-- - diskInfo.FreeVolumeCount++ + addVolumeCount(diskInfo, -1) } } for diskType, diskInfo := range emptyNode.info.DiskInfos { if diskType == v.DiskType { - diskInfo.VolumeCount++ - diskInfo.FreeVolumeCount-- + addVolumeCount(diskInfo, 1) } } return diff --git a/weed/shell/command_volume_fix_replication.go b/weed/shell/command_volume_fix_replication.go index b724f16f9..074931f40 100644 --- a/weed/shell/command_volume_fix_replication.go +++ b/weed/shell/command_volume_fix_replication.go @@ -4,16 +4,17 @@ import ( "context" "flag" "fmt" + "io" + "path/filepath" + "strconv" + "time" + "github.com/seaweedfs/seaweedfs/weed/pb" "github.com/seaweedfs/seaweedfs/weed/storage/needle" "github.com/seaweedfs/seaweedfs/weed/storage/needle_map" "github.com/seaweedfs/seaweedfs/weed/storage/types" "golang.org/x/exp/slices" "google.golang.org/grpc" - "io" - "path/filepath" - "strconv" - "time" "github.com/seaweedfs/seaweedfs/weed/operation" "github.com/seaweedfs/seaweedfs/weed/pb/master_pb" @@ -316,7 +317,7 @@ func (c *commandVolumeFixReplication) fixOneUnderReplicatedVolume(commandEnv *Co if !takeAction { // adjust volume count - dst.dataNode.DiskInfos[replica.info.DiskType].VolumeCount++ + addVolumeCount(dst.dataNode.DiskInfos[replica.info.DiskType], 1) break } @@ -350,7 +351,7 @@ func (c *commandVolumeFixReplication) fixOneUnderReplicatedVolume(commandEnv *Co } // adjust volume count - dst.dataNode.DiskInfos[replica.info.DiskType].VolumeCount++ + addVolumeCount(dst.dataNode.DiskInfos[replica.info.DiskType], 1) break } } @@ -361,6 +362,14 @@ func (c *commandVolumeFixReplication) fixOneUnderReplicatedVolume(commandEnv *Co return nil } +func addVolumeCount(info *master_pb.DiskInfo, count int) { + if info == nil { + return + } + info.VolumeCount += int64(count) + info.FreeVolumeCount -= int64(count) +} + func keepDataNodesSorted(dataNodes []location, diskType types.DiskType) { fn := capacityByFreeVolumeCount(diskType) slices.SortFunc(dataNodes, func(a, b location) int { diff --git a/weed/shell/command_volume_tier_move.go b/weed/shell/command_volume_tier_move.go index e6cf4ee02..c6364757f 100644 --- a/weed/shell/command_volume_tier_move.go +++ b/weed/shell/command_volume_tier_move.go @@ -5,15 +5,16 @@ import ( "errors" "flag" "fmt" + "io" + "path/filepath" + "sync" + "time" + "github.com/seaweedfs/seaweedfs/weed/glog" "github.com/seaweedfs/seaweedfs/weed/pb" "github.com/seaweedfs/seaweedfs/weed/pb/master_pb" "github.com/seaweedfs/seaweedfs/weed/storage/types" "github.com/seaweedfs/seaweedfs/weed/wdclient" - "io" - "path/filepath" - "sync" - "time" "github.com/seaweedfs/seaweedfs/weed/operation" "github.com/seaweedfs/seaweedfs/weed/pb/volume_server_pb" @@ -212,7 +213,7 @@ func (c *commandVolumeTierMove) doVolumeTierMove(commandEnv *CommandEnv, writer hasFoundTarget = true // adjust volume count - dst.dataNode.DiskInfos[string(toDiskType)].VolumeCount++ + addVolumeCount(dst.dataNode.DiskInfos[string(toDiskType)], 1) destServerAddress := pb.NewServerAddressFromDataNode(dst.dataNode) c.queues[destServerAddress] <- volumeTierMoveJob{sourceVolumeServer, vid} diff --git a/weed/util/http_util.go b/weed/util/http_util.go index 7b3ac4bc4..6f6a17008 100644 --- a/weed/util/http_util.go +++ b/weed/util/http_util.go @@ -328,7 +328,7 @@ func ReadUrlAsStreamAuthenticated(fileUrl, jwt string, cipherKey []byte, isConte } defer CloseResponse(r) if r.StatusCode >= 400 { - retryable = r.StatusCode == http.StatusNotFound || r.StatusCode >= 500 + retryable = r.StatusCode == http.StatusNotFound || r.StatusCode >= 499 return retryable, fmt.Errorf("%s: %s", fileUrl, r.Status) } diff --git a/weed/util/log_buffer/log_read.go b/weed/util/log_buffer/log_read.go index c3dd0f288..0d044fc14 100644 --- a/weed/util/log_buffer/log_read.go +++ b/weed/util/log_buffer/log_read.go @@ -66,9 +66,17 @@ func (logBuffer *LogBuffer) LoopProcessLogData(readerName string, startPosition isDone = true return } + logBuffer.RLock() lastTsNs := logBuffer.LastTsNs - for lastTsNs == logBuffer.LastTsNs { + logBuffer.RUnlock() + loopTsNs := lastTsNs // make a copy + + for lastTsNs == loopTsNs { if waitForDataFn() { + // Update loopTsNs and loop again + logBuffer.RLock() + loopTsNs = logBuffer.LastTsNs + logBuffer.RUnlock() continue } else { isDone = true |
