Clean up metadata cache when deleting bucket (#10802)

Metadata caches were left behind when deleting a bucket.
master
Klaus Post 4 years ago committed by GitHub
parent b686bb9c83
commit 422898d9b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      cmd/metacache-manager.go
  2. 3
      cmd/notification.go
  3. 4
      cmd/peer-rest-server.go

@ -128,6 +128,18 @@ func (m *metacacheManager) getBucket(ctx context.Context, bucket string) *bucket
return b
}
// deleteBucketCache will delete the bucket cache if it exists.
func (m *metacacheManager) deleteBucketCache(bucket string) {
m.mu.Lock()
defer m.mu.Unlock()
b, ok := m.buckets[bucket]
if !ok {
return
}
b.deleteAll()
delete(m.buckets, bucket)
}
// deleteAll will delete all caches.
func (m *metacacheManager) deleteAll() {
m.mu.Lock()

@ -675,6 +675,9 @@ func (sys *NotificationSys) LoadBucketMetadata(ctx context.Context, bucketName s
// DeleteBucketMetadata - calls DeleteBucketMetadata call on all peers
func (sys *NotificationSys) DeleteBucketMetadata(ctx context.Context, bucketName string) {
globalBucketMetadataSys.Remove(bucketName)
if localMetacacheMgr != nil {
localMetacacheMgr.deleteBucketCache(bucketName)
}
ng := WithNPeers(len(sys.peerClients))
for idx, client := range sys.peerClients {

@ -538,7 +538,9 @@ func (s *peerRESTServer) DeleteBucketMetadataHandler(w http.ResponseWriter, r *h
}
globalBucketMetadataSys.Remove(bucketName)
w.(http.Flusher).Flush()
if localMetacacheMgr != nil {
localMetacacheMgr.deleteBucketCache(bucketName)
}
}
// LoadBucketMetadataHandler - reloads in memory bucket metadata

Loading…
Cancel
Save