From 07dd0692b6807eb8bca298e8d2bc5161e0be76fc Mon Sep 17 00:00:00 2001 From: "Daniel A. Ochoa" Date: Mon, 8 Nov 2021 11:07:58 -0600 Subject: [PATCH] Fix hdfs gateway concurrent map writes (#13596) Co-authored-by: Harshavardhana --- cmd/gateway/hdfs/gateway-hdfs.go | 5 +++++ cmd/metrics.go | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/cmd/gateway/hdfs/gateway-hdfs.go b/cmd/gateway/hdfs/gateway-hdfs.go index ebb5f32bc..9012a5dc0 100644 --- a/cmd/gateway/hdfs/gateway-hdfs.go +++ b/cmd/gateway/hdfs/gateway-hdfs.go @@ -28,6 +28,7 @@ import ( "path" "sort" "strings" + "sync" "syscall" "time" @@ -407,6 +408,7 @@ func (n *hdfsObjects) listDirFactory() minio.ListDirFunc { // ListObjects lists all blobs in HDFS bucket filtered by prefix. func (n *hdfsObjects) ListObjects(ctx context.Context, bucket, prefix, marker, delimiter string, maxKeys int) (loi minio.ListObjectsInfo, err error) { + var mutex sync.Mutex fileInfos := make(map[string]os.FileInfo) targetPath := n.hdfsPathJoin(bucket, prefix) @@ -430,6 +432,9 @@ func (n *hdfsObjects) ListObjects(ctx context.Context, bucket, prefix, marker, d } getObjectInfo := func(ctx context.Context, bucket, entry string) (minio.ObjectInfo, error) { + mutex.Lock() + defer mutex.Unlock() + filePath := path.Clean(n.hdfsPathJoin(bucket, entry)) fi, ok := fileInfos[filePath] diff --git a/cmd/metrics.go b/cmd/metrics.go index 1ec4000c8..66f30bad7 100644 --- a/cmd/metrics.go +++ b/cmd/metrics.go @@ -108,6 +108,10 @@ func (c *minioCollector) Collect(ch chan<- prometheus.Metric) { } func nodeHealthMetricsPrometheus(ch chan<- prometheus.Metric) { + if globalIsGateway { + return + } + nodesUp, nodesDown := GetPeerOnlineCount() ch <- prometheus.MustNewConstMetric( prometheus.NewDesc(