mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-08-19 13:46:58 +00:00
Fix critical race condition and goroutine leak
This commit is contained in:
+5
-2
@@ -15,6 +15,7 @@ import (
|
||||
"github.com/seaweedfs/seaweedfs/weed/pb/filer_pb"
|
||||
"github.com/seaweedfs/seaweedfs/weed/security"
|
||||
"github.com/seaweedfs/seaweedfs/weed/util"
|
||||
"github.com/seaweedfs/seaweedfs/weed/util/grace"
|
||||
|
||||
// Import credential stores to register them
|
||||
_ "github.com/seaweedfs/seaweedfs/weed/credential/filer_etc"
|
||||
@@ -89,8 +90,10 @@ func (iamopt *IamOptions) startIamServer() bool {
|
||||
glog.Fatalf("IAM API Server startup error: %v", iamApiServer_err)
|
||||
}
|
||||
|
||||
// Ensure cleanup on shutdown
|
||||
defer iamApiServer.Shutdown()
|
||||
// Register shutdown handler to prevent goroutine leak
|
||||
grace.OnInterrupt(func() {
|
||||
iamApiServer.Shutdown()
|
||||
})
|
||||
|
||||
listenAddress := fmt.Sprintf(":%d", *iamopt.port)
|
||||
iamApiListener, iamApiLocalListener, err := util.NewIpAndLocalListeners(*iamopt.ip, *iamopt.port, time.Duration(10)*time.Second)
|
||||
|
||||
@@ -470,6 +470,11 @@ func (p *filerVolumeProvider) LookupVolumeIds(ctx context.Context, volumeIds []s
|
||||
for x := int32(0); x < n; x++ {
|
||||
// Get current filer address and health with read lock
|
||||
fc.filerAddressesMu.RLock()
|
||||
if len(fc.filerAddresses) == 0 {
|
||||
fc.filerAddressesMu.RUnlock()
|
||||
lastErr = fmt.Errorf("no filers available")
|
||||
break
|
||||
}
|
||||
if i >= int32(len(fc.filerAddresses)) {
|
||||
// Filer list changed, reset index
|
||||
i = 0
|
||||
|
||||
Reference in New Issue
Block a user