From b3ab9c0caa355ab09af2bd3515ae896f54baac84 Mon Sep 17 00:00:00 2001 From: Naman Jain Date: Mon, 20 Sep 2021 11:03:06 +0530 Subject: [PATCH] fix(probe): do not contend for lock in lazy load (#8037) Earlier the admin server mutex lock was used to protect the graphql schema map. But now we store that in schema store that internally handles the concurrency. Hence, we don't need to take the admin server's read lock to access schema. /probe/graphql is used as health check and is called very frequently. This rlock on adminserver mutex makes the /probe/graphql requests block while lazy loading when restore operation gets triggered at the startup. That leads to so many go routines being spun up. --- graphql/admin/admin.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/graphql/admin/admin.go b/graphql/admin/admin.go index 0d45d3f4ec6..0d1f7998cde 100644 --- a/graphql/admin/admin.go +++ b/graphql/admin/admin.go @@ -1077,12 +1077,9 @@ func (as *adminServer) resetSchema(ns uint64, gqlSchema schema.Schema) { func (as *adminServer) lazyLoadSchema(namespace uint64) error { // if the schema is already in memory, no need to fetch it from disk - as.mux.RLock() if currentSchema, ok := as.gqlSchemas.GetCurrent(namespace); ok && currentSchema.Loaded { - as.mux.RUnlock() return nil } - as.mux.RUnlock() // otherwise, fetch the schema from disk sch, err := getCurrentGraphQLSchema(namespace)