Skip to content
This repository was archived by the owner on Nov 7, 2025. It is now read-only.

Commit 4e03bae

Browse files
authored
Ingest stats panic - fix (#1440)
Fixes not protected concurrent map access. ``` fatal error: concurrent map read and map write goroutine 193 [running]: internal/runtime/maps.fatal({0xa2c93c?, 0x0?}) /usr/local/go/src/runtime/panic.go:1058 +0x20 github.com/QuesmaOrg/quesma/platform/stats.(*Statistics).Process(0x1279838?, 0x9f?, {0x400e74199f?, 0x22?}, 0x1d?, {0xa09a4e?, 0x2b?}) /platform/stats/ingest_statistics.go:127 +0x60 github.com/QuesmaOrg/quesma/platform/functionality/bulk.sendToClickhouse({0xc02f78, 0x4015dda210}, 0x0?, {0xf920c5f2d4b8, 0x40001ea408}, 0x1, 0x4000323400) /platform/functionality/bulk/bulk.go:274 +0x18c ```
1 parent ad9b27c commit 4e03bae

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

platform/stats/ingest_statistics.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,6 @@ func (s *Statistics) process(index string,
8383

8484
flatJson := util.FlattenMap(jsonData, nestedSeparator)
8585

86-
mu.Lock()
87-
defer mu.Unlock()
88-
8986
statistics, ok := (*s)[index]
9087
if !ok {
9188
statistics = &IngestStatistics{IndexName: index, Keys: make(map[string]*KeyStatistics)}
@@ -121,6 +118,10 @@ func (s *Statistics) process(index string,
121118
}
122119

123120
func (s *Statistics) Process(ingestStatsEnabled bool, index string, jsonData types.JSON, nestedSeparator string) {
121+
122+
mu.Lock()
123+
defer mu.Unlock()
124+
124125
if ingestStatsEnabled {
125126
s.process(index, jsonData, false, nestedSeparator)
126127
}
@@ -130,6 +131,10 @@ func (s *Statistics) Process(ingestStatsEnabled bool, index string, jsonData typ
130131
}
131132

132133
func (s *Statistics) UpdateNonSchemaValues(ingestStatsEnabled bool, index string, jsonData types.JSON, nestedSeparator string) {
134+
135+
mu.Lock()
136+
defer mu.Unlock()
137+
133138
if ingestStatsEnabled {
134139
s.process(index, jsonData, true, nestedSeparator)
135140
}

0 commit comments

Comments
 (0)