From ef61b36c5ab0cb1570f41e1df25789464708b2d9 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Thu, 29 Mar 2018 12:00:20 -0700 Subject: [PATCH] Fix PUT bucket notification deadlocks (#5734) This PR fixes two different variant of deadlocks in notification. - holding write lock on the bucket competing with read lock - holding competing locks on read/save notification config --- cmd/bucket-notification-handlers.go | 8 -------- cmd/notification.go | 16 ---------------- 2 files changed, 24 deletions(-) diff --git a/cmd/bucket-notification-handlers.go b/cmd/bucket-notification-handlers.go index 5a7b18e9f..a45f52934 100644 --- a/cmd/bucket-notification-handlers.go +++ b/cmd/bucket-notification-handlers.go @@ -138,14 +138,6 @@ func (api objectAPIHandlers) PutBucketNotificationHandler(w http.ResponseWriter, return } - // Acquire a write lock on bucket before modifying its configuration. - bucketLock := globalNSMutex.NewNSLock(bucketName, "") - if err = bucketLock.GetLock(globalOperationTimeout); err != nil { - writeErrorResponse(w, toAPIErrorCode(err), r.URL) - return - } - defer bucketLock.Unlock() - if err = saveNotificationConfig(objectAPI, bucketName, config); err != nil { writeErrorResponse(w, toAPIErrorCode(err), r.URL) return diff --git a/cmd/notification.go b/cmd/notification.go index 030e037c7..d99c7fe3e 100644 --- a/cmd/notification.go +++ b/cmd/notification.go @@ -496,14 +496,6 @@ func readConfig(objAPI ObjectLayer, configFile string) (*bytes.Buffer, error) { func readNotificationConfig(objAPI ObjectLayer, bucketName string) (*event.Config, error) { // Construct path to notification.xml for the given bucket. configFile := path.Join(bucketConfigPrefix, bucketName, bucketNotificationConfig) - - // Get read lock. - objLock := globalNSMutex.NewNSLock(minioMetaBucket, configFile) - if err := objLock.GetRLock(globalOperationTimeout); err != nil { - return nil, err - } - defer objLock.RUnlock() - reader, err := readConfig(objAPI, configFile) if err != nil { return nil, err @@ -519,14 +511,6 @@ func saveNotificationConfig(objAPI ObjectLayer, bucketName string, config *event } configFile := path.Join(bucketConfigPrefix, bucketName, bucketNotificationConfig) - - // Get write lock. - objLock := globalNSMutex.NewNSLock(minioMetaBucket, configFile) - if err := objLock.GetLock(globalOperationTimeout); err != nil { - return err - } - defer objLock.Unlock() - return saveConfig(objAPI, configFile, data) }