aboutsummaryrefslogtreecommitdiff
path: root/weed/topology
diff options
context:
space:
mode:
authorChris Lu <chrislusf@users.noreply.github.com>2019-01-10 09:02:13 -0800
committerGitHub <noreply@github.com>2019-01-10 09:02:13 -0800
commite978f3aaaba844f9b8def8fa9aed7872595f3245 (patch)
tree3d000a41408651ef4d2b6331501c550387c4a5a7 /weed/topology
parent2a75a36b275ea7f47a95ad2efc70be22d5ed3fe2 (diff)
parent39c745588111cebef0475f2453ee0715e0153c49 (diff)
downloadseaweedfs-e978f3aaaba844f9b8def8fa9aed7872595f3245.tar.xz
seaweedfs-e978f3aaaba844f9b8def8fa9aed7872595f3245.zip
Merge pull request #829 from PapaYofen/fix-823
Fix https://github.com/chrislusf/seaweedfs/issues/823
Diffstat (limited to 'weed/topology')
-rw-r--r--weed/topology/allocate_volume.go6
-rw-r--r--weed/topology/topology_vacuum.go16
2 files changed, 18 insertions, 4 deletions
diff --git a/weed/topology/allocate_volume.go b/weed/topology/allocate_volume.go
index 61fc9d479..55796ab43 100644
--- a/weed/topology/allocate_volume.go
+++ b/weed/topology/allocate_volume.go
@@ -2,6 +2,7 @@ package topology
import (
"context"
+ "time"
"github.com/chrislusf/seaweedfs/weed/operation"
"github.com/chrislusf/seaweedfs/weed/pb/volume_server_pb"
@@ -15,7 +16,10 @@ type AllocateVolumeResult struct {
func AllocateVolume(dn *DataNode, vid storage.VolumeId, option *VolumeGrowOption) error {
return operation.WithVolumeServerClient(dn.Url(), func(client volume_server_pb.VolumeServerClient) error {
- _, deleteErr := client.AssignVolume(context.Background(), &volume_server_pb.AssignVolumeRequest{
+ ctx, cancel := context.WithTimeout(context.Background(), time.Duration(5*time.Second))
+ defer cancel()
+
+ _, deleteErr := client.AssignVolume(ctx, &volume_server_pb.AssignVolumeRequest{
VolumdId: uint32(vid),
Collection: option.Collection,
Replication: option.ReplicaPlacement.String(),
diff --git a/weed/topology/topology_vacuum.go b/weed/topology/topology_vacuum.go
index e386dabdb..95d9376d5 100644
--- a/weed/topology/topology_vacuum.go
+++ b/weed/topology/topology_vacuum.go
@@ -15,7 +15,10 @@ func batchVacuumVolumeCheck(vl *VolumeLayout, vid storage.VolumeId, locationlist
for index, dn := range locationlist.list {
go func(index int, url string, vid storage.VolumeId) {
err := operation.WithVolumeServerClient(url, func(volumeServerClient volume_server_pb.VolumeServerClient) error {
- resp, err := volumeServerClient.VacuumVolumeCheck(context.Background(), &volume_server_pb.VacuumVolumeCheckRequest{
+ ctx, cancel := context.WithTimeout(context.Background(), time.Duration(5*time.Second))
+ defer cancel()
+
+ resp, err := volumeServerClient.VacuumVolumeCheck(ctx, &volume_server_pb.VacuumVolumeCheckRequest{
VolumdId: uint32(vid),
})
if err != nil {
@@ -48,6 +51,7 @@ func batchVacuumVolumeCompact(vl *VolumeLayout, vid storage.VolumeId, locationli
ch := make(chan bool, locationlist.Length())
for index, dn := range locationlist.list {
go func(index int, url string, vid storage.VolumeId) {
+ // TODO: set timeout according to actual compact duration
glog.V(0).Infoln(index, "Start vacuuming", vid, "on", url)
err := operation.WithVolumeServerClient(url, func(volumeServerClient volume_server_pb.VolumeServerClient) error {
_, err := volumeServerClient.VacuumVolumeCompact(context.Background(), &volume_server_pb.VacuumVolumeCompactRequest{
@@ -81,7 +85,10 @@ func batchVacuumVolumeCommit(vl *VolumeLayout, vid storage.VolumeId, locationlis
for _, dn := range locationlist.list {
glog.V(0).Infoln("Start Commiting vacuum", vid, "on", dn.Url())
err := operation.WithVolumeServerClient(dn.Url(), func(volumeServerClient volume_server_pb.VolumeServerClient) error {
- _, err := volumeServerClient.VacuumVolumeCommit(context.Background(), &volume_server_pb.VacuumVolumeCommitRequest{
+ ctx, cancel := context.WithTimeout(context.Background(), time.Duration(5*time.Second))
+ defer cancel()
+
+ _, err := volumeServerClient.VacuumVolumeCommit(ctx, &volume_server_pb.VacuumVolumeCommitRequest{
VolumdId: uint32(vid),
})
return err
@@ -102,7 +109,10 @@ func batchVacuumVolumeCleanup(vl *VolumeLayout, vid storage.VolumeId, locationli
for _, dn := range locationlist.list {
glog.V(0).Infoln("Start cleaning up", vid, "on", dn.Url())
err := operation.WithVolumeServerClient(dn.Url(), func(volumeServerClient volume_server_pb.VolumeServerClient) error {
- _, err := volumeServerClient.VacuumVolumeCleanup(context.Background(), &volume_server_pb.VacuumVolumeCleanupRequest{
+ ctx, cancel := context.WithTimeout(context.Background(), time.Duration(5*time.Second))
+ defer cancel()
+
+ _, err := volumeServerClient.VacuumVolumeCleanup(ctx, &volume_server_pb.VacuumVolumeCleanupRequest{
VolumdId: uint32(vid),
})
return err