Skip to content

Commit

Permalink
fix(probe): do not contend for lock in lazy load (#8037)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
NamanJain8 authored Sep 20, 2021
1 parent 0060094 commit 5ad40d8
Showing 1 changed file with 0 additions and 3 deletions.
3 changes: 0 additions & 3 deletions graphql/admin/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 5ad40d8

Please sign in to comment.