Skip to content

Commit

Permalink
MB-54798:Race Condition on IndexInfo in GSI client
Browse files Browse the repository at this point in the history
Concurrent read/write is happening on IndexInfo. Create a deep copy of IndexInfo and return that map[string]interface{} to query via IndexMetadata.

Change-Id: I60444d9409d7a69fe48bd2e5faf5b5876b6ed6fa
  • Loading branch information
singlaabhinandan committed Dec 14, 2022
1 parent 926cdb0 commit d97d219
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions secondary/queryport/n1ql/secondary_index.go
Expand Up @@ -1088,12 +1088,17 @@ func (si *secondaryIndex) IndexMetadata() map[string]interface{} {
si.indexStatsHolder.Rwlock.RLock()
defer si.indexStatsHolder.Rwlock.RUnlock()

indexInfo := make(map[string]interface{})
for k, v := range si.indexInfo {
indexInfo[k] = v
}

statsCopy := make(map[string]interface{})
for k, v := range si.indexStatsHolder.StatsMap {
statsCopy[k] = v
}
si.indexInfo["stats"] = statsCopy
return si.indexInfo
indexInfo["stats"] = statsCopy
return indexInfo
}

// State implement Index{} interface.
Expand Down

0 comments on commit d97d219

Please sign in to comment.