diff options
| author | Chris Lu <chrislusf@users.noreply.github.com> | 2021-05-05 07:41:38 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-05-05 07:41:38 -0700 |
| commit | 24efa31e49aea0ff5e0cbdaa1a8cb6267dbcbfed (patch) | |
| tree | 938711f3bb8854b2fdda61d4cd47fdbfb7a24bc5 | |
| parent | e24ba2aadc3c8a7fe4175eda452c6c59989a6b0c (diff) | |
| parent | ac26080bd2153803562838675238a349c203d3e8 (diff) | |
| download | seaweedfs-24efa31e49aea0ff5e0cbdaa1a8cb6267dbcbfed.tar.xz seaweedfs-24efa31e49aea0ff5e0cbdaa1a8cb6267dbcbfed.zip | |
Merge pull request #2045 from qieqieplus/fix-vacuum-commit
| -rw-r--r-- | weed/server/volume_grpc_vacuum.go | 9 | ||||
| -rw-r--r-- | weed/storage/store_vacuum.go | 6 |
2 files changed, 5 insertions, 10 deletions
diff --git a/weed/server/volume_grpc_vacuum.go b/weed/server/volume_grpc_vacuum.go index b87de4b5b..f8d1b7fda 100644 --- a/weed/server/volume_grpc_vacuum.go +++ b/weed/server/volume_grpc_vacuum.go @@ -44,19 +44,14 @@ func (vs *VolumeServer) VacuumVolumeCommit(ctx context.Context, req *volume_serv resp := &volume_server_pb.VacuumVolumeCommitResponse{} - err := vs.store.CommitCompactVolume(needle.VolumeId(req.VolumeId)) + readOnly, err := vs.store.CommitCompactVolume(needle.VolumeId(req.VolumeId)) if err != nil { glog.Errorf("commit volume %d: %v", req.VolumeId, err) } else { glog.V(1).Infof("commit volume %d", req.VolumeId) } - if err == nil { - if vs.store.GetVolume(needle.VolumeId(req.VolumeId)).IsReadOnly() { - resp.IsReadOnly = true - } - } - + resp.IsReadOnly = readOnly return resp, err } diff --git a/weed/storage/store_vacuum.go b/weed/storage/store_vacuum.go index 32666a417..fe2033070 100644 --- a/weed/storage/store_vacuum.go +++ b/weed/storage/store_vacuum.go @@ -25,11 +25,11 @@ func (s *Store) CompactVolume(vid needle.VolumeId, preallocate int64, compaction } return fmt.Errorf("volume id %d is not found during compact", vid) } -func (s *Store) CommitCompactVolume(vid needle.VolumeId) error { +func (s *Store) CommitCompactVolume(vid needle.VolumeId) (bool, error) { if v := s.findVolume(vid); v != nil { - return v.CommitCompact() + return v.IsReadOnly(), v.CommitCompact() } - return fmt.Errorf("volume id %d is not found during commit compact", vid) + return false, fmt.Errorf("volume id %d is not found during commit compact", vid) } func (s *Store) CommitCleanupVolume(vid needle.VolumeId) error { if v := s.findVolume(vid); v != nil { |
